Re: [PATCH v4 02/16] Move crypto.c into libutil
[notmuch-archives.git] / 07 / 466439adc200743f3d01a186d2b64fe95f4aae
1 Return-Path: <m.walters@qmul.ac.uk>\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 8302B431FBC\r
6         for <notmuch@notmuchmail.org>; Mon,  3 Feb 2014 12:19:15 -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: -1.098\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5\r
12         tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,\r
13         NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] 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 EtXKL1WKyroI for <notmuch@notmuchmail.org>;\r
17         Mon,  3 Feb 2014 12:19:07 -0800 (PST)\r
18 Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])\r
19         (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id F1279431FAF\r
22         for <notmuch@notmuchmail.org>; Mon,  3 Feb 2014 12:19:06 -0800 (PST)\r
23 Received: from smtp.qmul.ac.uk ([138.37.6.40])\r
24         by mail2.qmul.ac.uk with esmtp (Exim 4.71)\r
25         (envelope-from <m.walters@qmul.ac.uk>)\r
26         id 1WAPyt-00053x-3Z; Mon, 03 Feb 2014 20:19:01 +0000\r
27 Received: from 93-97-24-31.zone5.bethere.co.uk ([93.97.24.31] helo=localhost)\r
28         by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71)\r
29         (envelope-from <m.walters@qmul.ac.uk>)\r
30         id 1WAPxV-0004tm-CQ; Mon, 03 Feb 2014 20:17:33 +0000\r
31 From: Mark Walters <markwalters1009@gmail.com>\r
32 To: "W. Trevor King" <wking@tremily.us>, notmuch@notmuchmail.org\r
33 Subject: Re: [PATCH 2/2] emacs: Prefer Content-Description over filename for\r
34         part buttons\r
35 In-Reply-To:\r
36  <27be295875a7df782a83c9a2c09d06f9d321fe9e.1391423201.git.wking@tremily.us>\r
37 References: <877g9chbay.fsf@qmul.ac.uk>\r
38  <cover.1391423201.git.wking@tremily.us>\r
39         <27be295875a7df782a83c9a2c09d06f9d321fe9e.1391423201.git.wking@tremily.us>\r
40 User-Agent: Notmuch/0.15.2+484~gfb59956 (http://notmuchmail.org) Emacs/23.4.1\r
41         (x86_64-pc-linux-gnu)\r
42 Date: Mon, 03 Feb 2014 20:15:35 +0000\r
43 Message-ID: <87vbwwosuw.fsf@qmul.ac.uk>\r
44 MIME-Version: 1.0\r
45 Content-Type: text/plain; charset=us-ascii\r
46 X-Sender-Host-Address: 93.97.24.31\r
47 X-QM-Geographic: According to ripencc,\r
48         this message was delivered by a machine in Britain (UK) (GB).\r
49 X-QM-SPAM-Info: Sender has good ham record.  :)\r
50 X-QM-Body-MD5: c539f0f6708f1a6f06009f6f53f85c2d (of first 20000 bytes)\r
51 X-SpamAssassin-Score: 0.0\r
52 X-SpamAssassin-SpamBar: /\r
53 X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
54         determine if it is\r
55         spam. We require at least 5.0 points to mark a message as spam.\r
56         This message scored 0.0 points. Summary of the scoring: \r
57         * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\r
58         provider *      (markwalters1009[at]gmail.com)\r
59         *  0.0 AWL AWL: From: address is in the auto white-list\r
60 X-QM-Scan-Virus: ClamAV says the message is clean\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: Mon, 03 Feb 2014 20:19:15 -0000\r
74 \r
75 \r
76 On Mon, 03 Feb 2014, "W. Trevor King" <wking@tremily.us> wrote:\r
77 > On the rss2email list, Victor Orlikowski pointed out [1] that a number\r
78 > of MUAs don't use the Subject header of attached message/rfc822 parts\r
79 > to label multipart/digest subparts [2].  Instead, notmuch and several\r
80 > other MUAs use the filename parameter [3] as a content hint.  Using\r
81 > the filename parameter seems more sane than diving into the\r
82 > message/rfc822 part header, but that's still not what the filename\r
83 > parameter was designed for.  It makes more sense to me to use the\r
84 > message/rfc822 part's Content-Description header (which I just taught\r
85 > notmuch-show to export), falling back on the filename parameter if\r
86 > Content-Description isn't set.\r
87 >\r
88 > [1]: http://article.gmane.org/gmane.mail.rss2email/211\r
89 > [2]: Digests: http://tools.ietf.org/html/rfc2046#section-5.1.5\r
90 > [3]: Filename: http://tools.ietf.org/search/rfc2183#section-2.3\r
91 \r
92 I tried this and it all works. However, I looked through my collection\r
93 an I have a lot of emails which have Content-Description headers that\r
94 are empty. Thus, I think we should only display/use the\r
95 content-description if it exists and is non-empty. Something like\r
96 \r
97          (description (plist-get part :content-description))\r
98          (name (if (and description (not (equal description "")))\r
99                    description\r
100                  (plist-get part :filename)))\r
101 \r
102 My only other comment on the series is that you should update\r
103 devel/schemata in the first patch to reflect this addition.\r
104 \r
105 Otherwise it looks good to me\r
106 \r
107 Best wishes\r
108 \r
109 Mark\r
110 \r
111 \r
112 > ---\r
113 >  NEWS                                               |  7 ++\r
114 >  emacs/notmuch-show.el                              |  4 +-\r
115 >  test/T450-emacs-show.sh                            | 12 ++++\r
116 >  test/corpus/cur/24:2,                              |  1 +\r
117 >  .../notmuch-show-buttons-content-description       | 84 ++++++++++++++++++++++\r
118 >  .../notmuch-show-buttons-filename                  | 74 +++++++++++++++++++\r
119 >  6 files changed, 181 insertions(+), 1 deletion(-)\r
120 >  create mode 100644 test/emacs-show.expected-output/notmuch-show-buttons-content-description\r
121 >  create mode 100644 test/emacs-show.expected-output/notmuch-show-buttons-filename\r
122 >\r
123 > diff --git a/NEWS b/NEWS\r
124 > index 0f7b1c8..2154872 100644\r
125 > --- a/NEWS\r
126 > +++ b/NEWS\r
127 > @@ -10,6 +10,13 @@ Command-Line Interface\r
128 >  \r
129 >  `notmuch show` now includes envelope Content-Description headers.\r
130 >  \r
131 > +Emacs Interface\r
132 > +---------------\r
133 > +\r
134 > +`notmuch-show` mode prefers Content-Description to filename when\r
135 > +naming part buttons.  This is useful for finding interesting parts of\r
136 > +multipart/digest messages, assuming the digest-creator set that field.\r
137 > +\r
138 >  Notmuch 0.17 (2013-12-30)\r
139 >  =========================\r
140 >  \r
141 > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
142 > index 1ac80ca..dbff3a8 100644\r
143 > --- a/emacs/notmuch-show.el\r
144 > +++ b/emacs/notmuch-show.el\r
145 > @@ -874,13 +874,15 @@ useful for quoting in replies)."\r
146 >                       content-type))\r
147 >        (nth (plist-get part :id))\r
148 >        (beg (point))\r
149 > +      (name (or (plist-get part :content-description)\r
150 > +                (plist-get part :filename)))\r
151 >        ;; Hide the part initially if HIDE is t.\r
152 >        (show-part (not (equal hide t)))\r
153 >        ;; We omit the part button for the first (or only) part if\r
154 >        ;; this is text/plain, or HIDE is 'no-buttons.\r
155 >        (button (unless (or (equal hide 'no-buttons)\r
156 >                            (and (string= mime-type "text/plain") (<= nth 1)))\r
157 > -                (notmuch-show-insert-part-header nth mime-type content-type (plist-get part :filename))))\r
158 > +                (notmuch-show-insert-part-header nth mime-type content-type name)))\r
159 >        (content-beg (point)))\r
160 >  \r
161 >      ;; Store the computed mime-type for later use (e.g. by attachment handlers).\r
162 > diff --git a/test/T450-emacs-show.sh b/test/T450-emacs-show.sh\r
163 > index 2a3a535..5650f04 100755\r
164 > --- a/test/T450-emacs-show.sh\r
165 > +++ b/test/T450-emacs-show.sh\r
166 > @@ -106,6 +106,18 @@ test_emacs '(notmuch-search "from:lars@seas.harvard.edu and subject:\"Maildir st\r
167 >       (test-visible-output)'\r
168 >  test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-indent-thread-content-off\r
169 >  \r
170 > +test_begin_subtest "buttons prefer Content-Description"\r
171 > +test_emacs '(let ((notmuch-crypto-process-mime nil))\r
172 > +     (notmuch-show "id:20091118010116.GC25380@dottiness.seas.harvard.edu")\r
173 > +     (test-visible-output))'\r
174 > +test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-buttons-content-description\r
175 > +\r
176 > +test_begin_subtest "buttons fallback to filename"\r
177 > +test_emacs '(let ((notmuch-crypto-process-mime nil))\r
178 > +     (notmuch-show "id:20091118005829.GB25380@dottiness.seas.harvard.edu")\r
179 > +     (test-visible-output))'\r
180 > +test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-buttons-filename\r
181 > +\r
182 >  test_begin_subtest "id buttonization"\r
183 >  add_message '[body]="\r
184 >  id:abc\r
185 > diff --git a/test/corpus/cur/24:2, b/test/corpus/cur/24:2,\r
186 > index c800020..f9418d2 100644\r
187 > --- a/test/corpus/cur/24:2,\r
188 > +++ b/test/corpus/cur/24:2,\r
189 > @@ -104,6 +104,7 @@ Harvard University School of Engineering and Applied Sciences\r
190 >  \r
191 >  --KdquIMZPjGJQvRdI\r
192 >  Content-Type: text/plain; charset=us-ascii\r
193 > +Content-Description: v2 of the selectable usage() stream patch\r
194 >  Content-Disposition: attachment; filename="notmuch-help.patch"\r
195 >  Content-Transfer-Encoding: quoted-printable\r
196 >  \r
197 > diff --git a/test/emacs-show.expected-output/notmuch-show-buttons-content-description b/test/emacs-show.expected-output/notmuch-show-buttons-content-description\r
198 > new file mode 100644\r
199 > index 0000000..622c94e\r
200 > --- /dev/null\r
201 > +++ b/test/emacs-show.expected-output/notmuch-show-buttons-content-description\r
202 > @@ -0,0 +1,84 @@\r
203 > +Lars Kellogg-Stedman <lars@seas.harvard.edu> (2009-11-18) (attachment inbox signed unread)\r
204 > +Subject: [notmuch] "notmuch help" outputs to stderr?\r
205 > + Lars Kellogg-Stedman <lars@seas.harvard.edu> (2009-11-18) (attachment inbox signed)\r
206 > + Subject: Re: [notmuch] "notmuch help" outputs to stderr?\r
207 > + To: notmuch <notmuch@notmuchmail.org>\r
208 > + Date: Tue, 17 Nov 2009 20:01:16 -0500\r
209 > +\r
210 > + [ multipart/mixed ]\r
211 > + [ multipart/signed ]\r
212 > + [ multipart/mixed ]\r
213 > + [ text/plain ]\r
214 > + > I've attached a patch that lets usage() take a FILE * argument so that\r
215 > + > you can output to stderr in response to usage errors, and stdout in\r
216 > + > response to an explicit request.\r
217 > +\r
218 > + Whoops, missed a couple of stderr's in that last patch.  New one\r
219 > + attached.\r
220 > +\r
221 > + [ 4-line signature. Click/Enter to show. ]\r
222 > + [ v2 of the selectable usage() stream patch: text/plain ]\r
223 > + diff --git a/notmuch.c b/notmuch.c\r
224 > + index c47e640..446c810 100644\r
225 > + --- a/notmuch.c\r
226 > + +++ b/notmuch.c\r
227 > + @@ -157,23 +157,23 @@ command_t commands[] = {\r
228 > +  };\r
229 > +\r
230 > +  static void\r
231 > + -usage (void)\r
232 > + +usage (FILE *out)\r
233 > +  {\r
234 > +      command_t *command;\r
235 > +      unsigned int i;\r
236 > +\r
237 > + -    fprintf (stderr, "Usage: notmuch <command> [args...]\n");\r
238 > + -    fprintf (stderr, "\n");\r
239 > + -    fprintf (stderr, "Where <command> and [args...] are as follows:\n");\r
240 > + -    fprintf (stderr, "\n");\r
241 > + +    fprintf (out, "Usage: notmuch <command> [args...]\n");\r
242 > + +    fprintf (out, "\n");\r
243 > + +    fprintf (out, "Where <command> and [args...] are as follows:\n");\r
244 > + +    fprintf (out, "\n");\r
245 > +\r
246 > +      for (i = 0; i < ARRAY_SIZE (commands); i++) {\r
247 > +      command = &commands[i];\r
248 > +\r
249 > + -   fprintf (stderr, "\t%s\t%s\n\n", command->name, command->summary);\r
250 > + +   fprintf (out, "\t%s\t%s\n\n", command->name, command->summary);\r
251 > +      }\r
252 > +\r
253 > + -    fprintf (stderr, "Use \"notmuch help <command>\" for more details on\r
254 > + each command.\n\n");\r
255 > + +    fprintf (out, "Use \"notmuch help <command>\" for more details on each\r
256 > + command.\n\n");\r
257 > +  }\r
258 > +\r
259 > +  static int\r
260 > + @@ -183,8 +183,8 @@ notmuch_help_command (unused (void *ctx), int argc, char\r
261 > + *argv[])\r
262 > +      unsigned int i;\r
263 > +\r
264 > +      if (argc == 0) {\r
265 > + -   fprintf (stderr, "The notmuch mail system.\n\n");\r
266 > + -   usage ();\r
267 > + +   fprintf (stdout, "The notmuch mail system.\n\n");\r
268 > + +   usage (stdout);\r
269 > +      return 0;\r
270 > +      }\r
271 > +\r
272 > + @@ -192,8 +192,8 @@ notmuch_help_command (unused (void *ctx), int argc, char\r
273 > + *argv[])\r
274 > +      command = &commands[i];\r
275 > +\r
276 > +      if (strcmp (argv[0], command->name) == 0) {\r
277 > + -       fprintf (stderr, "Help for \"notmuch %s\":\n\n", argv[0]);\r
278 > + -       fprintf (stderr, "\t%s\t%s\n\n%s\n\n", command->name,\r
279 > + +       fprintf (stdout, "Help for \"notmuch %s\":\n\n", argv[0]);\r
280 > + +       fprintf (stdout, "\t%s\t%s\n\n%s\n\n", command->name,\r
281 > +                   command->summary, command->documentation);\r
282 > +          return 0;\r
283 > +      }\r
284 > + [ application/pgp-signature ]\r
285 > + [ text/plain ]\r
286 > + [ 4-line signature. Click/Enter to show. ]\r
287 > diff --git a/test/emacs-show.expected-output/notmuch-show-buttons-filename b/test/emacs-show.expected-output/notmuch-show-buttons-filename\r
288 > new file mode 100644\r
289 > index 0000000..8fb4d89\r
290 > --- /dev/null\r
291 > +++ b/test/emacs-show.expected-output/notmuch-show-buttons-filename\r
292 > @@ -0,0 +1,74 @@\r
293 > +Lars Kellogg-Stedman <lars@seas.harvard.edu> (2009-11-18) (attachment inbox signed)\r
294 > +Subject: [notmuch] "notmuch help" outputs to stderr?\r
295 > +To: notmuch <notmuch@notmuchmail.org>\r
296 > +Date: Tue, 17 Nov 2009 19:58:29 -0500\r
297 > +\r
298 > +[ multipart/mixed ]\r
299 > +[ multipart/signed ]\r
300 > +[ multipart/mixed ]\r
301 > +[ text/plain ]\r
302 > +I'm just noticing that 'notmuch help ...' outputs to stderr, which\r
303 > +isn't terribly intuitive.  For example, the obvious invocation:\r
304 > +\r
305 > +  notmuch help | less\r
306 > +\r
307 > +...isn't terribly helpful.\r
308 > +\r
309 > +I've attached a patch that lets usage() take a FILE * argument so that\r
310 > +you can output to stderr in response to usage errors, and stdout in\r
311 > +response to an explicit request.\r
312 > +\r
313 > +[ 4-line signature. Click/Enter to show. ]\r
314 > +[ notmuch-help.patch: text/plain ]\r
315 > +diff --git a/notmuch.c b/notmuch.c\r
316 > +index c47e640..a35cb99 100644\r
317 > +--- a/notmuch.c\r
318 > ++++ b/notmuch.c\r
319 > +@@ -157,23 +157,23 @@ command_t commands[] = {\r
320 > + };\r
321 > +\r
322 > + static void\r
323 > +-usage (void)\r
324 > ++usage (FILE *out)\r
325 > + {\r
326 > +     command_t *command;\r
327 > +     unsigned int i;\r
328 > +\r
329 > +-    fprintf (stderr, "Usage: notmuch <command> [args...]\n");\r
330 > +-    fprintf (stderr, "\n");\r
331 > +-    fprintf (stderr, "Where <command> and [args...] are as follows:\n");\r
332 > +-    fprintf (stderr, "\n");\r
333 > ++    fprintf (out, "Usage: notmuch <command> [args...]\n");\r
334 > ++    fprintf (out, "\n");\r
335 > ++    fprintf (out, "Where <command> and [args...] are as follows:\n");\r
336 > ++    fprintf (out, "\n");\r
337 > +\r
338 > +     for (i = 0; i < ARRAY_SIZE (commands); i++) {\r
339 > +     command = &commands[i];\r
340 > +\r
341 > +-    fprintf (stderr, "\t%s\t%s\n\n", command->name, command->summary);\r
342 > ++    fprintf (out, "\t%s\t%s\n\n", command->name, command->summary);\r
343 > +     }\r
344 > +\r
345 > +-    fprintf (stderr, "Use \"notmuch help <command>\" for more details on each\r
346 > +command.\n\n");\r
347 > ++    fprintf (out, "Use \"notmuch help <command>\" for more details on each\r
348 > +command.\n\n");\r
349 > + }\r
350 > +\r
351 > + static int\r
352 > +@@ -183,8 +183,8 @@ notmuch_help_command (unused (void *ctx), int argc, char\r
353 > +*argv[])\r
354 > +     unsigned int i;\r
355 > +\r
356 > +     if (argc == 0) {\r
357 > +-    fprintf (stderr, "The notmuch mail system.\n\n");\r
358 > +-    usage ();\r
359 > ++    fprintf (stdout, "The notmuch mail system.\n\n");\r
360 > ++    usage (stdout);\r
361 > +     return 0;\r
362 > +     }\r
363 > +[ application/pgp-signature ]\r
364 > +[ text/plain ]\r
365 > +[ 4-line signature. Click/Enter to show. ]\r
366 > + Lars Kellogg-Stedman <lars@seas.harvard.edu> (2009-11-18) (attachment inbox signed)\r
367 > -- \r
368 > 1.8.5.2.8.g0f6c0d1\r