[notmuch] [PATCH 1/2] notmuch-reply: Add support for replying only to sender
authorAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Thu, 3 Dec 2009 08:46:44 +0000 (14:16 +0530)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:35:48 +0000 (09:35 -0800)
00/64745d7575a95a28fecdaabb43c2c7e7c44622 [new file with mode: 0644]

diff --git a/00/64745d7575a95a28fecdaabb43c2c7e7c44622 b/00/64745d7575a95a28fecdaabb43c2c7e7c44622
new file mode 100644 (file)
index 0000000..2ec8fc9
--- /dev/null
@@ -0,0 +1,156 @@
+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 4C55F431FAE\r
+       for <notmuch@notmuchmail.org>; Thu,  3 Dec 2009 00:47:09 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\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 oTD5ScB80sJ0 for <notmuch@notmuchmail.org>;\r
+       Thu,  3 Dec 2009 00:47:06 -0800 (PST)\r
+Received: from e28smtp06.in.ibm.com (e28smtp06.in.ibm.com [122.248.162.6])\r
+       by olra.theworths.org (Postfix) with ESMTP id 5910D431FBC\r
+       for <notmuch@notmuchmail.org>; Thu,  3 Dec 2009 00:47:04 -0800 (PST)\r
+Received: from d28relay03.in.ibm.com (d28relay03.in.ibm.com [9.184.220.60])\r
+       by e28smtp06.in.ibm.com (8.14.3/8.13.1) with ESMTP id nB38l2SU032091\r
+       for <notmuch@notmuchmail.org>; Thu, 3 Dec 2009 14:17:02 +0530\r
+Received: from d28av01.in.ibm.com (d28av01.in.ibm.com [9.184.220.63])\r
+       by d28relay03.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id\r
+       nB38l2pO3469340\r
+       for <notmuch@notmuchmail.org>; Thu, 3 Dec 2009 14:17:02 +0530\r
+Received: from d28av01.in.ibm.com (loopback [127.0.0.1])\r
+       by d28av01.in.ibm.com (8.14.3/8.13.1/NCO v10.0 AVout) with ESMTP id\r
+       nB38l1ON022009\r
+       for <notmuch@notmuchmail.org>; Thu, 3 Dec 2009 14:17:02 +0530\r
+Received: from localhost.localdomain ([9.77.193.32])\r
+       by d28av01.in.ibm.com (8.14.3/8.13.1/NCO v10.0 AVin) with ESMTP id\r
+       nB38kmwA021218; Thu, 3 Dec 2009 14:16:51 +0530\r
+From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>\r
+To: cworth@cworth.org, aneesh.kumar@linux.vnet.ibm.com\r
+Date: Thu,  3 Dec 2009 14:16:44 +0530\r
+Message-Id: <1259830005-3439-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com>\r
+X-Mailer: git-send-email 1.6.5.2.74.g610f9\r
+Cc: "Aneesh Kumar K.V" <aneesh.kumar@gmail.com>, notmuch@notmuchmail.org\r
+Subject: [notmuch] [PATCH 1/2] notmuch-reply: Add support for replying only\r
+       to sender\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.12\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, 03 Dec 2009 08:47:09 -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 |   76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++\r
+ 1 files changed, 76 insertions(+), 0 deletions(-)\r
+\r
+diff --git a/notmuch-reply.c b/notmuch-reply.c\r
+index 9ca1236..9d96ef1 100644\r
+--- a/notmuch-reply.c\r
++++ b/notmuch-reply.c\r
+@@ -354,6 +354,80 @@ notmuch_reply_format_headers_only(void *ctx, notmuch_config_t *config, notmuch_q\r
+     }\r
+     return 0;\r
+ }\r
++static int\r
++notmuch_reply_format_sender_only(void *ctx, notmuch_config_t *config, notmuch_query_t *query)\r
++{\r
++    GMimeMessage *reply;\r
++    notmuch_messages_t *messages;\r
++    notmuch_message_t *message;\r
++    const char *subject, *recipient, *from_addr = NULL;\r
++    const char *in_reply_to, *orig_references, *references;\r
++    char *reply_headers;\r
++\r
++    for (messages = notmuch_query_search_messages (query);\r
++       notmuch_messages_has_more (messages);\r
++       notmuch_messages_advance (messages))\r
++    {\r
++      message = notmuch_messages_get (messages);\r
++\r
++      /* The 1 means we want headers in a "pretty" order. */\r
++      reply = g_mime_message_new (1);\r
++      if (reply == NULL) {\r
++          fprintf (stderr, "Out of memory\n");\r
++          return 1;\r
++      }\r
++\r
++      subject = notmuch_message_get_header (message, "subject");\r
++\r
++      if (strncasecmp (subject, "Re:", 3))\r
++          subject = talloc_asprintf (ctx, "Re: %s", subject);\r
++      g_mime_message_set_subject (reply, subject);\r
++\r
++      recipient = notmuch_message_get_header (message, "From");\r
++      g_mime_object_set_header (GMIME_OBJECT (reply),\r
++                                      "To", recipient);\r
++\r
++      from_addr = notmuch_config_get_user_primary_email (config);\r
++      from_addr = talloc_asprintf (ctx, "%s <%s>",\r
++                                   notmuch_config_get_user_name (config),\r
++                                   from_addr);\r
++      g_mime_object_set_header (GMIME_OBJECT (reply),\r
++                                "From", from_addr);\r
++\r
++      g_mime_object_set_header (GMIME_OBJECT (reply), "Bcc",\r
++                         notmuch_config_get_user_primary_email (config));\r
++\r
++      in_reply_to = talloc_asprintf (ctx, "<%s>",\r
++                           notmuch_message_get_message_id (message));\r
++\r
++      g_mime_object_set_header (GMIME_OBJECT (reply),\r
++                                "In-Reply-To", in_reply_to);\r
++\r
++      orig_references = notmuch_message_get_header (message, "references");\r
++      references = talloc_asprintf (ctx, "%s%s%s",\r
++                                    orig_references ? orig_references : "",\r
++                                    orig_references ? " " : "",\r
++                                    in_reply_to);\r
++      g_mime_object_set_header (GMIME_OBJECT (reply),\r
++                                "References", references);\r
++\r
++      reply_headers = g_mime_object_to_string (GMIME_OBJECT (reply));\r
++      printf ("%s", reply_headers);\r
++      free (reply_headers);\r
++\r
++      g_object_unref (G_OBJECT (reply));\r
++      reply = NULL;\r
++\r
++      printf ("On %s, %s wrote:\n",\r
++              notmuch_message_get_header (message, "date"),\r
++              notmuch_message_get_header (message, "from"));\r
++\r
++      show_message_body (notmuch_message_get_filename (message), reply_part);\r
++\r
++      notmuch_message_destroy (message);\r
++    }\r
++    return 0;\r
++}\r
\r
+ int\r
+ notmuch_reply_command (void *ctx, int argc, char *argv[])\r
+@@ -378,6 +452,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.5.2.74.g610f9\r
+\r