1 Return-Path: <jani@nikula.org>
\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 1626D431FB6
\r
6 for <notmuch@notmuchmail.org>; Thu, 8 Mar 2012 14:05:18 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id mJaMF39Vrbsn for <notmuch@notmuchmail.org>;
\r
16 Thu, 8 Mar 2012 14:05:16 -0800 (PST)
\r
17 Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com
\r
18 [209.85.217.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
19 (No client certificate requested)
\r
20 by olra.theworths.org (Postfix) with ESMTPS id 31A47431FAE
\r
21 for <notmuch@notmuchmail.org>; Thu, 8 Mar 2012 14:05:16 -0800 (PST)
\r
22 Received: by lbok6 with SMTP id k6so250584lbo.26
\r
23 for <notmuch@notmuchmail.org>; Thu, 08 Mar 2012 14:05:13 -0800 (PST)
\r
24 Received: by 10.112.24.196 with SMTP id w4mr2867102lbf.62.1331244313062;
\r
25 Thu, 08 Mar 2012 14:05:13 -0800 (PST)
\r
26 Received: from localhost (dsl-hkibrasgw4-fe50f800-253.dhcp.inet.fi.
\r
28 by mx.google.com with ESMTPS id s18sm3829853lbv.17.2012.03.08.14.05.10
\r
29 (version=SSLv3 cipher=OTHER); Thu, 08 Mar 2012 14:05:11 -0800 (PST)
\r
30 From: Jani Nikula <jani@nikula.org>
\r
31 To: Adam Wolfe Gordon <awg+notmuch@xvx.ca>, notmuch@notmuchmail.org
\r
32 Subject: Re: [PATCH v6 02/10] reply: Factor out reply creation
\r
33 In-Reply-To: <1329893199-21630-3-git-send-email-awg+notmuch@xvx.ca>
\r
34 References: <1329893199-21630-1-git-send-email-awg+notmuch@xvx.ca>
\r
35 <1329893199-21630-3-git-send-email-awg+notmuch@xvx.ca>
\r
36 User-Agent: Notmuch/0.11.1+295~g780f284 (http://notmuchmail.org) Emacs/23.3.1
\r
38 Date: Fri, 09 Mar 2012 00:05:08 +0200
\r
39 Message-ID: <87obs692az.fsf@nikula.org>
\r
41 Content-Type: text/plain; charset=us-ascii
\r
43 ALoCoQltTWWK+yu7GdphpS7gZN1dgW3cvKj4JuRybFZGTAvgDTZrtOMCxnjvtryM91+3Al4Chz2Z
\r
44 X-BeenThere: notmuch@notmuchmail.org
\r
45 X-Mailman-Version: 2.1.13
\r
47 List-Id: "Use and development of the notmuch mail system."
\r
48 <notmuch.notmuchmail.org>
\r
49 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
50 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
51 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
52 List-Post: <mailto:notmuch@notmuchmail.org>
\r
53 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
54 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
55 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
56 X-List-Received-Date: Thu, 08 Mar 2012 22:05:18 -0000
\r
58 On Tue, 21 Feb 2012 23:46:31 -0700, Adam Wolfe Gordon <awg+notmuch@xvx.ca> wrote:
\r
59 > Factor out the creation of a reply message based on an original
\r
60 > message so it can be shared by different reply formats.
\r
62 > notmuch-reply.c | 101 +++++++++++++++++++++++++++++++-----------------------
\r
63 > 1 files changed, 58 insertions(+), 43 deletions(-)
\r
65 > diff --git a/notmuch-reply.c b/notmuch-reply.c
\r
66 > index 6b244e6..8e56245 100644
\r
67 > --- a/notmuch-reply.c
\r
68 > +++ b/notmuch-reply.c
\r
69 > @@ -505,6 +505,61 @@ guess_from_received_header (notmuch_config_t *config, notmuch_message_t *message
\r
73 > +static GMimeMessage *
\r
74 > +create_reply_message(void *ctx,
\r
75 > + notmuch_config_t *config,
\r
76 > + notmuch_message_t *message,
\r
77 > + notmuch_bool_t reply_all)
\r
79 > + const char *subject, *from_addr = NULL;
\r
80 > + const char *in_reply_to, *orig_references, *references;
\r
82 > + /* The 1 means we want headers in a "pretty" order. */
\r
83 > + GMimeMessage *reply = g_mime_message_new (1);
\r
84 > + if (reply == NULL) {
\r
85 > + fprintf (stderr, "Out of memory\n");
\r
89 > + subject = notmuch_message_get_header (message, "subject");
\r
91 > + if (strncasecmp (subject, "Re:", 3))
\r
92 > + subject = talloc_asprintf (ctx, "Re: %s", subject);
\r
93 > + g_mime_message_set_subject (reply, subject);
\r
96 > + from_addr = add_recipients_from_message (reply, config,
\r
97 > + message, reply_all);
\r
99 > + if (from_addr == NULL)
\r
100 > + from_addr = guess_from_received_header (config, message);
\r
102 > + if (from_addr == NULL)
\r
103 > + from_addr = notmuch_config_get_user_primary_email (config);
\r
105 > + from_addr = talloc_asprintf (ctx, "%s <%s>",
\r
106 > + notmuch_config_get_user_name (config),
\r
108 > + g_mime_object_set_header (GMIME_OBJECT (reply),
\r
109 > + "From", from_addr);
\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
129 > notmuch_reply_format_default(void *ctx,
\r
130 > notmuch_config_t *config,
\r
131 > @@ -515,8 +570,6 @@ notmuch_reply_format_default(void *ctx,
\r
132 > GMimeMessage *reply;
\r
133 > notmuch_messages_t *messages;
\r
134 > notmuch_message_t *message;
\r
135 > - const char *subject, *from_addr = NULL;
\r
136 > - const char *in_reply_to, *orig_references, *references;
\r
137 > const notmuch_show_format_t *format = &format_reply;
\r
139 > for (messages = notmuch_query_search_messages (query);
\r
140 > @@ -525,48 +578,10 @@ notmuch_reply_format_default(void *ctx,
\r
142 > message = notmuch_messages_get (messages);
\r
144 > - /* The 1 means we want headers in a "pretty" order. */
\r
145 > - reply = g_mime_message_new (1);
\r
146 > - if (reply == NULL) {
\r
147 > - fprintf (stderr, "Out of memory\n");
\r
151 > - subject = notmuch_message_get_header (message, "subject");
\r
153 > - if (strncasecmp (subject, "Re:", 3))
\r
154 > - subject = talloc_asprintf (ctx, "Re: %s", subject);
\r
155 > - g_mime_message_set_subject (reply, subject);
\r
158 > - from_addr = add_recipients_from_message (reply, config, message,
\r
160 > + reply = create_reply_message (ctx, config, message, reply_all);
\r
162 > - if (from_addr == NULL)
\r
163 > - from_addr = guess_from_received_header (config, message);
\r
165 > - if (from_addr == NULL)
\r
166 > - from_addr = notmuch_config_get_user_primary_email (config);
\r
168 > - from_addr = talloc_asprintf (ctx, "%s <%s>",
\r
169 > - notmuch_config_get_user_name (config),
\r
171 > - g_mime_object_set_header (GMIME_OBJECT (reply),
\r
172 > - "From", from_addr);
\r
174 > - in_reply_to = talloc_asprintf (ctx, "<%s>",
\r
175 > - notmuch_message_get_message_id (message));
\r
177 > - g_mime_object_set_header (GMIME_OBJECT (reply),
\r
178 > - "In-Reply-To", in_reply_to);
\r
180 > - orig_references = notmuch_message_get_header (message, "references");
\r
181 > - references = talloc_asprintf (ctx, "%s%s%s",
\r
182 > - orig_references ? orig_references : "",
\r
183 > - orig_references ? " " : "",
\r
185 > - g_mime_object_set_header (GMIME_OBJECT (reply),
\r
186 > - "References", references);
\r
190 This changes the existing behaviour, which was to abort on errors. Also,
\r
191 "continue" here skips notmuch_message_destroy (message). With out of
\r
192 memory being the only possible error here, perhaps it's just easiest to
\r
193 abort instead of trying to go on?
\r
202 > show_reply_headers (reply);
\r
207 > _______________________________________________
\r
208 > notmuch mailing list
\r
209 > notmuch@notmuchmail.org
\r
210 > http://notmuchmail.org/mailman/listinfo/notmuch
\r