[PATCH 4/4] Update NEWS for user.other_name
[notmuch-archives.git] / a8 / 3650fe35c2180359b36c2757e1cd0eb82439aa
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 18FB5431FBC\r
6         for <notmuch@notmuchmail.org>; Sun,  5 Feb 2012 09:22:18 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0.104\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.104 tagged_above=-999 required=5\r
12         tests=[DATE_IN_PAST_12_24=0.804, RCVD_IN_DNSWL_LOW=-0.7]\r
13         autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id QtsgMU53CKiZ for <notmuch@notmuchmail.org>;\r
17         Sun,  5 Feb 2012 09:22:16 -0800 (PST)\r
18 Received: from dmz-mailsec-scanner-6.mit.edu (DMZ-MAILSEC-SCANNER-6.MIT.EDU\r
19         [18.7.68.35])\r
20         by olra.theworths.org (Postfix) with ESMTP id 40929431FAF\r
21         for <notmuch@notmuchmail.org>; Sun,  5 Feb 2012 09:22:16 -0800 (PST)\r
22 X-AuditID: 12074423-b7f9c6d0000008c3-30-4f2ebac74d59\r
23 Received: from mailhub-auth-3.mit.edu ( [18.9.21.43])\r
24         by dmz-mailsec-scanner-6.mit.edu (Symantec Messaging Gateway) with SMTP\r
25         id A6.E3.02243.7CABE2F4; Sun,  5 Feb 2012 12:22:15 -0500 (EST)\r
26 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
27         by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id q15HMFJj018766; \r
28         Sun, 5 Feb 2012 12:22:15 -0500\r
29 Received: from drake.mit.edu\r
30         (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com\r
31         [209.6.116.242]) (authenticated bits=0)\r
32         (User authenticated as amdragon@ATHENA.MIT.EDU)\r
33         by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q15HMDbV027734\r
34         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
35         Sun, 5 Feb 2012 12:22:14 -0500 (EST)\r
36 Received: from amthrax by drake.mit.edu with local (Exim 4.77)\r
37         (envelope-from <amthrax@drake.mit.edu>)\r
38         id 1Ru5n4-0000ss-18; Sun, 05 Feb 2012 12:22:14 -0500\r
39 From: Austin Clements <amdragon@MIT.EDU>\r
40 To: notmuch@notmuchmail.org\r
41 Subject: [PATCH v2 2/2] show: Simplify new text formatter code\r
42 Date: Sat,  4 Feb 2012 16:24:26 -0500\r
43 Message-Id: <1328390666-22435-3-git-send-email-amdragon@mit.edu>\r
44 X-Mailer: git-send-email 1.7.7.3\r
45 In-Reply-To: <1328390666-22435-1-git-send-email-amdragon@mit.edu>\r
46 References: <1327560926-22401-1-git-send-email-amdragon@mit.edu>\r
47         <1328390666-22435-1-git-send-email-amdragon@mit.edu>\r
48 X-Brightmail-Tracker:\r
49  H4sIAAAAAAAAA+NgFtrDIsWRmVeSWpSXmKPExsUixCmqrXt8l56/wfRluhZXt/azW1y/OZPZ\r
50         gclj56y77B7PVt1iDmCK4rJJSc3JLEst0rdL4Mp4Oekce8FN94rdWztZGxhXWHUxcnBICJhI\r
51         3O4FMjmBTDGJC/fWs3UxcnEICexjlNh3cgMzhLOeUeLU7ZOsEM49JolJO09CZeYzSlx694Qd\r
52         pJ9NQENi2/7ljCC2iIC0xM67s1lBbGYBJ4nFfxcxg9jCAnYSNy61soHYLAKqEiu6roLFeQUc\r
53         JC5/28YEcYeCxLnV59hBzuMUcJTY+LcQJCwkUC6x6dct1gmM/AsYGVYxyqbkVunmJmbmFKcm\r
54         6xYnJ+blpRbpmunlZpbopaaUbmIEBRK7i/IOxj8HlQ4xCnAwKvHwMpvr+QuxJpYVV+YeYpTk\r
55         YFIS5c3cDhTiS8pPqcxILM6ILyrNSS0+xCjBwawkwit7VNdfiDclsbIqtSgfJiXNwaIkzquh\r
56         9c5PSCA9sSQ1OzW1ILUIJivDwaEkwcsLjBghwaLU9NSKtMycEoQ0EwcnyHAeoOECIDW8xQWJ\r
57         ucWZ6RD5U4yKUuK8DCAJAZBERmkeXC8s0l8xigO9IszLD1LFA0wScN2vgAYzAQ3exwZydXFJ\r
58         IkJKqoFRbcf78Fnza6RKlvzM5Hxv3xnokxssfVmhv8mD86fkqbdtuenXbbjKHHYs8nkeJTQ7\r
59         kWfv1BU/t/FrH15gVLSg4KN/0vW1tTxrl9xXjOqfn9Q6ewfvId2jE02Pad6v/em5bMOFE+bz\r
60         1ff03DN4tffc3i/zHlRs3BNTMntRjPZyiVg9vzkHvgRoKbEUZyQaajEXFScCAM5fpTvPAgAA\r
61 X-BeenThere: notmuch@notmuchmail.org\r
62 X-Mailman-Version: 2.1.13\r
63 Precedence: list\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: Sun, 05 Feb 2012 17:22:18 -0000\r
74 \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
79 32% shorter.\r
80 \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
83 ---\r
84  notmuch-show.c     |   85 +++++++++++++---------------------------------------\r
85  test/crypto        |    2 +-\r
86  test/thread-naming |   16 +++++-----\r
87  3 files changed, 30 insertions(+), 73 deletions(-)\r
88 \r
89 diff --git a/notmuch-show.c b/notmuch-show.c\r
90 index 6a890b2..816e0f8 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
99      int i;\r
100  \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
105 -       };\r
106 -       const char *name, *value;\r
107 -       unsigned int i;\r
108  \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
113 +               part_type,\r
114                 notmuch_message_get_message_id (message),\r
115                 indent,\r
116                 notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH),\r
117                 notmuch_message_get_filename (message));\r
118 -\r
119 -       printf ("\fheader{\n");\r
120 -\r
121 -       printf ("%s\n", _get_one_line_summary (ctx, message));\r
122 -\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
128 -       }\r
129 -       printf ("\fheader}\n");\r
130      } else {\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
135  \r
136         if (disposition &&\r
137             strcmp (disposition->disposition, GMIME_DISPOSITION_ATTACHMENT) == 0)\r
138 -       {\r
139 -           printf ("\fattachment{ ID: %d", node->part_num);\r
140 -\r
141 -       } else {\r
142 -\r
143 -           printf ("\fpart{ ID: %d", node->part_num);\r
144 -       }\r
145 -\r
146 -       if (GMIME_IS_PART (node->part))\r
147 -       {\r
148 -           const char *filename = g_mime_part_get_filename (GMIME_PART (node->part));\r
149 -           if (filename)\r
150 -               printf (", Filename: %s", filename);\r
151 -       }\r
152 +           part_type = "attachment";\r
153 +       else\r
154 +           part_type = "part";\r
155  \r
156 +       printf ("\f%s{ ID: %d", part_type, node->part_num);\r
157 +       if (filename)\r
158 +           printf (", Filename: %s", filename);\r
159         if (cid)\r
160             printf (", Content-id: %s", cid);\r
161 -\r
162         printf (", Content-type: %s\n", g_mime_content_type_to_string (content_type));\r
163      }\r
164  \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
170  \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
181 +\r
182 +       printf ("\fbody{\n");\r
183      }\r
184  \r
185 -    if (!node->envelope_file) {\r
186 +    if (leaf) {\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
189         {\r
190 @@ -810,45 +793,19 @@ 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
194 -       }\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
197 -       {\r
198 -           /* Do nothing for multipart since its content will be printed\r
199 -            * when recursing. */\r
200 -       }\r
201 -       else\r
202 -       {\r
203 +       } else {\r
204             printf ("Non-text part: %s\n",\r
205                     g_mime_content_type_to_string (content_type));\r
206         }\r
207      }\r
208  \r
209 -    if (GMIME_IS_MESSAGE (node->part))\r
210 -       printf ("\fbody{\n");\r
211 -\r
212      for (i = 0; i < node->nchildren; i++)\r
213         format_part_text (ctx, mime_node_child (node, i), indent, params);\r
214  \r
215      if (GMIME_IS_MESSAGE (node->part))\r
216         printf ("\fbody}\n");\r
217  \r
218 -    if (node->envelope_file) {\r
219 -       printf ("\fmessage}\n");\r
220 -    } else {\r
221 -       GMimeContentDisposition *disposition;\r
222 -\r
223 -       disposition = g_mime_object_get_content_disposition (meta);\r
224 -       if (disposition &&\r
225 -           strcmp (disposition->disposition, GMIME_DISPOSITION_ATTACHMENT) == 0)\r
226 -       {\r
227 -           printf ("\fattachment}\n");\r
228 -       }\r
229 -       else\r
230 -       {\r
231 -           printf ("\fpart}\n");\r
232 -       }\r
233 -    }\r
234 +    printf ("\f%s}\n", part_type);\r
235  }\r
236  \r
237  static void\r
238 diff --git a/test/crypto b/test/crypto\r
239 index 446a58b..1dbb60a 100755\r
240 --- a/test/crypto\r
241 +++ b/test/crypto\r
242 @@ -159,7 +159,7 @@ Notmuch Test Suite <test_suite@notmuchmail.org> (2000-01-01) (encrypted inbox)\r
243  Subject: test encrypted message 001\r
244  From: Notmuch Test Suite <test_suite@notmuchmail.org>\r
245  To: test_suite@notmuchmail.org\r
246 -Date: 01 Jan 2000 12:00:00 -0000\r
247 +Date: Sat, 01 Jan 2000 12:00:00 +0000\r
248  \f\r
249 header}\r
250  \f\r
251 body{\r
252  \f\r
253 part{ ID: 1, Content-type: multipart/encrypted\r
254 diff --git a/test/thread-naming b/test/thread-naming\r
255 index 2ce9216..942e593 100755\r
256 --- a/test/thread-naming\r
257 +++ b/test/thread-naming\r
258 @@ -71,7 +71,7 @@ Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-05) (unread)\r
259  Subject: thread-naming: Initial thread subject\r
260  From: Notmuch Test Suite <test_suite@notmuchmail.org>\r
261  To: Notmuch Test Suite <test_suite@notmuchmail.org>\r
262 -Date: Fri, 05 Jan 2001 15:43:56 -0000\r
263 +Date: Fri, 05 Jan 2001 15:43:56 +0000\r
264  \f\r
265 header}\r
266  \f\r
267 body{\r
268  \f\r
269 part{ ID: 1, Content-type: text/plain\r
270 @@ -85,7 +85,7 @@ Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-06) (inbox unread)\r
271  Subject: thread-naming: Older changed subject\r
272  From: Notmuch Test Suite <test_suite@notmuchmail.org>\r
273  To: Notmuch Test Suite <test_suite@notmuchmail.org>\r
274 -Date: Sat, 06 Jan 2001 15:43:56 -0000\r
275 +Date: Sat, 06 Jan 2001 15:43:56 +0000\r
276  \f\r
277 header}\r
278  \f\r
279 body{\r
280  \f\r
281 part{ ID: 1, Content-type: text/plain\r
282 @@ -99,7 +99,7 @@ Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-07) (inbox unread)\r
283  Subject: thread-naming: Newer changed subject\r
284  From: Notmuch Test Suite <test_suite@notmuchmail.org>\r
285  To: Notmuch Test Suite <test_suite@notmuchmail.org>\r
286 -Date: Sun, 07 Jan 2001 15:43:56 -0000\r
287 +Date: Sun, 07 Jan 2001 15:43:56 +0000\r
288  \f\r
289 header}\r
290  \f\r
291 body{\r
292  \f\r
293 part{ ID: 1, Content-type: text/plain\r
294 @@ -113,7 +113,7 @@ Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-08) (unread)\r
295  Subject: thread-naming: Final thread subject\r
296  From: Notmuch Test Suite <test_suite@notmuchmail.org>\r
297  To: Notmuch Test Suite <test_suite@notmuchmail.org>\r
298 -Date: Mon, 08 Jan 2001 15:43:56 -0000\r
299 +Date: Mon, 08 Jan 2001 15:43:56 +0000\r
300  \f\r
301 header}\r
302  \f\r
303 body{\r
304  \f\r
305 part{ ID: 1, Content-type: text/plain\r
306 @@ -127,7 +127,7 @@ Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-09) (inbox unread)\r
307  Subject: Re: thread-naming: Initial thread subject\r
308  From: Notmuch Test Suite <test_suite@notmuchmail.org>\r
309  To: Notmuch Test Suite <test_suite@notmuchmail.org>\r
310 -Date: Tue, 09 Jan 2001 15:43:45 -0000\r
311 +Date: Tue, 09 Jan 2001 15:43:45 +0000\r
312  \f\r
313 header}\r
314  \f\r
315 body{\r
316  \f\r
317 part{ ID: 1, Content-type: text/plain\r
318 @@ -141,7 +141,7 @@ Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-10) (inbox unread)\r
319  Subject: Aw: thread-naming: Initial thread subject\r
320  From: Notmuch Test Suite <test_suite@notmuchmail.org>\r
321  To: Notmuch Test Suite <test_suite@notmuchmail.org>\r
322 -Date: Wed, 10 Jan 2001 15:43:45 -0000\r
323 +Date: Wed, 10 Jan 2001 15:43:45 +0000\r
324  \f\r
325 header}\r
326  \f\r
327 body{\r
328  \f\r
329 part{ ID: 1, Content-type: text/plain\r
330 @@ -155,7 +155,7 @@ Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-11) (inbox unread)\r
331  Subject: Vs: thread-naming: Initial thread subject\r
332  From: Notmuch Test Suite <test_suite@notmuchmail.org>\r
333  To: Notmuch Test Suite <test_suite@notmuchmail.org>\r
334 -Date: Thu, 11 Jan 2001 15:43:45 -0000\r
335 +Date: Thu, 11 Jan 2001 15:43:45 +0000\r
336  \f\r
337 header}\r
338  \f\r
339 body{\r
340  \f\r
341 part{ ID: 1, Content-type: text/plain\r
342 @@ -169,7 +169,7 @@ Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-12) (inbox unread)\r
343  Subject: Sv: thread-naming: Initial thread subject\r
344  From: Notmuch Test Suite <test_suite@notmuchmail.org>\r
345  To: Notmuch Test Suite <test_suite@notmuchmail.org>\r
346 -Date: Fri, 12 Jan 2001 15:43:45 -0000\r
347 +Date: Fri, 12 Jan 2001 15:43:45 +0000\r
348  \f\r
349 header}\r
350  \f\r
351 body{\r
352  \f\r
353 part{ ID: 1, Content-type: text/plain\r
354 -- \r
355 1.7.7.3\r
356 \r