1 Return-Path: <amdragon@mit.edu>
\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 EC9A3429E27
\r
6 for <notmuch@notmuchmail.org>; Thu, 12 Jan 2012 14:02:51 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id 0+r6ya1plusQ for <notmuch@notmuchmail.org>;
\r
16 Thu, 12 Jan 2012 14:02:51 -0800 (PST)
\r
17 Received: from dmz-mailsec-scanner-8.mit.edu (DMZ-MAILSEC-SCANNER-8.MIT.EDU
\r
19 by olra.theworths.org (Postfix) with ESMTP id E22AC429E26
\r
20 for <notmuch@notmuchmail.org>; Thu, 12 Jan 2012 14:02:50 -0800 (PST)
\r
21 X-AuditID: 12074425-b7f4a6d0000008e0-83-4f0f588abca6
\r
22 Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])
\r
23 by dmz-mailsec-scanner-8.mit.edu (Symantec Messaging Gateway) with SMTP
\r
24 id DB.DB.02272.A885F0F4; Thu, 12 Jan 2012 17:02:50 -0500 (EST)
\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])
\r
26 by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id q0CM2nuK016803;
\r
27 Thu, 12 Jan 2012 17:02:49 -0500
\r
28 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])
\r
29 (authenticated bits=0)
\r
30 (User authenticated as amdragon@ATHENA.MIT.EDU)
\r
31 by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q0CM2mT3023426
\r
32 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);
\r
33 Thu, 12 Jan 2012 17:02:49 -0500 (EST)
\r
34 Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77)
\r
35 (envelope-from <amdragon@mit.edu>)
\r
36 id 1RlSjT-0006Xb-BY; Thu, 12 Jan 2012 17:02:51 -0500
\r
37 Date: Thu, 12 Jan 2012 17:02:51 -0500
\r
38 From: Austin Clements <amdragon@MIT.EDU>
\r
39 To: Jani Nikula <jani@nikula.org>
\r
40 Subject: Re: [PATCH v4 2/5] cli: add support for replying just to the sender
\r
42 Message-ID: <20120112220251.GG18625@mit.edu>
\r
43 References: <cover.1325794371.git.jani@nikula.org>
\r
44 <cover.1326403905.git.jani@nikula.org>
\r
45 <9be66534c17fbffe00b0c1201f378e60fadd11d1.1326403905.git.jani@nikula.org>
\r
47 Content-Type: text/plain; charset=us-ascii
\r
48 Content-Disposition: inline
\r
50 <9be66534c17fbffe00b0c1201f378e60fadd11d1.1326403905.git.jani@nikula.org>
\r
51 User-Agent: Mutt/1.5.21 (2010-09-15)
\r
52 X-Brightmail-Tracker:
\r
53 H4sIAAAAAAAAA+NgFuphleLIzCtJLcpLzFFi42IRYrdT1+2K4Pc32DhP1qJpurPF6rk8Ftdv
\r
54 zmR2YPbYOesuu8et+6/ZPZ6tusUcwBzFZZOSmpNZllqkb5fAlbFu7gz2gj6nipuT/jI1MG4x
\r
55 7mLk5JAQMJHYM3cDO4QtJnHh3nq2LkYuDiGBfYwSPU3fmSGcDYwSl4+cZAKpEhI4ySTx8W8G
\r
56 RGIJo8Tbm1fZQBIsAqoSr56+ZAax2QQ0JLbtX84IYosIKEpsPrkfzGYWMJNYOfU72CBhgUSJ
\r
57 3devgcV5BXQkNi1pY4QYupxRYvbNZywQCUGJkzOfsEA0a0nc+PcSqJkDyJaWWP6PAyTMKRAm
\r
58 8eLnUbASUQEViSknt7FNYBSahaR7FpLuWQjdCxiZVzHKpuRW6eYmZuYUpybrFicn5uWlFula
\r
59 6OVmluilppRuYgQHuovqDsYJh5QOMQpwMCrx8L4S5vcXYk0sK67MPcQoycGkJMrLCowTIb6k
\r
60 /JTKjMTijPii0pzU4kOMEhzMSiK8MbpAOd6UxMqq1KJ8mJQ0B4uSOK+m1js/IYH0xJLU7NTU
\r
61 gtQimKwMB4eSBO+ZcKBGwaLU9NSKtMycEoQ0EwcnyHAeoOHHQGp4iwsSc4sz0yHypxgVpcR5
\r
62 r4MkBEASGaV5cL2wRPSKURzoFWHe4yBVPMAkBtf9CmgwE9DgshQ+kMEliQgpqQbGwy2V2Y9Z
\r
63 k++y+jzpMGpzrOdeqHPZI/JfZoNJ8nLR+ENSFS49Scc3rLKPb585zfHjs46bffx7YpZErNnx
\r
64 ePPcHPmYEMX23Qte2/GYnai8MOW9t+YRi1nzJ1tf5mRq+mFpk97gueyOjXKG9O/zV84vf6me
\r
65 x/XzyLObpW/3Cxm22fokZkXGTjmhxFKckWioxVxUnAgAo7O54B8DAAA=
\r
66 Cc: notmuch@notmuchmail.org
\r
67 X-BeenThere: notmuch@notmuchmail.org
\r
68 X-Mailman-Version: 2.1.13
\r
70 List-Id: "Use and development of the notmuch mail system."
\r
71 <notmuch.notmuchmail.org>
\r
72 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
73 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
74 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
75 List-Post: <mailto:notmuch@notmuchmail.org>
\r
76 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
77 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
78 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
79 X-List-Received-Date: Thu, 12 Jan 2012 22:02:52 -0000
\r
81 LGTM. Again, one minor nit below, but not enough to hold up this
\r
84 Quoth Jani Nikula on Jan 12 at 11:40 pm:
\r
85 > Add new option --reply-to=(all|sender) to "notmuch reply" to select whether
\r
86 > to reply to all (sender and all recipients), or just sender. Reply to all
\r
87 > remains the default.
\r
89 > Credits to Mark Walters <markwalters1009@gmail.com> for his similar earlier
\r
90 > work where I picked up the basic idea of handling reply-to-sender in
\r
91 > add_recipients_from_message(). All bugs are mine, though.
\r
93 > Signed-off-by: Jani Nikula <jani@nikula.org>
\r
97 > Settled on --reply-to=(all|sender) per Carl's earlier suggestion
\r
98 > (id:87pqn5cg4g.fsf@yoom.home.cworth.org) and David's approval on IRC.
\r
100 > man/man1/notmuch-reply.1 | 28 ++++++++++++++++++++----
\r
101 > notmuch-reply.c | 52 +++++++++++++++++++++++++++++++++++++--------
\r
102 > 2 files changed, 65 insertions(+), 15 deletions(-)
\r
104 > diff --git a/man/man1/notmuch-reply.1 b/man/man1/notmuch-reply.1
\r
105 > index db464d8..5160ece 100644
\r
106 > --- a/man/man1/notmuch-reply.1
\r
107 > +++ b/man/man1/notmuch-reply.1
\r
108 > @@ -14,11 +14,13 @@ Constructs a reply template for a set of messages.
\r
109 > To make replying to email easier,
\r
111 > takes an existing set of messages and constructs a suitable mail
\r
112 > -template. The Reply-to header (if any, otherwise From:) is used for
\r
113 > -the To: address. Vales from the To: and Cc: headers are copied, but
\r
114 > -not including any of the current user's email addresses (as configured
\r
115 > -in primary_mail or other_email in the .notmuch\-config file) in the
\r
117 > +template. The Reply-to: header (if any, otherwise From:) is used for
\r
118 > +the To: address. Unless
\r
119 > +.BR \-\-reply-to=sender
\r
120 > +is specified, values from the To: and Cc: headers are copied, but not
\r
121 > +including any of the current user's email addresses (as configured in
\r
122 > +primary_mail or other_email in the .notmuch\-config file) in the
\r
125 > It also builds a suitable new subject, including Re: at the front (if
\r
126 > not already present), and adding the message IDs of the messages being
\r
127 > @@ -45,6 +47,22 @@ Includes subject and quoted message body.
\r
128 > Only produces In\-Reply\-To, References, To, Cc, and Bcc headers.
\r
133 > +.BR \-\-reply\-to= ( all | sender )
\r
136 > +.BR all " (default)"
\r
137 > +Replies to all addresses.
\r
140 > +Replies only to the sender. If replying to user's own message
\r
141 > +(Reply-to: or From: header is one of the user's configured email
\r
142 > +addresses), try To:, Cc:, and Bcc: headers in this order, and copy
\r
143 > +values from the first that contains something other than only the
\r
144 > +user's addresses.
\r
148 > See \fBnotmuch-search-terms\fR(7)
\r
149 > for details of the supported syntax for <search-terms>.
\r
150 > diff --git a/notmuch-reply.c b/notmuch-reply.c
\r
151 > index 4fae66f..b4c81de 100644
\r
152 > --- a/notmuch-reply.c
\r
153 > +++ b/notmuch-reply.c
\r
154 > @@ -289,7 +289,14 @@ reply_to_header_is_redundant (notmuch_message_t *message)
\r
158 > -/* Augments the recipients of reply from the headers of message.
\r
159 > +/* Augment the recipients of 'reply' from the "Reply-to:", "From:", "To:",
\r
160 > + * "Cc:", and "Bcc:" headers of 'message'.
\r
162 > + * If 'reply_all' is true, use sender and all recipients, otherwise scan the
\r
163 > + * headers for the first that contains something other than the user's addresses
\r
164 > + * and add the recipients from this header (typically this would be
\r
165 > + * reply-to-sender, but also handles reply to user's own message in a sensible
\r
168 Same comment about 80 column wrapping.
\r
171 > * If any of the user's addresses were found in these headers, the first
\r
172 > * of these returned, otherwise NULL is returned.
\r
173 > @@ -297,7 +304,8 @@ reply_to_header_is_redundant (notmuch_message_t *message)
\r
174 > static const char *
\r
175 > add_recipients_from_message (GMimeMessage *reply,
\r
176 > notmuch_config_t *config,
\r
177 > - notmuch_message_t *message)
\r
178 > + notmuch_message_t *message,
\r
179 > + notmuch_bool_t reply_all)
\r
182 > const char *header;
\r
183 > @@ -311,6 +319,7 @@ add_recipients_from_message (GMimeMessage *reply,
\r
185 > const char *from_addr = NULL;
\r
187 > + unsigned int n = 0;
\r
189 > /* Some mailing lists munge the Reply-To header despite it being A Bad
\r
190 > * Thing, see http://www.unicom.com/pw/reply-to-harmful.html
\r
191 > @@ -337,8 +346,23 @@ add_recipients_from_message (GMimeMessage *reply,
\r
192 > recipients = notmuch_message_get_header (message,
\r
193 > reply_to_map[i].fallback);
\r
195 > - scan_address_string (recipients, config, reply,
\r
196 > - reply_to_map[i].recipient_type, &from_addr);
\r
197 > + n += scan_address_string (recipients, config, reply,
\r
198 > + reply_to_map[i].recipient_type, &from_addr);
\r
200 > + if (!reply_all && n) {
\r
201 > + /* Stop adding new recipients in reply-to-sender mode if we have
\r
202 > + * added some recipient(s) above.
\r
204 > + * This also handles the case of user replying to his own message,
\r
205 > + * where reply-to/from is not a recipient. In this case there may be
\r
206 > + * more than one recipient even if not replying to all.
\r
210 > + /* From address and some recipients are enough, bail out. */
\r
219 > return from_addr;
\r
220 > @@ -482,7 +506,8 @@ static int
\r
221 > notmuch_reply_format_default(void *ctx,
\r
222 > notmuch_config_t *config,
\r
223 > notmuch_query_t *query,
\r
224 > - notmuch_show_params_t *params)
\r
225 > + notmuch_show_params_t *params,
\r
226 > + notmuch_bool_t reply_all)
\r
228 > GMimeMessage *reply;
\r
229 > notmuch_messages_t *messages;
\r
230 > @@ -511,7 +536,8 @@ notmuch_reply_format_default(void *ctx,
\r
231 > g_mime_message_set_subject (reply, subject);
\r
234 > - from_addr = add_recipients_from_message (reply, config, message);
\r
235 > + from_addr = add_recipients_from_message (reply, config, message,
\r
238 > if (from_addr == NULL)
\r
239 > from_addr = guess_from_received_header (config, message);
\r
240 > @@ -560,7 +586,8 @@ static int
\r
241 > notmuch_reply_format_headers_only(void *ctx,
\r
242 > notmuch_config_t *config,
\r
243 > notmuch_query_t *query,
\r
244 > - unused (notmuch_show_params_t *params))
\r
245 > + unused (notmuch_show_params_t *params),
\r
246 > + notmuch_bool_t reply_all)
\r
248 > GMimeMessage *reply;
\r
249 > notmuch_messages_t *messages;
\r
250 > @@ -600,7 +627,7 @@ notmuch_reply_format_headers_only(void *ctx,
\r
251 > g_mime_object_set_header (GMIME_OBJECT (reply),
\r
252 > "References", references);
\r
254 > - (void)add_recipients_from_message (reply, config, message);
\r
255 > + (void)add_recipients_from_message (reply, config, message, reply_all);
\r
257 > reply_headers = g_mime_object_to_string (GMIME_OBJECT (reply));
\r
258 > printf ("%s", reply_headers);
\r
259 > @@ -627,9 +654,10 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
\r
260 > notmuch_query_t *query;
\r
261 > char *query_string;
\r
262 > int opt_index, ret = 0;
\r
263 > - int (*reply_format_func)(void *ctx, notmuch_config_t *config, notmuch_query_t *query, notmuch_show_params_t *params);
\r
264 > + int (*reply_format_func)(void *ctx, notmuch_config_t *config, notmuch_query_t *query, notmuch_show_params_t *params, notmuch_bool_t reply_all);
\r
265 > notmuch_show_params_t params = { .part = -1 };
\r
266 > int format = FORMAT_DEFAULT;
\r
267 > + int reply_all = TRUE;
\r
268 > notmuch_bool_t decrypt = FALSE;
\r
270 > notmuch_opt_desc_t options[] = {
\r
271 > @@ -637,6 +665,10 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
\r
272 > (notmuch_keyword_t []){ { "default", FORMAT_DEFAULT },
\r
273 > { "headers-only", FORMAT_HEADERS_ONLY },
\r
275 > + { NOTMUCH_OPT_KEYWORD, &reply_all, "reply-to", 'r',
\r
276 > + (notmuch_keyword_t []){ { "all", TRUE },
\r
277 > + { "sender", FALSE },
\r
279 > { NOTMUCH_OPT_BOOLEAN, &decrypt, "decrypt", 'd', 0 },
\r
280 > { 0, 0, 0, 0, 0 }
\r
282 > @@ -690,7 +722,7 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
\r
286 > - if (reply_format_func (ctx, config, query, ¶ms) != 0)
\r
287 > + if (reply_format_func (ctx, config, query, ¶ms, reply_all) != 0)
\r
290 > notmuch_query_destroy (query);
\r