1 Return-Path: <amthrax@drake.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 78C3F431FC2
\r
6 for <notmuch@notmuchmail.org>; Wed, 25 Jan 2012 22:55:41 -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 OroB-k1xtnI2 for <notmuch@notmuchmail.org>;
\r
16 Wed, 25 Jan 2012 22:55:39 -0800 (PST)
\r
17 Received: from dmz-mailsec-scanner-1.mit.edu (DMZ-MAILSEC-SCANNER-1.MIT.EDU
\r
19 by olra.theworths.org (Postfix) with ESMTP id 65499431FB6
\r
20 for <notmuch@notmuchmail.org>; Wed, 25 Jan 2012 22:55:39 -0800 (PST)
\r
21 X-AuditID: 1209190c-b7fad6d000000920-08-4f20f8eb4167
\r
22 Received: from mailhub-auth-1.mit.edu ( [18.9.21.35])
\r
23 by dmz-mailsec-scanner-1.mit.edu (Symantec Messaging Gateway) with SMTP
\r
24 id C7.FC.02336.BE8F02F4; Thu, 26 Jan 2012 01:55:39 -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 q0Q6taeG010092;
\r
27 Thu, 26 Jan 2012 01:55:36 -0500
\r
28 Received: from drake.mit.edu
\r
29 (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com
\r
30 [209.6.116.242]) (authenticated bits=0)
\r
31 (User authenticated as amdragon@ATHENA.MIT.EDU)
\r
32 by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q0Q6tYsq005480
\r
33 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);
\r
34 Thu, 26 Jan 2012 01:55:34 -0500 (EST)
\r
35 Received: from amthrax by drake.mit.edu with local (Exim 4.77)
\r
36 (envelope-from <amthrax@drake.mit.edu>)
\r
37 id 1RqJF7-0005uI-U7; Thu, 26 Jan 2012 01:55:33 -0500
\r
38 From: Austin Clements <amdragon@MIT.EDU>
\r
39 To: notmuch@notmuchmail.org
\r
40 Subject: [PATCH 2/2] show: Simplify new text formatter code
\r
41 Date: Thu, 26 Jan 2012 01:55:26 -0500
\r
42 Message-Id: <1327560926-22401-3-git-send-email-amdragon@mit.edu>
\r
43 X-Mailer: git-send-email 1.7.7.3
\r
44 In-Reply-To: <1327560926-22401-1-git-send-email-amdragon@mit.edu>
\r
45 References: <1327560926-22401-1-git-send-email-amdragon@mit.edu>
\r
46 X-Brightmail-Tracker:
\r
47 H4sIAAAAAAAAA+NgFrrJIsWRmVeSWpSXmKPExsUixCmqrPv6h4K/wf0uDourW/vZLZqmO1vs
\r
48 2edlcf3mTGaLNyvnsTqwetw9zeWxc9Zddo/DXxeyeNy6/5rd49mqW8wBrFFcNimpOZllqUX6
\r
49 dglcGde2pxS0eVS0nJvA2MB42qqLkZNDQsBE4s23LawQtpjEhXvr2boYuTiEBPYxSqy81ckI
\r
50 4WxglPjQuocdwrnPJNG+fREThDOfUeLFlhZGkH42AQ2JbfuXg9kiAtISO+/OZgUpYhboYZRY
\r
51 eOg5WEJYwFri5rd9zCA2i4CqxO7F39lBbF4BB4lZD9pZIA5RkDi3+hxYnFPAUeLlub9gthBQ
\r
52 TUPfL/YJjPwLGBlWMcqm5Fbp5iZm5hSnJusWJyfm5aUW6Rrq5WaW6KWmlG5iBIegJM8OxjcH
\r
53 lQ4xCnAwKvHw7jBS8BdiTSwrrsw9xCjJwaQkypv5HSjEl5SfUpmRWJwRX1Sak1p8iFGCg1lJ
\r
54 hFfMHijHm5JYWZValA+TkuZgURLnVdF65yckkJ5YkpqdmlqQWgSTleHgUJLgjQXGmpBgUWp6
\r
55 akVaZk4JQpqJgxNkOA/QcHeQGt7igsTc4sx0iPwpRkUpcV5TkIQASCKjNA+uF5YiXjGKA70i
\r
56 zBsIUsUDTC9w3a+ABjMBDV6qKw8yuCQRISXVwFh+ZYqbhGHoyndeO+vnP82dNUlkXyVbpay+
\r
57 3qTDPCHb6mriu/Zvn9gR6/3u5MSHESb/a2rU30zl2eih5eG9/8t2k+gUZq9/r9kjaibfbTLM
\r
58 /roi7d7uiItfBeXm/ubMXpBeNs8m7XjV9lv/l/avtjTY/LC26Mxl5TDbe+Jhx2N3ZwWXZd3f
\r
59 aKrEUpyRaKjFXFScCABmkxGR7AIAAA==
\r
60 Cc: tomi.ollila@iki.fi
\r
61 X-BeenThere: notmuch@notmuchmail.org
\r
62 X-Mailman-Version: 2.1.13
\r
64 List-Id: "Use and development of the notmuch mail system."
\r
65 <notmuch.notmuchmail.org>
\r
66 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
67 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
68 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
69 List-Post: <mailto:notmuch@notmuchmail.org>
\r
70 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
71 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
72 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
73 X-List-Received-Date: Thu, 26 Jan 2012 06:55:41 -0000
\r
75 This makes the text formatter take advantage of the new code
\r
76 structure. The previously duplicated header logic is now unified,
\r
77 several things that we used to compute repeatedly across different
\r
78 callbacks are now computed once, and the code is simpler overall and
\r
81 Unifying the header logic causes this to format some dates slightly
\r
82 differently, so the two affected test cases are updated.
\r
84 notmuch-show.c | 88 +++++++++++++--------------------------------------
\r
86 test/thread-naming | 16 +++++-----
\r
87 3 files changed, 32 insertions(+), 74 deletions(-)
\r
89 diff --git a/notmuch-show.c b/notmuch-show.c
\r
90 index 6a890b2..30f6501 100644
\r
91 --- a/notmuch-show.c
\r
92 +++ b/notmuch-show.c
\r
93 @@ -727,67 +727,48 @@ format_part_text (const void *ctx, mime_node_t *node,
\r
94 GMimeObject *meta = node->envelope_part ?
\r
95 GMIME_OBJECT (node->envelope_part) : node->part;
\r
96 GMimeContentType *content_type = g_mime_object_get_content_type (meta);
\r
97 + const notmuch_bool_t leaf = GMIME_IS_PART (node->part);
\r
98 + const char *part_type;
\r
101 if (node->envelope_file) {
\r
102 notmuch_message_t *message = node->envelope_file;
\r
103 - const char *headers[] = {
\r
104 - "Subject", "From", "To", "Cc", "Bcc", "Date"
\r
106 - const char *name, *value;
\r
109 - printf ("\fmessage{ ");
\r
110 - printf ("id:%s depth:%d match:%d filename:%s\n",
\r
111 + part_type = "message";
\r
112 + printf ("\f%s{ id:%s depth:%d match:%d filename:%s\n",
\r
114 notmuch_message_get_message_id (message),
\r
116 notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH),
\r
117 notmuch_message_get_filename (message));
\r
119 - printf ("\fheader{\n");
\r
121 - printf ("%s\n", _get_one_line_summary (ctx, message));
\r
123 - for (i = 0; i < ARRAY_SIZE (headers); i++) {
\r
124 - name = headers[i];
\r
125 - value = notmuch_message_get_header (message, name);
\r
126 - if (value && strlen (value))
\r
127 - printf ("%s: %s\n", name, value);
\r
129 - printf ("\fheader}\n");
\r
131 GMimeContentDisposition *disposition = g_mime_object_get_content_disposition (meta);
\r
132 const char *cid = g_mime_object_get_content_id (meta);
\r
133 + const char *filename = leaf ?
\r
134 + g_mime_part_get_filename (GMIME_PART (node->part)) : NULL;
\r
137 strcmp (disposition->disposition, GMIME_DISPOSITION_ATTACHMENT) == 0)
\r
139 - printf ("\fattachment{ ID: %d", node->part_num);
\r
143 - printf ("\fpart{ ID: %d", node->part_num);
\r
146 - if (GMIME_IS_PART (node->part))
\r
148 - const char *filename = g_mime_part_get_filename (GMIME_PART (node->part));
\r
150 - printf (", Filename: %s", filename);
\r
152 + part_type = "attachment";
\r
154 + part_type = "part";
\r
156 + printf ("\f%s{ ID: %d", part_type, node->part_num);
\r
158 + printf (", Filename: %s", filename);
\r
160 printf (", Content-id: %s", cid);
\r
162 printf (", Content-type: %s\n", g_mime_content_type_to_string (content_type));
\r
165 - if (node->envelope_part) {
\r
166 + if (GMIME_IS_MESSAGE (node->part)) {
\r
167 GMimeMessage *message = GMIME_MESSAGE (node->part);
\r
168 InternetAddressList *recipients;
\r
169 const char *recipients_string;
\r
171 printf ("\fheader{\n");
\r
172 + if (node->envelope_file)
\r
173 + printf ("%s\n", _get_one_line_summary (ctx, node->envelope_file));
\r
174 printf ("Subject: %s\n", g_mime_message_get_subject (message));
\r
175 printf ("From: %s\n", g_mime_message_get_sender (message));
\r
176 recipients = g_mime_message_get_recipients (message, GMIME_RECIPIENT_TYPE_TO);
\r
177 @@ -800,9 +781,11 @@ format_part_text (const void *ctx, mime_node_t *node,
\r
178 printf ("Cc: %s\n", recipients_string);
\r
179 printf ("Date: %s\n", g_mime_message_get_date_as_string (message));
\r
180 printf ("\fheader}\n");
\r
182 + printf ("\fbody{\n");
\r
185 - if (!node->envelope_file) {
\r
187 if (g_mime_content_type_is_type (content_type, "text", "*") &&
\r
188 !g_mime_content_type_is_type (content_type, "text", "html"))
\r
190 @@ -810,45 +793,20 @@ format_part_text (const void *ctx, mime_node_t *node,
\r
191 g_mime_stream_file_set_owner (GMIME_STREAM_FILE (stream_stdout), FALSE);
\r
192 show_text_part_content (node->part, stream_stdout);
\r
193 g_object_unref(stream_stdout);
\r
195 - else if (g_mime_content_type_is_type (content_type, "multipart", "*") ||
\r
196 - g_mime_content_type_is_type (content_type, "message", "rfc822"))
\r
198 - /* Do nothing for multipart since its content will be printed
\r
199 - * when recursing. */
\r
204 printf ("Non-text part: %s\n",
\r
205 g_mime_content_type_to_string (content_type));
\r
209 - if (GMIME_IS_MESSAGE (node->part))
\r
210 - printf ("\fbody{\n");
\r
212 for (i = 0; i < node->nchildren; i++)
\r
213 format_part_text (ctx, mime_node_child (node, i), indent, params);
\r
215 - if (GMIME_IS_MESSAGE (node->part))
\r
216 + if (GMIME_IS_MESSAGE (node->part)) {
\r
217 printf ("\fbody}\n");
\r
219 - if (node->envelope_file) {
\r
220 - printf ("\fmessage}\n");
\r
222 - GMimeContentDisposition *disposition;
\r
224 - disposition = g_mime_object_get_content_disposition (meta);
\r
225 - if (disposition &&
\r
226 - strcmp (disposition->disposition, GMIME_DISPOSITION_ATTACHMENT) == 0)
\r
228 - printf ("\fattachment}\n");
\r
232 - printf ("\fpart}\n");
\r
236 + printf ("\f%s}\n", part_type);
\r
240 diff --git a/test/crypto b/test/crypto
\r
241 index 446a58b..1dbb60a 100755
\r
244 @@ -159,7 +159,7 @@ Notmuch Test Suite <test_suite@notmuchmail.org> (2000-01-01) (encrypted inbox)
\r
245 Subject: test encrypted message 001
\r
246 From: Notmuch Test Suite <test_suite@notmuchmail.org>
\r
247 To: test_suite@notmuchmail.org
\r
248 -Date: 01 Jan 2000 12:00:00 -0000
\r
249 +Date: Sat, 01 Jan 2000 12:00:00 +0000
\r
255 part{ ID: 1, Content-type: multipart/encrypted
\r
256 diff --git a/test/thread-naming b/test/thread-naming
\r
257 index 2ce9216..942e593 100755
\r
258 --- a/test/thread-naming
\r
259 +++ b/test/thread-naming
\r
260 @@ -71,7 +71,7 @@ Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-05) (unread)
\r
261 Subject: thread-naming: Initial thread subject
\r
262 From: Notmuch Test Suite <test_suite@notmuchmail.org>
\r
263 To: Notmuch Test Suite <test_suite@notmuchmail.org>
\r
264 -Date: Fri, 05 Jan 2001 15:43:56 -0000
\r
265 +Date: Fri, 05 Jan 2001 15:43:56 +0000
\r
271 part{ ID: 1, Content-type: text/plain
\r
272 @@ -85,7 +85,7 @@ Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-06) (inbox unread)
\r
273 Subject: thread-naming: Older changed subject
\r
274 From: Notmuch Test Suite <test_suite@notmuchmail.org>
\r
275 To: Notmuch Test Suite <test_suite@notmuchmail.org>
\r
276 -Date: Sat, 06 Jan 2001 15:43:56 -0000
\r
277 +Date: Sat, 06 Jan 2001 15:43:56 +0000
\r
283 part{ ID: 1, Content-type: text/plain
\r
284 @@ -99,7 +99,7 @@ Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-07) (inbox unread)
\r
285 Subject: thread-naming: Newer changed subject
\r
286 From: Notmuch Test Suite <test_suite@notmuchmail.org>
\r
287 To: Notmuch Test Suite <test_suite@notmuchmail.org>
\r
288 -Date: Sun, 07 Jan 2001 15:43:56 -0000
\r
289 +Date: Sun, 07 Jan 2001 15:43:56 +0000
\r
295 part{ ID: 1, Content-type: text/plain
\r
296 @@ -113,7 +113,7 @@ Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-08) (unread)
\r
297 Subject: thread-naming: Final thread subject
\r
298 From: Notmuch Test Suite <test_suite@notmuchmail.org>
\r
299 To: Notmuch Test Suite <test_suite@notmuchmail.org>
\r
300 -Date: Mon, 08 Jan 2001 15:43:56 -0000
\r
301 +Date: Mon, 08 Jan 2001 15:43:56 +0000
\r
307 part{ ID: 1, Content-type: text/plain
\r
308 @@ -127,7 +127,7 @@ Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-09) (inbox unread)
\r
309 Subject: Re: thread-naming: Initial thread subject
\r
310 From: Notmuch Test Suite <test_suite@notmuchmail.org>
\r
311 To: Notmuch Test Suite <test_suite@notmuchmail.org>
\r
312 -Date: Tue, 09 Jan 2001 15:43:45 -0000
\r
313 +Date: Tue, 09 Jan 2001 15:43:45 +0000
\r
319 part{ ID: 1, Content-type: text/plain
\r
320 @@ -141,7 +141,7 @@ Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-10) (inbox unread)
\r
321 Subject: Aw: thread-naming: Initial thread subject
\r
322 From: Notmuch Test Suite <test_suite@notmuchmail.org>
\r
323 To: Notmuch Test Suite <test_suite@notmuchmail.org>
\r
324 -Date: Wed, 10 Jan 2001 15:43:45 -0000
\r
325 +Date: Wed, 10 Jan 2001 15:43:45 +0000
\r
331 part{ ID: 1, Content-type: text/plain
\r
332 @@ -155,7 +155,7 @@ Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-11) (inbox unread)
\r
333 Subject: Vs: thread-naming: Initial thread subject
\r
334 From: Notmuch Test Suite <test_suite@notmuchmail.org>
\r
335 To: Notmuch Test Suite <test_suite@notmuchmail.org>
\r
336 -Date: Thu, 11 Jan 2001 15:43:45 -0000
\r
337 +Date: Thu, 11 Jan 2001 15:43:45 +0000
\r
343 part{ ID: 1, Content-type: text/plain
\r
344 @@ -169,7 +169,7 @@ Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-12) (inbox unread)
\r
345 Subject: Sv: thread-naming: Initial thread subject
\r
346 From: Notmuch Test Suite <test_suite@notmuchmail.org>
\r
347 To: Notmuch Test Suite <test_suite@notmuchmail.org>
\r
348 -Date: Fri, 12 Jan 2001 15:43:45 -0000
\r
349 +Date: Fri, 12 Jan 2001 15:43:45 +0000
\r
355 part{ ID: 1, Content-type: text/plain
\r