--- /dev/null
+Return-Path: <aneesh.kumar@linux.vnet.ibm.com>\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 83637431FAE\r
+ for <notmuch@notmuchmail.org>; Sat, 23 Jan 2010 02:05:30 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -3.703\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-3.703 tagged_above=-999 required=5 tests=[AWL=0.296,\r
+ BAYES_50=0.001, RCVD_IN_DNSWL_MED=-4] autolearn=unavailable\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 MefNPXUBrxJG for <notmuch@notmuchmail.org>;\r
+ Sat, 23 Jan 2010 02:05:30 -0800 (PST)\r
+Received: from e23smtp07.au.ibm.com (e23smtp07.au.ibm.com [202.81.31.140])\r
+ by olra.theworths.org (Postfix) with ESMTP id EAEF4431FBC\r
+ for <notmuch@notmuchmail.org>; Sat, 23 Jan 2010 02:05:29 -0800 (PST)\r
+Received: from d23relay04.au.ibm.com (d23relay04.au.ibm.com [202.81.31.246])\r
+ by e23smtp07.au.ibm.com (8.14.3/8.13.1) with ESMTP id o0NA5R8n000816\r
+ for <notmuch@notmuchmail.org>; Sat, 23 Jan 2010 21:05:27 +1100\r
+Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139])\r
+ by d23relay04.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id\r
+ o0NA0f5C1314904\r
+ for <notmuch@notmuchmail.org>; Sat, 23 Jan 2010 21:00:43 +1100\r
+Received: from d23av04.au.ibm.com (loopback [127.0.0.1])\r
+ by d23av04.au.ibm.com (8.14.3/8.13.1/NCO v10.0 AVout) with ESMTP id\r
+ o0NA5O5E007372\r
+ for <notmuch@notmuchmail.org>; Sat, 23 Jan 2010 21:05:24 +1100\r
+Received: from localhost.localdomain ([9.77.206.84])\r
+ by d23av04.au.ibm.com (8.14.3/8.13.1/NCO v10.0 AVin) with ESMTP id\r
+ o0NA5J0f007294; Sat, 23 Jan 2010 21:05:20 +1100\r
+From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>\r
+To: cworth@cworth.org\r
+Date: Sat, 23 Jan 2010 15:35:04 +0530\r
+Message-Id: <1264241105-5983-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com>\r
+X-Mailer: git-send-email 1.6.6.1.394.gdedc0\r
+Cc: "Aneesh Kumar K.V" <aneesh.kumar@gmail.com>, notmuch@notmuchmail.org\r
+Subject: [notmuch] [PATCH -V2 1/2] notmuch-reply: Add support for replying\r
+ only to sender\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, 23 Jan 2010 10:05:30 -0000\r
+\r
+From: Aneesh Kumar K.V <aneesh.kumar@gmail.com>\r
+\r
+This patch add --format=sender-only option.\r
+\r
+Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@gmail.com>\r
+---\r
+ notmuch-reply.c | 54 ++++++++++++++++++++++++++++++++++++++++--------------\r
+ 1 files changed, 40 insertions(+), 14 deletions(-)\r
+\r
+diff --git a/notmuch-reply.c b/notmuch-reply.c\r
+index 0cda72d..859b725 100644\r
+--- a/notmuch-reply.c\r
++++ b/notmuch-reply.c\r
+@@ -23,15 +23,23 @@\r
+ #include "notmuch-client.h"\r
+ #include "gmime-filter-reply.h"\r
+ \r
+-static const struct {\r
++struct reply_map {\r
+ const char *header;\r
+ const char *fallback;\r
+ GMimeRecipientType recipient_type;\r
+-} reply_to_map[] = {\r
++};\r
++\r
++static const struct reply_map reply_to_all_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
++ { "bcc", NULL, GMIME_RECIPIENT_TYPE_BCC },\r
++ { NULL, NULL, 0}\r
++};\r
++\r
++static const struct reply_map reply_to_sender_map[] = {\r
++ { "reply-to", "from", GMIME_RECIPIENT_TYPE_TO },\r
++ { NULL, NULL, 0}\r
+ };\r
+ \r
+ static void\r
+@@ -200,7 +208,8 @@ add_recipients_for_string (GMimeMessage *message,\r
+ }\r
+ \r
+ static int\r
+-notmuch_reply_format_default(void *ctx, notmuch_config_t *config, notmuch_query_t *query)\r
++__notmuch_reply(void *ctx, notmuch_config_t *config,\r
++ notmuch_query_t *query, const struct reply_map *map)\r
+ {\r
+ GMimeMessage *reply;\r
+ notmuch_messages_t *messages;\r
+@@ -229,17 +238,19 @@ notmuch_reply_format_default(void *ctx, notmuch_config_t *config, notmuch_query_\r
+ subject = talloc_asprintf (ctx, "Re: %s", subject);\r
+ g_mime_message_set_subject (reply, subject);\r
+ \r
+- for (i = 0; i < ARRAY_SIZE (reply_to_map); i++) {\r
++ for (i = 0;; i++) {\r
+ const char *addr;\r
+ \r
++ if (!map[i].header)\r
++ break;\r
+ recipients = notmuch_message_get_header (message,\r
+- reply_to_map[i].header);\r
+- if ((recipients == NULL || recipients[0] == '\0') && reply_to_map[i].fallback)\r
++ map[i].header);\r
++ if ((recipients == NULL || recipients[0] == '\0') && map[i].fallback)\r
+ recipients = notmuch_message_get_header (message,\r
+- reply_to_map[i].fallback);\r
++ map[i].fallback);\r
+ \r
+ addr = add_recipients_for_string (reply, config,\r
+- reply_to_map[i].recipient_type,\r
++ map[i].recipient_type,\r
+ recipients);\r
+ if (from_addr == NULL)\r
+ from_addr = addr;\r
+@@ -289,6 +300,12 @@ notmuch_reply_format_default(void *ctx, notmuch_config_t *config, notmuch_query_\r
+ return 0;\r
+ }\r
+ \r
++static int\r
++notmuch_reply_format_default(void *ctx, notmuch_config_t *config, notmuch_query_t *query)\r
++{\r
++ return __notmuch_reply(ctx, config, query, reply_to_all_map);\r
++}\r
++\r
+ /* This format is currently tuned for a git send-email --notmuch hook */\r
+ static int\r
+ notmuch_reply_format_headers_only(void *ctx, notmuch_config_t *config, notmuch_query_t *query)\r
+@@ -332,17 +349,18 @@ notmuch_reply_format_headers_only(void *ctx, notmuch_config_t *config, notmuch_q\r
+ g_mime_object_set_header (GMIME_OBJECT (reply),\r
+ "References", references);\r
+ \r
+- for (i = 0; i < ARRAY_SIZE (reply_to_map); i++) {\r
++ for (i = 0; i < ARRAY_SIZE (reply_to_all_map); i++) {\r
+ const char *addr;\r
+ \r
+ recipients = notmuch_message_get_header (message,\r
+- reply_to_map[i].header);\r
+- if ((recipients == NULL || recipients[0] == '\0') && reply_to_map[i].fallback)\r
++ reply_to_all_map[i].header);\r
++ if ((recipients == NULL || recipients[0] == '\0') &&\r
++ reply_to_all_map[i].fallback)\r
+ recipients = notmuch_message_get_header (message,\r
+- reply_to_map[i].fallback);\r
++ reply_to_all_map[i].fallback);\r
+ \r
+ addr = add_recipients_for_string (reply, config,\r
+- reply_to_map[i].recipient_type,\r
++ reply_to_all_map[i].recipient_type,\r
+ recipients);\r
+ }\r
+ \r
+@@ -361,6 +379,12 @@ notmuch_reply_format_headers_only(void *ctx, notmuch_config_t *config, notmuch_q\r
+ return 0;\r
+ }\r
+ \r
++static int\r
++notmuch_reply_format_sender_only(void *ctx, notmuch_config_t *config, notmuch_query_t *query)\r
++{\r
++ return __notmuch_reply(ctx, config, query, reply_to_sender_map);\r
++}\r
++\r
+ int\r
+ notmuch_reply_command (void *ctx, int argc, char *argv[])\r
+ {\r
+@@ -384,6 +408,8 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])\r
+ reply_format_func = notmuch_reply_format_default;\r
+ } else if (strcmp (opt, "headers-only") == 0) {\r
+ reply_format_func = notmuch_reply_format_headers_only;\r
++ } else if (strcmp (opt, "sender-only") == 0) {\r
++ reply_format_func = notmuch_reply_format_sender_only;\r
+ } else {\r
+ fprintf (stderr, "Invalid value for --format: %s\n", opt);\r
+ return 1;\r
+-- \r
+1.6.6.1.394.gdedc0\r
+\r