--- /dev/null
+Return-Path: <jani@nikula.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 861A6431FBC\r
+ for <notmuch@notmuchmail.org>; Sat, 4 Feb 2012 10:00:06 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id gFmbbhrFt0GP for <notmuch@notmuchmail.org>;\r
+ Sat, 4 Feb 2012 10:00:05 -0800 (PST)\r
+Received: from mail-lpp01m010-f53.google.com (mail-lpp01m010-f53.google.com\r
+ [209.85.215.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 40EB2431FAF\r
+ for <notmuch@notmuchmail.org>; Sat, 4 Feb 2012 10:00:05 -0800 (PST)\r
+Received: by lahd3 with SMTP id d3so2606224lah.26\r
+ for <notmuch@notmuchmail.org>; Sat, 04 Feb 2012 10:00:03 -0800 (PST)\r
+Received: by 10.152.132.133 with SMTP id ou5mr6097211lab.46.1328378403520;\r
+ Sat, 04 Feb 2012 10:00:03 -0800 (PST)\r
+Received: from localhost (dsl-hkibrasgw4-fe50f800-253.dhcp.inet.fi.\r
+ [84.248.80.253])\r
+ by mx.google.com with ESMTPS id fl2sm8108488lbb.4.2012.02.04.10.00.00\r
+ (version=SSLv3 cipher=OTHER); Sat, 04 Feb 2012 10:00:02 -0800 (PST)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: Mark Walters <markwalters1009@gmail.com>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH 1/2] cli: add --from option to reply to restrict guessing\r
+ of the From: header.\r
+In-Reply-To: <1328375350-10352-2-git-send-email-markwalters1009@gmail.com>\r
+References: <1328375350-10352-1-git-send-email-markwalters1009@gmail.com>\r
+ <1328375350-10352-2-git-send-email-markwalters1009@gmail.com>\r
+User-Agent: Notmuch/0.11+139~g4340989 (http://notmuchmail.org) Emacs/23.3.1\r
+ (i686-pc-linux-gnu)\r
+Date: Sat, 04 Feb 2012 19:59:58 +0200\r
+Message-ID: <87lioio4wx.fsf@nikula.org>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sat, 04 Feb 2012 18:00:06 -0000\r
+\r
+On Sat, 4 Feb 2012 17:09:09 +0000, Mark Walters <markwalters1009@gmail.com> wrote:\r
+> Add an option --from= to notmuch-reply.c to restrict guessing of the\r
+> From: header. The existing logic looks as the main headers, then at\r
+> the delivery headers, and finally defaults to the config file address.\r
+> \r
+> This patch allows the user to restrict which of these guesses are\r
+> made. Currently the supported values are:\r
+> default|fallback-all current behaviour\r
+> fallback-received fallback to delivery headers but not config file\r
+> fallback-none only look at from/reply-to/to/cc/ headers\r
+> none From: header is always left empty\r
+\r
+As discussed on IRC, --from=primary is a natural extension to always use\r
+the primary address from config, but that can be a later patch.\r
+\r
+> \r
+> If the code does not find an allowed address it outputs an empty From:\r
+> line and the caller can decide how to respond.\r
+> ---\r
+> notmuch-reply.c | 39 ++++++++++++++++++++++++++++++---------\r
+> 1 files changed, 30 insertions(+), 9 deletions(-)\r
+> \r
+> diff --git a/notmuch-reply.c b/notmuch-reply.c\r
+> index f55b1d2..f660749 100644\r
+> --- a/notmuch-reply.c\r
+> +++ b/notmuch-reply.c\r
+> @@ -24,6 +24,13 @@\r
+> #include "gmime-filter-reply.h"\r
+> #include "gmime-filter-headers.h"\r
+> \r
+\r
+I think it would be good to have a comment here reminding later\r
+developers that the order matters in this enum.\r
+\r
+> +enum {\r
+> + FROM_FALLBACK_ALL,\r
+> + FROM_FALLBACK_RECEIVED,\r
+> + FROM_FALLBACK_NONE,\r
+> + FROM_NONE\r
+> +};\r
+> +\r
+> static void\r
+> reply_headers_message_part (GMimeMessage *message);\r
+> \r
+> @@ -510,7 +517,8 @@ notmuch_reply_format_default(void *ctx,\r
+> notmuch_config_t *config,\r
+> notmuch_query_t *query,\r
+> notmuch_show_params_t *params,\r
+> - notmuch_bool_t reply_all)\r
+> + notmuch_bool_t reply_all,\r
+> + int from_guess)\r
+\r
+Hrmh, I'd like this to sound more deterministic than\r
+"guessing". from_select? from_use? from?\r
+\r
+> {\r
+> GMimeMessage *reply;\r
+> notmuch_messages_t *messages;\r
+> @@ -542,15 +550,19 @@ notmuch_reply_format_default(void *ctx,\r
+> from_addr = add_recipients_from_message (reply, config, message,\r
+> reply_all);\r
+> \r
+> - if (from_addr == NULL)\r
+> + if ((from_addr == NULL) && (from_guess <= FROM_FALLBACK_RECEIVED))\r
+\r
+Please drop the extra braces here and below.\r
+\r
+> from_addr = guess_from_received_header (config, message);\r
+> \r
+> - if (from_addr == NULL)\r
+> + if ((from_addr == NULL) && (from_guess <= FROM_FALLBACK_ALL ))\r
+> from_addr = notmuch_config_get_user_primary_email (config);\r
+> \r
+> - from_addr = talloc_asprintf (ctx, "%s <%s>",\r
+> - notmuch_config_get_user_name (config),\r
+> - from_addr);\r
+> + if ((from_addr != NULL) || (from_guess = FROM_NONE)) {\r
+\r
+Should that be (from_addr != NULL && from_guess != FROM_NONE)?\r
+Definitely the assignment is an error!\r
+\r
+> + from_addr = talloc_asprintf (ctx, "%s <%s>",\r
+> + notmuch_config_get_user_name (config),\r
+> + from_addr);\r
+> + } else {\r
+> + from_addr = talloc_strdup (ctx, "");\r
+> + }\r
+> g_mime_object_set_header (GMIME_OBJECT (reply),\r
+> "From", from_addr);\r
+> \r
+> @@ -590,7 +602,8 @@ notmuch_reply_format_headers_only(void *ctx,\r
+> notmuch_config_t *config,\r
+> notmuch_query_t *query,\r
+> unused (notmuch_show_params_t *params),\r
+> - notmuch_bool_t reply_all)\r
+> + notmuch_bool_t reply_all,\r
+> + unused (int from_guess))\r
+> {\r
+> GMimeMessage *reply;\r
+> notmuch_messages_t *messages;\r
+> @@ -657,10 +670,11 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])\r
+> notmuch_query_t *query;\r
+> char *query_string;\r
+> int opt_index, ret = 0;\r
+> - 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
+> + int (*reply_format_func)(void *ctx, notmuch_config_t *config, notmuch_query_t *query, notmuch_show_params_t *params, notmuch_bool_t reply_all, int from_guess);\r
+> notmuch_show_params_t params = { .part = -1 };\r
+> int format = FORMAT_DEFAULT;\r
+> int reply_all = TRUE;\r
+> + int from_guess = FROM_FALLBACK_ALL;\r
+> notmuch_bool_t decrypt = FALSE;\r
+> \r
+> notmuch_opt_desc_t options[] = {\r
+> @@ -672,6 +686,13 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])\r
+> (notmuch_keyword_t []){ { "all", TRUE },\r
+> { "sender", FALSE },\r
+> { 0, 0 } } },\r
+> + { NOTMUCH_OPT_KEYWORD, &from_guess, "from", 'F',\r
+> + (notmuch_keyword_t []){ { "default", FROM_FALLBACK_ALL },\r
+> + { "fallback-all", FROM_FALLBACK_ALL },\r
+> + { "fallback-received", FROM_FALLBACK_RECEIVED },\r
+> + { "fallback-none", FROM_FALLBACK_NONE },\r
+> + { "none", FROM_NONE },\r
+> + { 0, 0 } } },\r
+> { NOTMUCH_OPT_BOOLEAN, &decrypt, "decrypt", 'd', 0 },\r
+> { 0, 0, 0, 0, 0 }\r
+> };\r
+> @@ -732,7 +753,7 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])\r
+> return 1;\r
+> }\r
+> \r
+> - if (reply_format_func (ctx, config, query, ¶ms, reply_all) != 0)\r
+> + if (reply_format_func (ctx, config, query, ¶ms, reply_all, from_guess) != 0)\r
+> return 1;\r
+> \r
+> notmuch_query_destroy (query);\r
+> -- \r
+> 1.7.2.3\r
+> \r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r