--- /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 3C108421186\r
+ for <notmuch@notmuchmail.org>; Thu, 5 Jan 2012 12:25:36 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"\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 tiULzZBrSQXN for <notmuch@notmuchmail.org>;\r
+ Thu, 5 Jan 2012 12:25:33 -0800 (PST)\r
+Received: from mail-ee0-f53.google.com (mail-ee0-f53.google.com\r
+ [74.125.83.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client\r
+ certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
+ 921F742117B for <notmuch@notmuchmail.org>; Thu, 5 Jan 2012 12:25:30 -0800\r
+ (PST)\r
+Received: by mail-ee0-f53.google.com with SMTP id d41so756745eek.26\r
+ for <notmuch@notmuchmail.org>; Thu, 05 Jan 2012 12:25:30 -0800 (PST)\r
+Received: by 10.213.32.76 with SMTP id b12mr716985ebd.6.1325795130164;\r
+ Thu, 05 Jan 2012 12:25:30 -0800 (PST)\r
+Received: from localhost (dsl-hkibrasgw4-fe5cdc00-23.dhcp.inet.fi.\r
+ [80.220.92.23])\r
+ by mx.google.com with ESMTPS id 13sm238065664eeu.1.2012.01.05.12.25.28\r
+ (version=SSLv3 cipher=OTHER); Thu, 05 Jan 2012 12:25:29 -0800 (PST)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org,\r
+ david@tethera.net\r
+Subject: [PATCH 3/4] cli: add support for replying just to the sender in\r
+ "notmuch reply"\r
+Date: Thu, 5 Jan 2012 22:25:14 +0200\r
+Message-Id:\r
+ <5fd10003b5c515c83cd298ea30f27b01f9233380.1325794371.git.jani@nikula.org>\r
+X-Mailer: git-send-email 1.7.5.4\r
+In-Reply-To: <cover.1325794371.git.jani@nikula.org>\r
+References: <cover.1325794371.git.jani@nikula.org>\r
+In-Reply-To: <cover.1325794371.git.jani@nikula.org>\r
+References: <cover.1325794371.git.jani@nikula.org>\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: Thu, 05 Jan 2012 20:25:37 -0000\r
+\r
+Add new option --no-reply-all to "notmuch reply" to reply just to the\r
+sender instead of sender and all recipients.\r
+\r
+Signed-off-by: Jani Nikula <jani@nikula.org>\r
+---\r
+ notmuch-reply.c | 52 ++++++++++++++++++++++++++++++++--------------------\r
+ 1 files changed, 32 insertions(+), 20 deletions(-)\r
+\r
+diff --git a/notmuch-reply.c b/notmuch-reply.c\r
+index 000f6da..57458ec 100644\r
+--- a/notmuch-reply.c\r
++++ b/notmuch-reply.c\r
+@@ -170,7 +170,7 @@ address_is_users (const char *address, notmuch_config_t *config)\r
+ \r
+ /* For each address in 'list' that is not configured as one of the\r
+ * user's addresses in 'config', add that address to 'message' as an\r
+- * address of 'type'.\r
++ * address of 'type', if 'add' is true.\r
+ *\r
+ * The first address encountered that *is* the user's address will be\r
+ * returned, (otherwise NULL is returned).\r
+@@ -179,7 +179,8 @@ static const char *\r
+ add_recipients_for_address_list (GMimeMessage *message,\r
+ notmuch_config_t *config,\r
+ GMimeRecipientType type,\r
+- InternetAddressList *list)\r
++ InternetAddressList *list,\r
++ notmuch_bool_t add)\r
+ {\r
+ InternetAddress *address;\r
+ int i;\r
+@@ -197,7 +198,7 @@ add_recipients_for_address_list (GMimeMessage *message,\r
+ continue;\r
+ \r
+ add_recipients_for_address_list (message, config,\r
+- type, group_list);\r
++ type, group_list, add);\r
+ } else {\r
+ InternetAddressMailbox *mailbox;\r
+ const char *name;\r
+@@ -211,7 +212,7 @@ add_recipients_for_address_list (GMimeMessage *message,\r
+ if (address_is_users (addr, config)) {\r
+ if (ret == NULL)\r
+ ret = addr;\r
+- } else {\r
++ } else if (add) {\r
+ g_mime_message_add_recipient (message, type, name, addr);\r
+ }\r
+ }\r
+@@ -222,7 +223,7 @@ add_recipients_for_address_list (GMimeMessage *message,\r
+ \r
+ /* For each address in 'recipients' that is not configured as one of\r
+ * the user's addresses in 'config', add that address to 'message' as\r
+- * an address of 'type'.\r
++ * an address of 'type', if 'add' is true.\r
+ *\r
+ * The first address encountered that *is* the user's address will be\r
+ * returned, (otherwise NULL is returned).\r
+@@ -231,7 +232,8 @@ static const char *\r
+ add_recipients_for_string (GMimeMessage *message,\r
+ notmuch_config_t *config,\r
+ GMimeRecipientType type,\r
+- const char *recipients)\r
++ const char *recipients,\r
++ notmuch_bool_t add)\r
+ {\r
+ InternetAddressList *list;\r
+ \r
+@@ -242,7 +244,7 @@ add_recipients_for_string (GMimeMessage *message,\r
+ if (list == NULL)\r
+ return NULL;\r
+ \r
+- return add_recipients_for_address_list (message, config, type, list);\r
++ return add_recipients_for_address_list (message, config, type, list, add);\r
+ }\r
+ \r
+ /* Does the address in the Reply-To header of 'message' already appear\r
+@@ -284,7 +286,9 @@ reply_to_header_is_redundant (notmuch_message_t *message)\r
+ return 0;\r
+ }\r
+ \r
+-/* Augments the recipients of reply from the headers of message.\r
++/* Augments the recipients of reply from the headers of message. If 'reply_all'\r
++ * is true, use sender and all recipients, otherwise use just the sender\r
++ * ("reply-to" or "from" headers).\r
+ *\r
+ * If any of the user's addresses were found in these headers, the first\r
+ * of these returned, otherwise NULL is returned.\r
+@@ -292,17 +296,19 @@ reply_to_header_is_redundant (notmuch_message_t *message)\r
+ static const char *\r
+ add_recipients_from_message (GMimeMessage *reply,\r
+ notmuch_config_t *config,\r
+- notmuch_message_t *message)\r
++ notmuch_message_t *message,\r
++ notmuch_bool_t reply_all)\r
+ {\r
+ struct {\r
+ const char *header;\r
+ const char *fallback;\r
+ GMimeRecipientType recipient_type;\r
++ notmuch_bool_t always; /* use entry when not reply_all */\r
+ } reply_to_map[] = {\r
+- { "reply-to", "from", GMIME_RECIPIENT_TYPE_TO },\r
+- { "to", NULL, GMIME_RECIPIENT_TYPE_TO },\r
+- { "cc", NULL, GMIME_RECIPIENT_TYPE_CC },\r
+- { "bcc", NULL, GMIME_RECIPIENT_TYPE_BCC }\r
++ { "reply-to", "from", GMIME_RECIPIENT_TYPE_TO, TRUE },\r
++ { "to", NULL, GMIME_RECIPIENT_TYPE_TO, FALSE },\r
++ { "cc", NULL, GMIME_RECIPIENT_TYPE_CC, FALSE },\r
++ { "bcc", NULL, GMIME_RECIPIENT_TYPE_BCC, FALSE }\r
+ };\r
+ const char *from_addr = NULL;\r
+ unsigned int i;\r
+@@ -334,7 +340,8 @@ add_recipients_from_message (GMimeMessage *reply,\r
+ \r
+ addr = add_recipients_for_string (reply, config,\r
+ reply_to_map[i].recipient_type,\r
+- recipients);\r
++ recipients,\r
++ reply_all || reply_to_map[i].always);\r
+ if (from_addr == NULL)\r
+ from_addr = addr;\r
+ }\r
+@@ -480,7 +487,8 @@ static int\r
+ notmuch_reply_format_default(void *ctx,\r
+ notmuch_config_t *config,\r
+ notmuch_query_t *query,\r
+- notmuch_show_params_t *params)\r
++ notmuch_show_params_t *params,\r
++ notmuch_bool_t reply_all)\r
+ {\r
+ GMimeMessage *reply;\r
+ notmuch_messages_t *messages;\r
+@@ -509,7 +517,8 @@ notmuch_reply_format_default(void *ctx,\r
+ g_mime_message_set_subject (reply, subject);\r
+ }\r
+ \r
+- from_addr = add_recipients_from_message (reply, config, message);\r
++ from_addr = add_recipients_from_message (reply, config, message,\r
++ reply_all);\r
+ \r
+ if (from_addr == NULL)\r
+ from_addr = guess_from_received_header (config, message);\r
+@@ -558,7 +567,8 @@ static int\r
+ 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
++ unused (notmuch_show_params_t *params),\r
++ notmuch_bool_t reply_all)\r
+ {\r
+ GMimeMessage *reply;\r
+ notmuch_messages_t *messages;\r
+@@ -598,7 +608,7 @@ notmuch_reply_format_headers_only(void *ctx,\r
+ g_mime_object_set_header (GMIME_OBJECT (reply),\r
+ "References", references);\r
+ \r
+- (void)add_recipients_from_message (reply, config, message);\r
++ (void)add_recipients_from_message (reply, config, message, reply_all);\r
+ \r
+ reply_headers = g_mime_object_to_string (GMIME_OBJECT (reply));\r
+ printf ("%s", reply_headers);\r
+@@ -625,10 +635,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);\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
+ notmuch_show_params_t params = { .part = -1 };\r
+ int format = FORMAT_DEFAULT;\r
+ notmuch_bool_t decrypt = FALSE;\r
++ notmuch_bool_t no_reply_all = FALSE;\r
+ \r
+ notmuch_opt_desc_t options[] = {\r
+ { NOTMUCH_OPT_KEYWORD, &format, "format", 'f',\r
+@@ -636,6 +647,7 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])\r
+ { "headers-only", FORMAT_HEADERS_ONLY },\r
+ { 0, 0 } } },\r
+ { NOTMUCH_OPT_BOOLEAN, &decrypt, "decrypt", 'd', 0 },\r
++ { NOTMUCH_OPT_BOOLEAN, &no_reply_all, "no-reply-all", 'r', 0 },\r
+ { 0, 0, 0, 0, 0 }\r
+ };\r
+ \r
+@@ -688,7 +700,7 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])\r
+ return 1;\r
+ }\r
+ \r
+- if (reply_format_func (ctx, config, query, ¶ms) != 0)\r
++ if (reply_format_func (ctx, config, query, ¶ms, !no_reply_all) != 0)\r
+ return 1;\r
+ \r
+ notmuch_query_destroy (query);\r
+-- \r
+1.7.5.4\r
+\r