encrypting replies to encrypted mail
[notmuch-archives.git] / be / e4094ca49f7ece279b534a2109c80d39a70549
1 Return-Path: <lrilling@gmail.com>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 1B582431FD0\r
6         for <notmuch@notmuchmail.org>; Mon, 11 Jul 2011 15:38:16 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.699\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.699 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001,\r
13         RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id FSqPRRj03bqk for <notmuch@notmuchmail.org>;\r
17         Mon, 11 Jul 2011 15:38:14 -0700 (PDT)\r
18 Received: from mail-fx0-f46.google.com (mail-fx0-f46.google.com\r
19         [209.85.161.46]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id 28D06431FB6\r
22         for <notmuch@notmuchmail.org>; Mon, 11 Jul 2011 15:38:14 -0700 (PDT)\r
23 Received: by fxh19 with SMTP id 19so4426485fxh.19\r
24         for <notmuch@notmuchmail.org>; Mon, 11 Jul 2011 15:38:12 -0700 (PDT)\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
26         h=sender:date:from:to:cc:subject:message-id:references:mime-version\r
27         :content-type:content-disposition:in-reply-to:user-agent;\r
28         bh=IoB5MKBF3FvQ39ci8MYqNHzjj3scSlKTtGIgeQ583/Q=;\r
29         b=Yrj/6ZmW3SledT0IfLEcaPFiNynuhwcMbBa2ObayyINZlpCKSboSQgviDFEk45Scoz\r
30         mJJMfqC/4Wajq/dRULd1l2jGTDB/icZNVjplz3pQ+XrtuUkaEjMqKOyQte2aJvaKBHje\r
31         p7j0QPA0uwbC5Slg6ehypYxOYAJ1XwkMFhU+E=\r
32 Received: by 10.223.68.22 with SMTP id t22mr8251046fai.145.1310423892619;\r
33         Mon, 11 Jul 2011 15:38:12 -0700 (PDT)\r
34 Received: from localdomain ([78.222.14.116])\r
35         by mx.google.com with ESMTPS id f15sm8360242fai.46.2011.07.11.15.38.11\r
36         (version=SSLv3 cipher=OTHER); Mon, 11 Jul 2011 15:38:11 -0700 (PDT)\r
37 Sender: Louis Rilling <lrilling@gmail.com>\r
38 Date: Tue, 12 Jul 2011 00:38:05 +0200\r
39 From: Louis Rilling <l.rilling@av7.net>\r
40 To: Austin Clements <amdragon@MIT.EDU>\r
41 Subject: Re: [PATCH 2/2] tags_to_maildir_flags: Don't rename if no flags\r
42  change\r
43 Message-ID: <20110711223805.GC3583@localdomain>\r
44 References: <87d3hzgemi.fsf@yoom.home.cworth.org>\r
45         <1310394978-11883-3-git-send-email-l.rilling@av7.net>\r
46         <20110711200712.GB25558@mit.edu>\r
47 MIME-Version: 1.0\r
48 Content-Type: text/plain; charset=us-ascii\r
49 Content-Disposition: inline\r
50 In-Reply-To: <20110711200712.GB25558@mit.edu>\r
51 User-Agent: Mutt/1.5.20 (2009-06-14)\r
52 Cc: notmuch@notmuchmail.org\r
53 X-BeenThere: notmuch@notmuchmail.org\r
54 X-Mailman-Version: 2.1.13\r
55 Precedence: list\r
56 List-Id: "Use and development of the notmuch mail system."\r
57         <notmuch.notmuchmail.org>\r
58 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
59         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
60 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
61 List-Post: <mailto:notmuch@notmuchmail.org>\r
62 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
63 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
64         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
65 X-List-Received-Date: Mon, 11 Jul 2011 22:38:16 -0000\r
66 \r
67 On 11/07/11 16:07 -0400, Austin Clements wrote:\r
68 > I worry that this may compound the confusion caused by mutt's handling\r
69 > of the new flag, but I suppose people aren't likely to manipulate any\r
70 > of the other maildir-synchronized flags without also marking the\r
71 > message as seen.\r
72 \r
73 Even if they don't mark the message as seen, any flag changed would move the message to cur/. The only buggy behavior would be from mutt, with the bug you mentioned about mutt putting messages with flags back to new/.\r
74 \r
75 > At any rate, the change is certainly correct\r
76 > technically.  A few nits below.\r
77 \r
78 They should be addressed by the follow-up patch. Just a comment below.\r
79 \r
80\r
81 > Quoth Louis Rilling on Jul 11 at  4:36 pm:\r
82 > > notmuch_message_tags_to_maildir_flags() unconditionally moves messages from\r
83 > > maildir directory "new/" to maildir directory "cur/", which makes messages lose\r
84 > > their "new" status in the MUA. However some users want to keep this "new"\r
85 > > status after, for instance, an auto-tagging of new messages.\r
86 > > \r
87 > > However, as Austin mentioned and according to the maildir specification,\r
88 > > messages living in "new/" are not allowed to have flags, even if mutt allows it\r
89 > > to happen. For this reason, this patch prevents moving messages from "new/" to\r
90 > > "cur/", only if no flags have to be changed. It's hopefully enough to satisfy\r
91 > > mutt (and maybe other MUAs showing the "new" status) users checking the "new"\r
92 > > status.\r
93 > > \r
94 > > Signed-off-by: Louis Rilling <l.rilling@av7.net>\r
95 > > ---\r
96 > >  lib/message.cc |   12 +++++++++++-\r
97 > >  1 files changed, 11 insertions(+), 1 deletions(-)\r
98 > > \r
99 > > diff --git a/lib/message.cc b/lib/message.cc\r
100 > > index 64b6cf8..131d99b 100644\r
101 > > --- a/lib/message.cc\r
102 > > +++ b/lib/message.cc\r
103 > > @@ -1139,7 +1139,7 @@ _get_maildir_flag_actions (notmuch_message_t *message,\r
104 > >   * compute the new maildir filename.\r
105 > >   *\r
106 > >   * If the existing filename is in the directory "new", the new\r
107 > > - * filename will be in the directory "cur".\r
108 > > + * filename will be in the directory "cur", unless no flags are changed.\r
109 > >   *\r
110 > >   * After a sequence of ":2," in the filename, any subsequent\r
111 > >   * single-character flags will be added or removed according to the\r
112 > > @@ -1162,6 +1162,7 @@ _new_maildir_filename (void *ctx,\r
113 > >      char *filename_new, *dir;\r
114 > >      char flag_map[128];\r
115 > >      int flags_in_map = 0;\r
116 > > +    bool flags_changed = false;\r
117\r
118 > The convention in notmuch is to use notmuch_bool_t, TRUE, and FALSE\r
119 > (though, admittedly, I don't know why; avoiding C99-isms?)\r
120 \r
121 And bool is already used at another place in message.cc:\r
122 \r
123         struct maildir_flag_tag {\r
124             char flag;\r
125             const char *tag;\r
126             bool inverse;\r
127         };\r
128 \r
129 IIUC it should be changed to notmuch_bool_t too.\r
130 \r
131\r
132 > >      unsigned int i;\r
133 > >      char *s;\r
134 > >  \r
135 > > @@ -1202,6 +1203,7 @@ _new_maildir_filename (void *ctx,\r
136 > >     if (flag_map[flag] == 0) {\r
137 > >         flag_map[flag] = 1;\r
138 > >         flags_in_map++;\r
139 > > +       flags_changed = true;\r
140 > >     }\r
141 > >      }\r
142 > >  \r
143 > > @@ -1210,9 +1212,17 @@ _new_maildir_filename (void *ctx,\r
144 > >     if (flag_map[flag]) {\r
145 > >         flag_map[flag] = 0;\r
146 > >         flags_in_map--;\r
147 > > +       flags_changed = true;\r
148 > >     }\r
149 > >      }\r
150 > >  \r
151 > > +    /* No need to rename. Messages in new/ can be kept in new/.\r
152 > > +     * Note: We don't even try to fix buggy messages having flags and living in\r
153 > > +     * new/. It's not our business.\r
154 > > +     */\r
155 > > +    if (!flags_changed)\r
156 > > +   return NULL;\r
157 > > +\r
158\r
159 > NULL generally indicates an error in notmuch and is currently used\r
160 > that way in _new_maildir_filename, so even though the caller currently\r
161 > doesn't really care, I'd lean against overloading it to indicate that\r
162 > the filename doesn't need to change.  Despite the slight inefficiency,\r
163 > I would recommend returning talloc_strdup (ctx, filename).\r
164 \r
165 Ok.\r
166 \r
167 Thanks,\r
168 \r
169 Louis\r
170 \r
171\r
172 > >      filename_new = (char *) talloc_size (ctx,\r
173 > >                                      info - filename +\r
174 > >                                      strlen (":2,") + flags_in_map + 1);\r