Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id EC9A3429E27 for ; Thu, 12 Jan 2012 14:02:51 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0+r6ya1plusQ for ; Thu, 12 Jan 2012 14:02:51 -0800 (PST) Received: from dmz-mailsec-scanner-8.mit.edu (DMZ-MAILSEC-SCANNER-8.MIT.EDU [18.7.68.37]) by olra.theworths.org (Postfix) with ESMTP id E22AC429E26 for ; Thu, 12 Jan 2012 14:02:50 -0800 (PST) X-AuditID: 12074425-b7f4a6d0000008e0-83-4f0f588abca6 Received: from mailhub-auth-4.mit.edu ( [18.7.62.39]) by dmz-mailsec-scanner-8.mit.edu (Symantec Messaging Gateway) with SMTP id DB.DB.02272.A885F0F4; Thu, 12 Jan 2012 17:02:50 -0500 (EST) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id q0CM2nuK016803; Thu, 12 Jan 2012 17:02:49 -0500 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q0CM2mT3023426 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Thu, 12 Jan 2012 17:02:49 -0500 (EST) Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77) (envelope-from ) id 1RlSjT-0006Xb-BY; Thu, 12 Jan 2012 17:02:51 -0500 Date: Thu, 12 Jan 2012 17:02:51 -0500 From: Austin Clements To: Jani Nikula Subject: Re: [PATCH v4 2/5] cli: add support for replying just to the sender in "notmuch reply" Message-ID: <20120112220251.GG18625@mit.edu> References: <9be66534c17fbffe00b0c1201f378e60fadd11d1.1326403905.git.jani@nikula.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9be66534c17fbffe00b0c1201f378e60fadd11d1.1326403905.git.jani@nikula.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuphleLIzCtJLcpLzFFi42IRYrdT1+2K4Pc32DhP1qJpurPF6rk8Ftdv zmR2YPbYOesuu8et+6/ZPZ6tusUcwBzFZZOSmpNZllqkb5fAlbFu7gz2gj6nipuT/jI1MG4x 7mLk5JAQMJHYM3cDO4QtJnHh3nq2LkYuDiGBfYwSPU3fmSGcDYwSl4+cZAKpEhI4ySTx8W8G RGIJo8Tbm1fZQBIsAqoSr56+ZAax2QQ0JLbtX84IYosIKEpsPrkfzGYWMJNYOfU72CBhgUSJ 3devgcV5BXQkNi1pY4QYupxRYvbNZywQCUGJkzOfsEA0a0nc+PcSqJkDyJaWWP6PAyTMKRAm 8eLnUbASUQEViSknt7FNYBSahaR7FpLuWQjdCxiZVzHKpuRW6eYmZuYUpybrFicn5uWlFula 6OVmluilppRuYgQHuovqDsYJh5QOMQpwMCrx8L4S5vcXYk0sK67MPcQoycGkJMrLCowTIb6k /JTKjMTijPii0pzU4kOMEhzMSiK8MbpAOd6UxMqq1KJ8mJQ0B4uSOK+m1js/IYH0xJLU7NTU gtQimKwMB4eSBO+ZcKBGwaLU9NSKtMycEoQ0EwcnyHAeoOHHQGp4iwsSc4sz0yHypxgVpcR5 r4MkBEASGaV5cL2wRPSKURzoFWHe4yBVPMAkBtf9CmgwE9DgshQ+kMEliQgpqQbGwy2V2Y9Z k++y+jzpMGpzrOdeqHPZI/JfZoNJ8nLR+ENSFS49Scc3rLKPb585zfHjs46bffx7YpZErNnx ePPcHPmYEMX23Qte2/GYnai8MOW9t+YRi1nzJ1tf5mRq+mFpk97gueyOjXKG9O/zV84vf6me x/XzyLObpW/3Cxm22fokZkXGTjmhxFKckWioxVxUnAgAo7O54B8DAAA= Cc: notmuch@notmuchmail.org X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Jan 2012 22:02:52 -0000 LGTM. Again, one minor nit below, but not enough to hold up this patch. Quoth Jani Nikula on Jan 12 at 11:40 pm: > Add new option --reply-to=(all|sender) to "notmuch reply" to select whether > to reply to all (sender and all recipients), or just sender. Reply to all > remains the default. > > Credits to Mark Walters for his similar earlier > work where I picked up the basic idea of handling reply-to-sender in > add_recipients_from_message(). All bugs are mine, though. > > Signed-off-by: Jani Nikula > > --- > > Settled on --reply-to=(all|sender) per Carl's earlier suggestion > (id:87pqn5cg4g.fsf@yoom.home.cworth.org) and David's approval on IRC. > --- > man/man1/notmuch-reply.1 | 28 ++++++++++++++++++++---- > notmuch-reply.c | 52 +++++++++++++++++++++++++++++++++++++-------- > 2 files changed, 65 insertions(+), 15 deletions(-) > > diff --git a/man/man1/notmuch-reply.1 b/man/man1/notmuch-reply.1 > index db464d8..5160ece 100644 > --- a/man/man1/notmuch-reply.1 > +++ b/man/man1/notmuch-reply.1 > @@ -14,11 +14,13 @@ Constructs a reply template for a set of messages. > To make replying to email easier, > .B notmuch reply > takes an existing set of messages and constructs a suitable mail > -template. The Reply-to header (if any, otherwise From:) is used for > -the To: address. Vales from the To: and Cc: headers are copied, but > -not including any of the current user's email addresses (as configured > -in primary_mail or other_email in the .notmuch\-config file) in the > -recipient list > +template. The Reply-to: header (if any, otherwise From:) is used for > +the To: address. Unless > +.BR \-\-reply-to=sender > +is specified, values from the To: and Cc: headers are copied, but not > +including any of the current user's email addresses (as configured in > +primary_mail or other_email in the .notmuch\-config file) in the > +recipient list. > > It also builds a suitable new subject, including Re: at the front (if > not already present), and adding the message IDs of the messages being > @@ -45,6 +47,22 @@ Includes subject and quoted message body. > Only produces In\-Reply\-To, References, To, Cc, and Bcc headers. > .RE > .RE > +.RS > +.TP 4 > +.BR \-\-reply\-to= ( all | sender ) > +.RS > +.TP 4 > +.BR all " (default)" > +Replies to all addresses. > +.TP 4 > +.BR sender > +Replies only to the sender. If replying to user's own message > +(Reply-to: or From: header is one of the user's configured email > +addresses), try To:, Cc:, and Bcc: headers in this order, and copy > +values from the first that contains something other than only the > +user's addresses. > +.RE > +.RE > > See \fBnotmuch-search-terms\fR(7) > for details of the supported syntax for . > diff --git a/notmuch-reply.c b/notmuch-reply.c > index 4fae66f..b4c81de 100644 > --- a/notmuch-reply.c > +++ b/notmuch-reply.c > @@ -289,7 +289,14 @@ reply_to_header_is_redundant (notmuch_message_t *message) > return 0; > } > > -/* Augments the recipients of reply from the headers of message. > +/* Augment the recipients of 'reply' from the "Reply-to:", "From:", "To:", > + * "Cc:", and "Bcc:" headers of 'message'. > + * > + * If 'reply_all' is true, use sender and all recipients, otherwise scan the > + * headers for the first that contains something other than the user's addresses > + * and add the recipients from this header (typically this would be > + * reply-to-sender, but also handles reply to user's own message in a sensible > + * way). Same comment about 80 column wrapping. > * > * If any of the user's addresses were found in these headers, the first > * of these returned, otherwise NULL is returned. > @@ -297,7 +304,8 @@ reply_to_header_is_redundant (notmuch_message_t *message) > static const char * > add_recipients_from_message (GMimeMessage *reply, > notmuch_config_t *config, > - notmuch_message_t *message) > + notmuch_message_t *message, > + notmuch_bool_t reply_all) > { > struct { > const char *header; > @@ -311,6 +319,7 @@ add_recipients_from_message (GMimeMessage *reply, > }; > const char *from_addr = NULL; > unsigned int i; > + unsigned int n = 0; > > /* Some mailing lists munge the Reply-To header despite it being A Bad > * Thing, see http://www.unicom.com/pw/reply-to-harmful.html > @@ -337,8 +346,23 @@ add_recipients_from_message (GMimeMessage *reply, > recipients = notmuch_message_get_header (message, > reply_to_map[i].fallback); > > - scan_address_string (recipients, config, reply, > - reply_to_map[i].recipient_type, &from_addr); > + n += scan_address_string (recipients, config, reply, > + reply_to_map[i].recipient_type, &from_addr); > + > + if (!reply_all && n) { > + /* Stop adding new recipients in reply-to-sender mode if we have > + * added some recipient(s) above. > + * > + * This also handles the case of user replying to his own message, > + * where reply-to/from is not a recipient. In this case there may be > + * more than one recipient even if not replying to all. > + */ > + reply = NULL; > + > + /* From address and some recipients are enough, bail out. */ > + if (from_addr) > + break; Nifty. > + } > } > > return from_addr; > @@ -482,7 +506,8 @@ static int > notmuch_reply_format_default(void *ctx, > notmuch_config_t *config, > notmuch_query_t *query, > - notmuch_show_params_t *params) > + notmuch_show_params_t *params, > + notmuch_bool_t reply_all) > { > GMimeMessage *reply; > notmuch_messages_t *messages; > @@ -511,7 +536,8 @@ notmuch_reply_format_default(void *ctx, > g_mime_message_set_subject (reply, subject); > } > > - from_addr = add_recipients_from_message (reply, config, message); > + from_addr = add_recipients_from_message (reply, config, message, > + reply_all); > > if (from_addr == NULL) > from_addr = guess_from_received_header (config, message); > @@ -560,7 +586,8 @@ static int > notmuch_reply_format_headers_only(void *ctx, > notmuch_config_t *config, > notmuch_query_t *query, > - unused (notmuch_show_params_t *params)) > + unused (notmuch_show_params_t *params), > + notmuch_bool_t reply_all) > { > GMimeMessage *reply; > notmuch_messages_t *messages; > @@ -600,7 +627,7 @@ notmuch_reply_format_headers_only(void *ctx, > g_mime_object_set_header (GMIME_OBJECT (reply), > "References", references); > > - (void)add_recipients_from_message (reply, config, message); > + (void)add_recipients_from_message (reply, config, message, reply_all); > > reply_headers = g_mime_object_to_string (GMIME_OBJECT (reply)); > printf ("%s", reply_headers); > @@ -627,9 +654,10 @@ notmuch_reply_command (void *ctx, int argc, char *argv[]) > notmuch_query_t *query; > char *query_string; > int opt_index, ret = 0; > - int (*reply_format_func)(void *ctx, notmuch_config_t *config, notmuch_query_t *query, notmuch_show_params_t *params); > + int (*reply_format_func)(void *ctx, notmuch_config_t *config, notmuch_query_t *query, notmuch_show_params_t *params, notmuch_bool_t reply_all); > notmuch_show_params_t params = { .part = -1 }; > int format = FORMAT_DEFAULT; > + int reply_all = TRUE; > notmuch_bool_t decrypt = FALSE; > > notmuch_opt_desc_t options[] = { > @@ -637,6 +665,10 @@ notmuch_reply_command (void *ctx, int argc, char *argv[]) > (notmuch_keyword_t []){ { "default", FORMAT_DEFAULT }, > { "headers-only", FORMAT_HEADERS_ONLY }, > { 0, 0 } } }, > + { NOTMUCH_OPT_KEYWORD, &reply_all, "reply-to", 'r', > + (notmuch_keyword_t []){ { "all", TRUE }, > + { "sender", FALSE }, > + { 0, 0 } } }, > { NOTMUCH_OPT_BOOLEAN, &decrypt, "decrypt", 'd', 0 }, > { 0, 0, 0, 0, 0 } > }; > @@ -690,7 +722,7 @@ notmuch_reply_command (void *ctx, int argc, char *argv[]) > return 1; > } > > - if (reply_format_func (ctx, config, query, ¶ms) != 0) > + if (reply_format_func (ctx, config, query, ¶ms, reply_all) != 0) > return 1; > > notmuch_query_destroy (query);