1 Return-Path: <aneesh.kumar@linux.vnet.ibm.com>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 52D61431FBF
\r
6 for <notmuch@notmuchmail.org>; Sat, 5 Dec 2009 01:38:08 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
8 Received: from olra.theworths.org ([127.0.0.1])
\r
9 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
10 with ESMTP id vJrfds3Kd2tW for <notmuch@notmuchmail.org>;
\r
11 Sat, 5 Dec 2009 01:38:07 -0800 (PST)
\r
12 Received: from e23smtp08.au.ibm.com (e23smtp08.au.ibm.com [202.81.31.141])
\r
13 by olra.theworths.org (Postfix) with ESMTP id 56302431FBC
\r
14 for <notmuch@notmuchmail.org>; Sat, 5 Dec 2009 01:38:07 -0800 (PST)
\r
15 Received: from d23relay05.au.ibm.com (d23relay05.au.ibm.com [202.81.31.247])
\r
16 by e23smtp08.au.ibm.com (8.14.3/8.13.1) with ESMTP id nB5Kc5Ro028850
\r
17 for <notmuch@notmuchmail.org>; Sun, 6 Dec 2009 07:38:05 +1100
\r
18 Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139])
\r
19 by d23relay05.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id
\r
21 for <notmuch@notmuchmail.org>; Sat, 5 Dec 2009 20:34:21 +1100
\r
22 Received: from d23av04.au.ibm.com (loopback [127.0.0.1])
\r
23 by d23av04.au.ibm.com (8.14.3/8.13.1/NCO v10.0 AVout) with ESMTP id
\r
25 for <notmuch@notmuchmail.org>; Sat, 5 Dec 2009 20:38:02 +1100
\r
26 Received: from localhost.localdomain ([9.77.207.152])
\r
27 by d23av04.au.ibm.com (8.14.3/8.13.1/NCO v10.0 AVin) with ESMTP id
\r
28 nB59c0n6007312; Sat, 5 Dec 2009 20:38:00 +1100
\r
29 From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
\r
30 To: cworth@cworth.org, aneesh.kumar@linux.vnet.ibm.com
\r
31 Date: Sat, 5 Dec 2009 15:07:58 +0530
\r
33 <1260005878-18500-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com>
\r
34 X-Mailer: git-send-email 1.6.5.2.74.g610f9
\r
36 <1259830005-3439-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com>
\r
37 References: <1259830005-3439-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com>
\r
38 Cc: "Aneesh Kumar K.V" <aneesh.kumar@gmail.com>, notmuch@notmuchmail.org
\r
39 Subject: [notmuch] [PATCH -V2] notmuch-reply: Add support for replying only
\r
41 X-BeenThere: notmuch@notmuchmail.org
\r
42 X-Mailman-Version: 2.1.12
\r
44 List-Id: "Use and development of the notmuch mail system."
\r
45 <notmuch.notmuchmail.org>
\r
46 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
47 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
48 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
49 List-Post: <mailto:notmuch@notmuchmail.org>
\r
50 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
51 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
52 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
53 X-List-Received-Date: Sat, 05 Dec 2009 09:38:08 -0000
\r
55 From: Aneesh Kumar K.V <aneesh.kumar@gmail.com>
\r
57 This patch add --format=sender-only option.
\r
59 Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@gmail.com>
\r
61 notmuch-reply.c | 54 ++++++++++++++++++++++++++++++++++++++++--------------
\r
62 1 files changed, 40 insertions(+), 14 deletions(-)
\r
64 diff --git a/notmuch-reply.c b/notmuch-reply.c
\r
65 index 0cda72d..859b725 100644
\r
66 --- a/notmuch-reply.c
\r
67 +++ b/notmuch-reply.c
\r
69 #include "notmuch-client.h"
\r
70 #include "gmime-filter-reply.h"
\r
72 -static const struct {
\r
75 const char *fallback;
\r
76 GMimeRecipientType recipient_type;
\r
77 -} reply_to_map[] = {
\r
80 +static const struct reply_map reply_to_all_map[] = {
\r
81 { "reply-to", "from", GMIME_RECIPIENT_TYPE_TO },
\r
82 { "to", NULL, GMIME_RECIPIENT_TYPE_TO },
\r
83 { "cc", NULL, GMIME_RECIPIENT_TYPE_CC },
\r
84 - { "bcc", NULL, GMIME_RECIPIENT_TYPE_BCC }
\r
85 + { "bcc", NULL, GMIME_RECIPIENT_TYPE_BCC },
\r
89 +static const struct reply_map reply_to_sender_map[] = {
\r
90 + { "reply-to", "from", GMIME_RECIPIENT_TYPE_TO },
\r
95 @@ -200,7 +208,8 @@ add_recipients_for_string (GMimeMessage *message,
\r
99 -notmuch_reply_format_default(void *ctx, notmuch_config_t *config, notmuch_query_t *query)
\r
100 +__notmuch_reply(void *ctx, notmuch_config_t *config,
\r
101 + notmuch_query_t *query, const struct reply_map *map)
\r
103 GMimeMessage *reply;
\r
104 notmuch_messages_t *messages;
\r
105 @@ -229,17 +238,19 @@ notmuch_reply_format_default(void *ctx, notmuch_config_t *config, notmuch_query_
\r
106 subject = talloc_asprintf (ctx, "Re: %s", subject);
\r
107 g_mime_message_set_subject (reply, subject);
\r
109 - for (i = 0; i < ARRAY_SIZE (reply_to_map); i++) {
\r
110 + for (i = 0;; i++) {
\r
113 + if (!map[i].header)
\r
115 recipients = notmuch_message_get_header (message,
\r
116 - reply_to_map[i].header);
\r
117 - if ((recipients == NULL || recipients[0] == '\0') && reply_to_map[i].fallback)
\r
119 + if ((recipients == NULL || recipients[0] == '\0') && map[i].fallback)
\r
120 recipients = notmuch_message_get_header (message,
\r
121 - reply_to_map[i].fallback);
\r
122 + map[i].fallback);
\r
124 addr = add_recipients_for_string (reply, config,
\r
125 - reply_to_map[i].recipient_type,
\r
126 + map[i].recipient_type,
\r
128 if (from_addr == NULL)
\r
130 @@ -289,6 +300,12 @@ notmuch_reply_format_default(void *ctx, notmuch_config_t *config, notmuch_query_
\r
135 +notmuch_reply_format_default(void *ctx, notmuch_config_t *config, notmuch_query_t *query)
\r
137 + return __notmuch_reply(ctx, config, query, reply_to_all_map);
\r
140 /* This format is currently tuned for a git send-email --notmuch hook */
\r
142 notmuch_reply_format_headers_only(void *ctx, notmuch_config_t *config, notmuch_query_t *query)
\r
143 @@ -332,17 +349,18 @@ notmuch_reply_format_headers_only(void *ctx, notmuch_config_t *config, notmuch_q
\r
144 g_mime_object_set_header (GMIME_OBJECT (reply),
\r
145 "References", references);
\r
147 - for (i = 0; i < ARRAY_SIZE (reply_to_map); i++) {
\r
148 + for (i = 0; i < ARRAY_SIZE (reply_to_all_map); i++) {
\r
151 recipients = notmuch_message_get_header (message,
\r
152 - reply_to_map[i].header);
\r
153 - if ((recipients == NULL || recipients[0] == '\0') && reply_to_map[i].fallback)
\r
154 + reply_to_all_map[i].header);
\r
155 + if ((recipients == NULL || recipients[0] == '\0') &&
\r
156 + reply_to_all_map[i].fallback)
\r
157 recipients = notmuch_message_get_header (message,
\r
158 - reply_to_map[i].fallback);
\r
159 + reply_to_all_map[i].fallback);
\r
161 addr = add_recipients_for_string (reply, config,
\r
162 - reply_to_map[i].recipient_type,
\r
163 + reply_to_all_map[i].recipient_type,
\r
167 @@ -361,6 +379,12 @@ notmuch_reply_format_headers_only(void *ctx, notmuch_config_t *config, notmuch_q
\r
172 +notmuch_reply_format_sender_only(void *ctx, notmuch_config_t *config, notmuch_query_t *query)
\r
174 + return __notmuch_reply(ctx, config, query, reply_to_sender_map);
\r
178 notmuch_reply_command (void *ctx, int argc, char *argv[])
\r
180 @@ -384,6 +408,8 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
\r
181 reply_format_func = notmuch_reply_format_default;
\r
182 } else if (strcmp (opt, "headers-only") == 0) {
\r
183 reply_format_func = notmuch_reply_format_headers_only;
\r
184 + } else if (strcmp (opt, "sender-only") == 0) {
\r
185 + reply_format_func = notmuch_reply_format_sender_only;
\r
187 fprintf (stderr, "Invalid value for --format: %s\n", opt);
\r