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 D48F4431FB6
\r
6 for <notmuch@notmuchmail.org>; Fri, 27 Jul 2012 14:35:43 -0700 (PDT)
\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 J6gubSLZ3Led for <notmuch@notmuchmail.org>;
\r
16 Fri, 27 Jul 2012 14:35:39 -0700 (PDT)
\r
17 Received: from dmz-mailsec-scanner-8.mit.edu (DMZ-MAILSEC-SCANNER-8.MIT.EDU
\r
19 by olra.theworths.org (Postfix) with ESMTP id B5C76431FAE
\r
20 for <notmuch@notmuchmail.org>; Fri, 27 Jul 2012 14:35:39 -0700 (PDT)
\r
21 X-AuditID: 12074425-b7f9b6d0000008c4-98-501309abe11f
\r
22 Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])
\r
23 by dmz-mailsec-scanner-8.mit.edu (Symantec Messaging Gateway) with SMTP
\r
24 id 5E.4A.02244.BA903105; Fri, 27 Jul 2012 17:35:39 -0400 (EDT)
\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])
\r
26 by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id q6RLZcCQ018364;
\r
27 Fri, 27 Jul 2012 17:35:39 -0400
\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 q6RLZbF5029580
\r
32 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);
\r
33 Fri, 27 Jul 2012 17:35:38 -0400 (EDT)
\r
34 Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77)
\r
35 (envelope-from <amdragon@mit.edu>)
\r
36 id 1SusC9-00012s-Ko; Fri, 27 Jul 2012 17:35:37 -0400
\r
37 Date: Fri, 27 Jul 2012 17:35:37 -0400
\r
38 From: Austin Clements <amdragon@MIT.EDU>
\r
39 To: Mark Walters <markwalters1009@gmail.com>
\r
40 Subject: Re: [PATCH 10/13] show: Convert envelope format_part_json to use
\r
42 Message-ID: <20120727213537.GD8502@mit.edu>
\r
43 References: <1343183693-17134-1-git-send-email-amdragon@mit.edu>
\r
44 <1343183693-17134-11-git-send-email-amdragon@mit.edu>
\r
45 <874novirxv.fsf@qmul.ac.uk>
\r
47 Content-Type: text/plain; charset=us-ascii
\r
48 Content-Disposition: inline
\r
49 In-Reply-To: <874novirxv.fsf@qmul.ac.uk>
\r
50 User-Agent: Mutt/1.5.21 (2010-09-15)
\r
51 X-Brightmail-Tracker:
\r
52 H4sIAAAAAAAAA+NgFmpileLIzCtJLcpLzFFi42IRYrdT113NKRxg8HMLu8XquTwW12/OZHZg
\r
53 8tg56y67x7NVt5gDmKK4bFJSczLLUov07RK4Mn49aWYqeKRcsfz8XMYGxpXSXYycHBICJhLH
\r
54 1x1kgrDFJC7cW8/WxcjFISSwj1Gi4+wVJghnA6PE1xUnoTInmSQ6Vt6EyixhlHh37jw7SD+L
\r
55 gKrEr51bWEBsNgENiW37lzOC2CICOhK3Dy0Aq2EWkJb49rsZbJ+wQIjE+xszwOp5BbQlpjVf
\r
56 BopzAA2dxijRnAwRFpQ4OfMJC0SrlsSNfy/BSkDGLP/HARLmBNp0cMkvsBJRARWJKSe3sU1g
\r
57 FJqFpHsWku5ZCN0LGJlXMcqm5Fbp5iZm5hSnJusWJyfm5aUW6Vro5WaW6KWmlG5iBAe1i+oO
\r
58 xgmHlA4xCnAwKvHwnroiFCDEmlhWXJl7iFGSg0lJlPcMh3CAEF9SfkplRmJxRnxRaU5q8SFG
\r
59 CQ5mJRFemx1A5bwpiZVVqUX5MClpDhYlcd4bKTf9hQTSE0tSs1NTC1KLYLIyHBxKErxXQIYK
\r
60 FqWmp1akZeaUIKSZODhBhvMADX8IUsNbXJCYW5yZDpE/xagoJc77BCQhAJLIKM2D64UlnVeM
\r
61 4kCvCPMyAFOQEA8wYcF1vwIazAQ02CIa5OrikkSElFQD4xSlzrx2gW+qAXf6F6855vM578gq
\r
62 i2/erwvnveJe+NKq/uDhh2usIm+uZ3yc/FbheMBd4/IPdVIrc7ie31tZUKdZYnyOz9FuC6/F
\r
63 J9k7fvtVxGtm6CjG7GdS7jhj9TD786+GeNlJ7RMFup9/iHNdXpNgmucXenf6DtEy7U1Mq760
\r
64 crkZfvZUUGIpzkg01GIuKk4EAAKO2pIVAwAA
\r
65 Cc: notmuch@notmuchmail.org
\r
66 X-BeenThere: notmuch@notmuchmail.org
\r
67 X-Mailman-Version: 2.1.13
\r
69 List-Id: "Use and development of the notmuch mail system."
\r
70 <notmuch.notmuchmail.org>
\r
71 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
72 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
73 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
74 List-Post: <mailto:notmuch@notmuchmail.org>
\r
75 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
76 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
77 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
78 X-List-Received-Date: Fri, 27 Jul 2012 21:35:44 -0000
\r
80 Quoth Mark Walters on Jul 25 at 8:03 pm:
\r
81 > On Wed, 25 Jul 2012, Austin Clements <amdragon@MIT.EDU> wrote:
\r
83 > > notmuch-show.c | 57 +++++++++++++++++++++++++++++++++-----------------------
\r
84 > > 1 file changed, 34 insertions(+), 23 deletions(-)
\r
86 > > diff --git a/notmuch-show.c b/notmuch-show.c
\r
87 > > index afbd9d0..fa1e6e9 100644
\r
88 > > --- a/notmuch-show.c
\r
89 > > +++ b/notmuch-show.c
\r
90 > > @@ -110,34 +110,44 @@ _get_one_line_summary (const void *ctx, notmuch_message_t *message)
\r
94 > > -format_message_json (const void *ctx, notmuch_message_t *message)
\r
95 > > +format_message_json (sprinter_t *sp, notmuch_message_t *message)
\r
98 > It might be nice to have a comment for this function (and other
\r
99 > similar ones) saying what it prints: is it a sequence of key: value
\r
100 > pairs, or a map or an array etc. On the other hand it might be that
\r
101 > it is best as it is where you just read the code to see.
\r
103 Ah, good point. I don't think this is so necessary for the other
\r
104 functions, but this one is weird because it requires the caller to
\r
105 begin the map (every other function simply emits a value, so it
\r
106 doesn't depend on the caller's context).
\r
108 > > + void *local = talloc_new (NULL);
\r
109 > > notmuch_tags_t *tags;
\r
110 > > - int first = 1;
\r
111 > > - void *ctx_quote = talloc_new (ctx);
\r
113 > > const char *relative_date;
\r
115 > > date = notmuch_message_get_date (message);
\r
116 > > - relative_date = notmuch_time_relative_date (ctx, date);
\r
117 > > + relative_date = notmuch_time_relative_date (local, date);
\r
119 > This makes the diff very easy to read but it might be nicer to have
\r
120 > these two assignments further down where they are used.
\r
122 Done, and it is nicer. (Apparently I had the 'date' assignment both
\r
130 > > + sp->map_key (sp, "id");
\r
131 > > + sp->string (sp, notmuch_message_get_message_id (message));
\r
133 > > + sp->map_key (sp, "match");
\r
134 > > + sp->boolean (sp, notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH));
\r
136 > > + sp->map_key (sp, "excluded");
\r
137 > > + sp->boolean (sp, notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED));
\r
139 > > + sp->map_key (sp, "filename");
\r
140 > > + sp->string (sp, notmuch_message_get_filename (message));
\r
142 > > + sp->map_key (sp, "timestamp");
\r
143 > > + date = notmuch_message_get_date (message);
\r
144 > > + sp->integer (sp, date);
\r
146 > > - printf ("\"id\": %s, \"match\": %s, \"excluded\": %s, \"filename\": %s, \"timestamp\": %ld, \"date_relative\": \"%s\", \"tags\": [",
\r
147 > > - json_quote_str (ctx_quote, notmuch_message_get_message_id (message)),
\r
148 > > - notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH) ? "true" : "false",
\r
149 > > - notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED) ? "true" : "false",
\r
150 > > - json_quote_str (ctx_quote, notmuch_message_get_filename (message)),
\r
151 > > - date, relative_date);
\r
152 > > + sp->map_key (sp, "date_relative");
\r
153 > > + sp->string (sp, relative_date);
\r
155 > > + sp->map_key (sp, "tags");
\r
156 > > + sp->begin_list (sp);
\r
157 > > for (tags = notmuch_message_get_tags (message);
\r
158 > > notmuch_tags_valid (tags);
\r
159 > > notmuch_tags_move_to_next (tags))
\r
161 > > - printf("%s%s", first ? "" : ",",
\r
162 > > - json_quote_str (ctx_quote, notmuch_tags_get (tags)));
\r
165 > > - printf("], ");
\r
166 > > - talloc_free (ctx_quote);
\r
167 > > + sp->string (sp, notmuch_tags_get (tags));
\r
168 > > + sp->end (sp);
\r
170 > > + talloc_free (local);
\r
173 > > /* Extract just the email address from the contents of a From:
\r
174 > > @@ -573,18 +583,19 @@ format_part_json (const void *ctx, sprinter_t *sp, mime_node_t *node,
\r
175 > > * devel/schemata. */
\r
177 > > if (node->envelope_file) {
\r
178 > > - printf ("{");
\r
179 > > - format_message_json (ctx, node->envelope_file);
\r
180 > > + sp->begin_map (sp);
\r
181 > > + format_message_json (sp, node->envelope_file);
\r
183 > > - printf ("\"headers\": ");
\r
184 > > + sp->map_key (sp, "headers");
\r
185 > > format_headers_json (sp, GMIME_MESSAGE (node->part), FALSE);
\r
187 > > if (output_body) {
\r
188 > > - printf (", \"body\": [");
\r
189 > > + sp->map_key (sp, "body");
\r
190 > > + sp->begin_list (sp);
\r
191 > > format_part_json (ctx, sp, mime_node_child (node, 0), first, TRUE);
\r
192 > > - printf ("]");
\r
193 > > + sp->end (sp);
\r
195 > > - printf ("}");
\r
196 > > + sp->end (sp);
\r