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 4C55F431FAE
\r
6 for <notmuch@notmuchmail.org>; Thu, 3 Dec 2009 00:47:09 -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 oTD5ScB80sJ0 for <notmuch@notmuchmail.org>;
\r
11 Thu, 3 Dec 2009 00:47:06 -0800 (PST)
\r
12 Received: from e28smtp06.in.ibm.com (e28smtp06.in.ibm.com [122.248.162.6])
\r
13 by olra.theworths.org (Postfix) with ESMTP id 5910D431FBC
\r
14 for <notmuch@notmuchmail.org>; Thu, 3 Dec 2009 00:47:04 -0800 (PST)
\r
15 Received: from d28relay03.in.ibm.com (d28relay03.in.ibm.com [9.184.220.60])
\r
16 by e28smtp06.in.ibm.com (8.14.3/8.13.1) with ESMTP id nB38l2SU032091
\r
17 for <notmuch@notmuchmail.org>; Thu, 3 Dec 2009 14:17:02 +0530
\r
18 Received: from d28av01.in.ibm.com (d28av01.in.ibm.com [9.184.220.63])
\r
19 by d28relay03.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id
\r
21 for <notmuch@notmuchmail.org>; Thu, 3 Dec 2009 14:17:02 +0530
\r
22 Received: from d28av01.in.ibm.com (loopback [127.0.0.1])
\r
23 by d28av01.in.ibm.com (8.14.3/8.13.1/NCO v10.0 AVout) with ESMTP id
\r
25 for <notmuch@notmuchmail.org>; Thu, 3 Dec 2009 14:17:02 +0530
\r
26 Received: from localhost.localdomain ([9.77.193.32])
\r
27 by d28av01.in.ibm.com (8.14.3/8.13.1/NCO v10.0 AVin) with ESMTP id
\r
28 nB38kmwA021218; Thu, 3 Dec 2009 14:16:51 +0530
\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: Thu, 3 Dec 2009 14:16:44 +0530
\r
32 Message-Id: <1259830005-3439-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com>
\r
33 X-Mailer: git-send-email 1.6.5.2.74.g610f9
\r
34 Cc: "Aneesh Kumar K.V" <aneesh.kumar@gmail.com>, notmuch@notmuchmail.org
\r
35 Subject: [notmuch] [PATCH 1/2] notmuch-reply: Add support for replying only
\r
37 X-BeenThere: notmuch@notmuchmail.org
\r
38 X-Mailman-Version: 2.1.12
\r
40 List-Id: "Use and development of the notmuch mail system."
\r
41 <notmuch.notmuchmail.org>
\r
42 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
43 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
44 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
45 List-Post: <mailto:notmuch@notmuchmail.org>
\r
46 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
47 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
48 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
49 X-List-Received-Date: Thu, 03 Dec 2009 08:47:09 -0000
\r
51 From: Aneesh Kumar K.V <aneesh.kumar@gmail.com>
\r
53 This patch add --format=sender-only option.
\r
55 Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@gmail.com>
\r
57 notmuch-reply.c | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
\r
58 1 files changed, 76 insertions(+), 0 deletions(-)
\r
60 diff --git a/notmuch-reply.c b/notmuch-reply.c
\r
61 index 9ca1236..9d96ef1 100644
\r
62 --- a/notmuch-reply.c
\r
63 +++ b/notmuch-reply.c
\r
64 @@ -354,6 +354,80 @@ notmuch_reply_format_headers_only(void *ctx, notmuch_config_t *config, notmuch_q
\r
69 +notmuch_reply_format_sender_only(void *ctx, notmuch_config_t *config, notmuch_query_t *query)
\r
71 + GMimeMessage *reply;
\r
72 + notmuch_messages_t *messages;
\r
73 + notmuch_message_t *message;
\r
74 + const char *subject, *recipient, *from_addr = NULL;
\r
75 + const char *in_reply_to, *orig_references, *references;
\r
76 + char *reply_headers;
\r
78 + for (messages = notmuch_query_search_messages (query);
\r
79 + notmuch_messages_has_more (messages);
\r
80 + notmuch_messages_advance (messages))
\r
82 + message = notmuch_messages_get (messages);
\r
84 + /* The 1 means we want headers in a "pretty" order. */
\r
85 + reply = g_mime_message_new (1);
\r
86 + if (reply == NULL) {
\r
87 + fprintf (stderr, "Out of memory\n");
\r
91 + subject = notmuch_message_get_header (message, "subject");
\r
93 + if (strncasecmp (subject, "Re:", 3))
\r
94 + subject = talloc_asprintf (ctx, "Re: %s", subject);
\r
95 + g_mime_message_set_subject (reply, subject);
\r
97 + recipient = notmuch_message_get_header (message, "From");
\r
98 + g_mime_object_set_header (GMIME_OBJECT (reply),
\r
101 + from_addr = notmuch_config_get_user_primary_email (config);
\r
102 + from_addr = talloc_asprintf (ctx, "%s <%s>",
\r
103 + notmuch_config_get_user_name (config),
\r
105 + g_mime_object_set_header (GMIME_OBJECT (reply),
\r
106 + "From", from_addr);
\r
108 + g_mime_object_set_header (GMIME_OBJECT (reply), "Bcc",
\r
109 + notmuch_config_get_user_primary_email (config));
\r
111 + in_reply_to = talloc_asprintf (ctx, "<%s>",
\r
112 + notmuch_message_get_message_id (message));
\r
114 + g_mime_object_set_header (GMIME_OBJECT (reply),
\r
115 + "In-Reply-To", in_reply_to);
\r
117 + orig_references = notmuch_message_get_header (message, "references");
\r
118 + references = talloc_asprintf (ctx, "%s%s%s",
\r
119 + orig_references ? orig_references : "",
\r
120 + orig_references ? " " : "",
\r
122 + g_mime_object_set_header (GMIME_OBJECT (reply),
\r
123 + "References", references);
\r
125 + reply_headers = g_mime_object_to_string (GMIME_OBJECT (reply));
\r
126 + printf ("%s", reply_headers);
\r
127 + free (reply_headers);
\r
129 + g_object_unref (G_OBJECT (reply));
\r
132 + printf ("On %s, %s wrote:\n",
\r
133 + notmuch_message_get_header (message, "date"),
\r
134 + notmuch_message_get_header (message, "from"));
\r
136 + show_message_body (notmuch_message_get_filename (message), reply_part);
\r
138 + notmuch_message_destroy (message);
\r
144 notmuch_reply_command (void *ctx, int argc, char *argv[])
\r
145 @@ -378,6 +452,8 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
\r
146 reply_format_func = notmuch_reply_format_default;
\r
147 } else if (strcmp (opt, "headers-only") == 0) {
\r
148 reply_format_func = notmuch_reply_format_headers_only;
\r
149 + } else if (strcmp (opt, "sender-only") == 0) {
\r
150 + reply_format_func = notmuch_reply_format_sender_only;
\r
152 fprintf (stderr, "Invalid value for --format: %s\n", opt);
\r