1 Return-Path: <amdragon@mit.edu>
\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 15C30431FB6
\r
6 for <notmuch@notmuchmail.org>; Thu, 6 Dec 2012 07:48:10 -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 r5nsHExkmKZr for <notmuch@notmuchmail.org>;
\r
16 Thu, 6 Dec 2012 07:48:09 -0800 (PST)
\r
17 Received: from dmz-mailsec-scanner-7.mit.edu (DMZ-MAILSEC-SCANNER-7.MIT.EDU
\r
19 by olra.theworths.org (Postfix) with ESMTP id D5136431FAE
\r
20 for <notmuch@notmuchmail.org>; Thu, 6 Dec 2012 07:48:08 -0800 (PST)
\r
21 X-AuditID: 12074424-b7fe06d0000008f0-56-50c0be38647c
\r
22 Received: from mailhub-auth-1.mit.edu ( [18.9.21.35])
\r
23 by dmz-mailsec-scanner-7.mit.edu (Symantec Messaging Gateway) with SMTP
\r
24 id 6C.21.02288.83EB0C05; Thu, 6 Dec 2012 10:48:08 -0500 (EST)
\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])
\r
26 by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id qB6Fm74C023384;
\r
27 Thu, 6 Dec 2012 10:48:08 -0500
\r
28 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])
\r
29 (authenticated bits=0)
\r
30 (User authenticated as amdragon@ATHENA.MIT.EDU)
\r
31 by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id qB6Fm5C8024625
\r
32 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT);
\r
33 Thu, 6 Dec 2012 10:48:06 -0500 (EST)
\r
34 Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80)
\r
35 (envelope-from <amdragon@mit.edu>)
\r
36 id 1TgdgD-00061c-8R; Thu, 06 Dec 2012 10:48:05 -0500
\r
37 From: Austin Clements <aclements@csail.mit.edu>
\r
38 To: Peter Feigl <craven@gmx.net>, notmuch@notmuchmail.org
\r
39 Subject: Re: [PATCH v4 2/5] Rename the -json printer functions in
\r
40 notmuch-reply and notmuch-show to generic -sprinter functions.
\r
42 <785c9f89c35c861fbbe3ead3fe7289b65d31e216.1354794428.git.craven@gmx.net>
\r
43 References: <cover.1354794428.git.craven@gmx.net>
\r
44 <785c9f89c35c861fbbe3ead3fe7289b65d31e216.1354794428.git.craven@gmx.net>
\r
45 User-Agent: Notmuch/0.14+159~g6895fee (http://notmuchmail.org) Emacs/23.4.1
\r
47 Date: Thu, 06 Dec 2012 10:48:05 -0500
\r
48 Message-ID: <87ehj3p4ga.fsf@awakening.csail.mit.edu>
\r
50 Content-Type: text/plain; charset=us-ascii
\r
51 X-Brightmail-Tracker:
\r
52 H4sIAAAAAAAAA+NgFnrAIsWRmVeSWpSXmKPExsUixCmqrGux70CAwbUtfBZ7G9oZLa7fnMns
\r
53 wOSxeNN+No9nq24xBzBFcdmkpOZklqUW6dslcGXc+/eSteBvaMWk26eZGhinOXcxcnJICJhI
\r
54 /Fkygw3CFpO4cG89kM3FISSwj1Hi85krjCAJIYH1jBJTHnJAJC4wScx90csE4SxhlHi+4Coz
\r
55 SBWbgL7EirWTWEFsEQFLialfLoGNEhZoYJSYd/8BWIJTIFRi+b7prBBjqyRmrHwDtIKDQ1Qg
\r
56 XmL2OR+QMIuAqsTWBx/YQMK8QOd9O5UHEuYVEJQ4OfMJC4jNLKAlcePfS6YJjAKzkKRmIUkt
\r
57 YGRaxSibklulm5uYmVOcmqxbnJyYl5dapGuul5tZopeaUrqJERSQ7C4qOxibDykdYhTgYFTi
\r
58 4X1QsT9AiDWxrLgy9xCjJAeTkiivzJ4DAUJ8SfkplRmJxRnxRaU5qcWHGCU4mJVEeGM6gHK8
\r
59 KYmVValF+TApaQ4WJXHe6yk3/YUE0hNLUrNTUwtSi2CyMhwcShK84nuBGgWLUtNTK9Iyc0oQ
\r
60 0kwcnCDDeYCGM4LU8BYXJOYWZ6ZD5E8xKkqJ8+4BuUgAJJFRmgfXC0sYrxjFgV4R5r0AUsUD
\r
61 TDZw3a+ABjMBDY5i3w8yuCQRISXVwNi+buPnv5v/cD4T0TvBXjq/Kp/Df4m33No179YnfMlh
\r
62 /N+92Oj5vwulD++WySziPWiaLrejIOarV822ZOYjhm+D5q/aJZmu3PPucswqtxqh2Xn39z7q
\r
63 VAmKfbLyYUrdwh+GOt9ytd4k7mF5qrK6fzFf6uVVb5K2PXVa1Phv1fu1oh+K3HWzbqUrsRRn
\r
64 JBpqMRcVJwIA+UkhNfMCAAA=
\r
65 X-BeenThere: notmuch@notmuchmail.org
\r
66 X-Mailman-Version: 2.1.13
\r
68 List-Id: "Use and development of the notmuch mail system."
\r
69 <notmuch.notmuchmail.org>
\r
70 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
71 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
72 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
73 List-Post: <mailto:notmuch@notmuchmail.org>
\r
74 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
75 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
76 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
77 X-List-Received-Date: Thu, 06 Dec 2012 15:48:10 -0000
\r
79 Just a nit: It would be nice to also replace _json with _sprinter in
\r
80 devel/schemata (those cross-references are always out of date anyway,
\r
81 but might as well try).
\r
83 On Thu, 06 Dec 2012, Peter Feigl <craven@gmx.net> wrote:
\r
84 > All the structured output functions in notmuch-reply and notmuch-show
\r
85 > are renamed to a generic name (as they do not contain any json-specific
\r
86 > code anyway). This patch is a preparation to actually using the new
\r
87 > S-Expression sprinter in notmuch-reply and notmuch-show.
\r
89 > notmuch-client.h | 8 ++++----
\r
90 > notmuch-reply.c | 43 ++++++++++++++++++++++++++-----------------
\r
91 > notmuch-show.c | 30 +++++++++++++++---------------
\r
92 > 3 files changed, 45 insertions(+), 36 deletions(-)
\r
94 > diff --git a/notmuch-client.h b/notmuch-client.h
\r
95 > index ae9344b..1c336dc 100644
\r
96 > --- a/notmuch-client.h
\r
97 > +++ b/notmuch-client.h
\r
98 > @@ -175,12 +175,12 @@ notmuch_status_t
\r
99 > show_one_part (const char *filename, int part);
\r
102 > -format_part_json (const void *ctx, struct sprinter *sp, mime_node_t *node,
\r
103 > - notmuch_bool_t first, notmuch_bool_t output_body);
\r
104 > +format_part_sprinter (const void *ctx, struct sprinter *sp, mime_node_t *node,
\r
105 > + notmuch_bool_t first, notmuch_bool_t output_body);
\r
108 > -format_headers_json (struct sprinter *sp, GMimeMessage *message,
\r
109 > - notmuch_bool_t reply);
\r
110 > +format_headers_sprinter (struct sprinter *sp, GMimeMessage *message,
\r
111 > + notmuch_bool_t reply);
\r
114 > NOTMUCH_SHOW_TEXT_PART_REPLY = 1 << 0,
\r
115 > diff --git a/notmuch-reply.c b/notmuch-reply.c
\r
116 > index e60a264..6103d6e 100644
\r
117 > --- a/notmuch-reply.c
\r
118 > +++ b/notmuch-reply.c
\r
119 > @@ -548,7 +548,8 @@ notmuch_reply_format_default(void *ctx,
\r
120 > notmuch_config_t *config,
\r
121 > notmuch_query_t *query,
\r
122 > notmuch_show_params_t *params,
\r
123 > - notmuch_bool_t reply_all)
\r
124 > + notmuch_bool_t reply_all,
\r
125 > + unused (sprinter_t *sp))
\r
127 > GMimeMessage *reply;
\r
128 > notmuch_messages_t *messages;
\r
129 > @@ -587,17 +588,17 @@ notmuch_reply_format_default(void *ctx,
\r
133 > -notmuch_reply_format_json(void *ctx,
\r
134 > - notmuch_config_t *config,
\r
135 > - notmuch_query_t *query,
\r
136 > - notmuch_show_params_t *params,
\r
137 > - notmuch_bool_t reply_all)
\r
138 > +notmuch_reply_format_sprinter(void *ctx,
\r
139 > + notmuch_config_t *config,
\r
140 > + notmuch_query_t *query,
\r
141 > + notmuch_show_params_t *params,
\r
142 > + notmuch_bool_t reply_all,
\r
143 > + sprinter_t *sp)
\r
145 > GMimeMessage *reply;
\r
146 > notmuch_messages_t *messages;
\r
147 > notmuch_message_t *message;
\r
148 > mime_node_t *node;
\r
149 > - sprinter_t *sp;
\r
151 > if (notmuch_query_count_messages (query) != 1) {
\r
152 > fprintf (stderr, "Error: search term did not match precisely one message.\n");
\r
153 > @@ -613,18 +614,17 @@ notmuch_reply_format_json(void *ctx,
\r
157 > - sp = sprinter_json_create (ctx, stdout);
\r
158 > sp->begin_map (sp);
\r
160 > /* The headers of the reply message we've created */
\r
161 > sp->map_key (sp, "reply-headers");
\r
162 > - format_headers_json (sp, reply, TRUE);
\r
163 > + format_headers_sprinter (sp, reply, TRUE);
\r
164 > g_object_unref (G_OBJECT (reply));
\r
167 > /* Start the original */
\r
168 > sp->map_key (sp, "original");
\r
169 > - format_part_json (ctx, sp, node, TRUE, TRUE);
\r
170 > + format_part_sprinter (ctx, sp, node, TRUE, TRUE);
\r
174 > @@ -639,7 +639,8 @@ notmuch_reply_format_headers_only(void *ctx,
\r
175 > notmuch_config_t *config,
\r
176 > notmuch_query_t *query,
\r
177 > unused (notmuch_show_params_t *params),
\r
178 > - notmuch_bool_t reply_all)
\r
179 > + notmuch_bool_t reply_all,
\r
180 > + unused (sprinter_t *sp))
\r
182 > GMimeMessage *reply;
\r
183 > notmuch_messages_t *messages;
\r
184 > @@ -707,7 +708,12 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
\r
185 > notmuch_query_t *query;
\r
186 > char *query_string;
\r
187 > int opt_index, ret = 0;
\r
188 > - int (*reply_format_func)(void *ctx, notmuch_config_t *config, notmuch_query_t *query, notmuch_show_params_t *params, notmuch_bool_t reply_all);
\r
189 > + int (*reply_format_func)(void *ctx,
\r
190 > + notmuch_config_t *config,
\r
191 > + notmuch_query_t *query,
\r
192 > + notmuch_show_params_t *params,
\r
193 > + notmuch_bool_t reply_all,
\r
194 > + struct sprinter *sp);
\r
195 > notmuch_show_params_t params = {
\r
198 > @@ -717,6 +723,7 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
\r
200 > int format = FORMAT_DEFAULT;
\r
201 > int reply_all = TRUE;
\r
202 > + struct sprinter *sp = NULL;
\r
204 > notmuch_opt_desc_t options[] = {
\r
205 > { NOTMUCH_OPT_KEYWORD, &format, "format", 'f',
\r
206 > @@ -738,12 +745,14 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
\r
210 > - if (format == FORMAT_HEADERS_ONLY)
\r
211 > + if (format == FORMAT_HEADERS_ONLY) {
\r
212 > reply_format_func = notmuch_reply_format_headers_only;
\r
213 > - else if (format == FORMAT_JSON)
\r
214 > - reply_format_func = notmuch_reply_format_json;
\r
216 > + } else if (format == FORMAT_JSON) {
\r
217 > + reply_format_func = notmuch_reply_format_sprinter;
\r
218 > + sp = sprinter_json_create (ctx, stdout);
\r
220 > reply_format_func = notmuch_reply_format_default;
\r
223 > config = notmuch_config_open (ctx, NULL, NULL);
\r
224 > if (config == NULL)
\r
225 > @@ -770,7 +779,7 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
\r
229 > - if (reply_format_func (ctx, config, query, ¶ms, reply_all) != 0)
\r
230 > + if (reply_format_func (ctx, config, query, ¶ms, reply_all, sp) != 0)
\r
233 > notmuch_crypto_cleanup (¶ms.crypto);
\r
234 > diff --git a/notmuch-show.c b/notmuch-show.c
\r
235 > index 2fa2292..38c621f 100644
\r
236 > --- a/notmuch-show.c
\r
237 > +++ b/notmuch-show.c
\r
238 > @@ -32,12 +32,12 @@ static const notmuch_show_format_t format_text = {
\r
241 > static notmuch_status_t
\r
242 > -format_part_json_entry (const void *ctx, sprinter_t *sp, mime_node_t *node,
\r
243 > +format_part_sprinter_entry (const void *ctx, sprinter_t *sp, mime_node_t *node,
\r
244 > int indent, const notmuch_show_params_t *params);
\r
246 > static const notmuch_show_format_t format_json = {
\r
247 > .new_sprinter = sprinter_json_create,
\r
248 > - .part = format_part_json_entry,
\r
249 > + .part = format_part_sprinter_entry,
\r
252 > static notmuch_status_t
\r
253 > @@ -108,7 +108,7 @@ _get_one_line_summary (const void *ctx, notmuch_message_t *message)
\r
254 > /* Emit a sequence of key/value pairs for the metadata of message.
\r
255 > * The caller should begin a map before calling this. */
\r
257 > -format_message_json (sprinter_t *sp, notmuch_message_t *message)
\r
258 > +format_message_sprinter (sprinter_t *sp, notmuch_message_t *message)
\r
260 > /* Any changes to the JSON format should be reflected in the file
\r
261 > * devel/schemata. */
\r
262 > @@ -208,7 +208,7 @@ _is_from_line (const char *line)
\r
266 > -format_headers_json (sprinter_t *sp, GMimeMessage *message,
\r
267 > +format_headers_sprinter (sprinter_t *sp, GMimeMessage *message,
\r
268 > notmuch_bool_t reply)
\r
270 > /* Any changes to the JSON format should be reflected in the file
\r
271 > @@ -363,7 +363,7 @@ signer_status_to_string (GMimeSignerStatus x)
\r
273 > #ifdef GMIME_ATLEAST_26
\r
275 > -format_part_sigstatus_json (sprinter_t *sp, mime_node_t *node)
\r
276 > +format_part_sigstatus_sprinter (sprinter_t *sp, mime_node_t *node)
\r
278 > /* Any changes to the JSON format should be reflected in the file
\r
279 > * devel/schemata. */
\r
280 > @@ -438,7 +438,7 @@ format_part_sigstatus_json (sprinter_t *sp, mime_node_t *node)
\r
284 > -format_part_sigstatus_json (sprinter_t *sp, mime_node_t *node)
\r
285 > +format_part_sigstatus_sprinter (sprinter_t *sp, mime_node_t *node)
\r
287 > const GMimeSignatureValidity* validity = node->sig_validity;
\r
289 > @@ -595,7 +595,7 @@ format_part_text (const void *ctx, sprinter_t *sp, mime_node_t *node,
\r
293 > -format_part_json (const void *ctx, sprinter_t *sp, mime_node_t *node,
\r
294 > +format_part_sprinter (const void *ctx, sprinter_t *sp, mime_node_t *node,
\r
295 > notmuch_bool_t first, notmuch_bool_t output_body)
\r
297 > /* Any changes to the JSON format should be reflected in the file
\r
298 > @@ -603,15 +603,15 @@ format_part_json (const void *ctx, sprinter_t *sp, mime_node_t *node,
\r
300 > if (node->envelope_file) {
\r
301 > sp->begin_map (sp);
\r
302 > - format_message_json (sp, node->envelope_file);
\r
303 > + format_message_sprinter (sp, node->envelope_file);
\r
305 > sp->map_key (sp, "headers");
\r
306 > - format_headers_json (sp, GMIME_MESSAGE (node->part), FALSE);
\r
307 > + format_headers_sprinter (sp, GMIME_MESSAGE (node->part), FALSE);
\r
309 > if (output_body) {
\r
310 > sp->map_key (sp, "body");
\r
311 > sp->begin_list (sp);
\r
312 > - format_part_json (ctx, sp, mime_node_child (node, 0), first, TRUE);
\r
313 > + format_part_sprinter (ctx, sp, mime_node_child (node, 0), first, TRUE);
\r
317 > @@ -646,7 +646,7 @@ format_part_json (const void *ctx, sprinter_t *sp, mime_node_t *node,
\r
319 > if (node->verify_attempted) {
\r
320 > sp->map_key (sp, "sigstatus");
\r
321 > - format_part_sigstatus_json (sp, node);
\r
322 > + format_part_sigstatus_sprinter (sp, node);
\r
325 > sp->map_key (sp, "content-type");
\r
326 > @@ -698,7 +698,7 @@ format_part_json (const void *ctx, sprinter_t *sp, mime_node_t *node,
\r
327 > sp->begin_map (sp);
\r
329 > sp->map_key (sp, "headers");
\r
330 > - format_headers_json (sp, GMIME_MESSAGE (node->part), FALSE);
\r
331 > + format_headers_sprinter (sp, GMIME_MESSAGE (node->part), FALSE);
\r
333 > sp->map_key (sp, "body");
\r
334 > sp->begin_list (sp);
\r
335 > @@ -706,7 +706,7 @@ format_part_json (const void *ctx, sprinter_t *sp, mime_node_t *node,
\r
338 > for (i = 0; i < node->nchildren; i++)
\r
339 > - format_part_json (ctx, sp, mime_node_child (node, i), i == 0, TRUE);
\r
340 > + format_part_sprinter (ctx, sp, mime_node_child (node, i), i == 0, TRUE);
\r
342 > /* Close content structures */
\r
343 > for (i = 0; i < nclose; i++)
\r
344 > @@ -716,11 +716,11 @@ format_part_json (const void *ctx, sprinter_t *sp, mime_node_t *node,
\r
347 > static notmuch_status_t
\r
348 > -format_part_json_entry (const void *ctx, sprinter_t *sp,
\r
349 > +format_part_sprinter_entry (const void *ctx, sprinter_t *sp,
\r
350 > mime_node_t *node, unused (int indent),
\r
351 > const notmuch_show_params_t *params)
\r
353 > - format_part_json (ctx, sp, node, TRUE, params->output_body);
\r
354 > + format_part_sprinter (ctx, sp, node, TRUE, params->output_body);
\r
356 > return NOTMUCH_STATUS_SUCCESS;
\r
361 > _______________________________________________
\r
362 > notmuch mailing list
\r
363 > notmuch@notmuchmail.org
\r
364 > http://notmuchmail.org/mailman/listinfo/notmuch
\r