--- /dev/null
+Return-Path: <m.walters@qmul.ac.uk>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 8302B431FBC\r
+ for <notmuch@notmuchmail.org>; Mon, 3 Feb 2014 12:19:15 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -1.098\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5\r
+ tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,\r
+ NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id EtXKL1WKyroI for <notmuch@notmuchmail.org>;\r
+ Mon, 3 Feb 2014 12:19:07 -0800 (PST)\r
+Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])\r
+ (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id F1279431FAF\r
+ for <notmuch@notmuchmail.org>; Mon, 3 Feb 2014 12:19:06 -0800 (PST)\r
+Received: from smtp.qmul.ac.uk ([138.37.6.40])\r
+ by mail2.qmul.ac.uk with esmtp (Exim 4.71)\r
+ (envelope-from <m.walters@qmul.ac.uk>)\r
+ id 1WAPyt-00053x-3Z; Mon, 03 Feb 2014 20:19:01 +0000\r
+Received: from 93-97-24-31.zone5.bethere.co.uk ([93.97.24.31] helo=localhost)\r
+ by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71)\r
+ (envelope-from <m.walters@qmul.ac.uk>)\r
+ id 1WAPxV-0004tm-CQ; Mon, 03 Feb 2014 20:17:33 +0000\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: "W. Trevor King" <wking@tremily.us>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH 2/2] emacs: Prefer Content-Description over filename for\r
+ part buttons\r
+In-Reply-To:\r
+ <27be295875a7df782a83c9a2c09d06f9d321fe9e.1391423201.git.wking@tremily.us>\r
+References: <877g9chbay.fsf@qmul.ac.uk>\r
+ <cover.1391423201.git.wking@tremily.us>\r
+ <27be295875a7df782a83c9a2c09d06f9d321fe9e.1391423201.git.wking@tremily.us>\r
+User-Agent: Notmuch/0.15.2+484~gfb59956 (http://notmuchmail.org) Emacs/23.4.1\r
+ (x86_64-pc-linux-gnu)\r
+Date: Mon, 03 Feb 2014 20:15:35 +0000\r
+Message-ID: <87vbwwosuw.fsf@qmul.ac.uk>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+X-Sender-Host-Address: 93.97.24.31\r
+X-QM-Geographic: According to ripencc,\r
+ this message was delivered by a machine in Britain (UK) (GB).\r
+X-QM-SPAM-Info: Sender has good ham record. :)\r
+X-QM-Body-MD5: c539f0f6708f1a6f06009f6f53f85c2d (of first 20000 bytes)\r
+X-SpamAssassin-Score: 0.0\r
+X-SpamAssassin-SpamBar: /\r
+X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
+ determine if it is\r
+ spam. We require at least 5.0 points to mark a message as spam.\r
+ This message scored 0.0 points. Summary of the scoring: \r
+ * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\r
+ provider * (markwalters1009[at]gmail.com)\r
+ * 0.0 AWL AWL: From: address is in the auto white-list\r
+X-QM-Scan-Virus: ClamAV says the message is clean\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 03 Feb 2014 20:19:15 -0000\r
+\r
+\r
+On Mon, 03 Feb 2014, "W. Trevor King" <wking@tremily.us> wrote:\r
+> On the rss2email list, Victor Orlikowski pointed out [1] that a number\r
+> of MUAs don't use the Subject header of attached message/rfc822 parts\r
+> to label multipart/digest subparts [2]. Instead, notmuch and several\r
+> other MUAs use the filename parameter [3] as a content hint. Using\r
+> the filename parameter seems more sane than diving into the\r
+> message/rfc822 part header, but that's still not what the filename\r
+> parameter was designed for. It makes more sense to me to use the\r
+> message/rfc822 part's Content-Description header (which I just taught\r
+> notmuch-show to export), falling back on the filename parameter if\r
+> Content-Description isn't set.\r
+>\r
+> [1]: http://article.gmane.org/gmane.mail.rss2email/211\r
+> [2]: Digests: http://tools.ietf.org/html/rfc2046#section-5.1.5\r
+> [3]: Filename: http://tools.ietf.org/search/rfc2183#section-2.3\r
+\r
+I tried this and it all works. However, I looked through my collection\r
+an I have a lot of emails which have Content-Description headers that\r
+are empty. Thus, I think we should only display/use the\r
+content-description if it exists and is non-empty. Something like\r
+\r
+ (description (plist-get part :content-description))\r
+ (name (if (and description (not (equal description "")))\r
+ description\r
+ (plist-get part :filename)))\r
+\r
+My only other comment on the series is that you should update\r
+devel/schemata in the first patch to reflect this addition.\r
+\r
+Otherwise it looks good to me\r
+\r
+Best wishes\r
+\r
+Mark\r
+\r
+\r
+> ---\r
+> NEWS | 7 ++\r
+> emacs/notmuch-show.el | 4 +-\r
+> test/T450-emacs-show.sh | 12 ++++\r
+> test/corpus/cur/24:2, | 1 +\r
+> .../notmuch-show-buttons-content-description | 84 ++++++++++++++++++++++\r
+> .../notmuch-show-buttons-filename | 74 +++++++++++++++++++\r
+> 6 files changed, 181 insertions(+), 1 deletion(-)\r
+> create mode 100644 test/emacs-show.expected-output/notmuch-show-buttons-content-description\r
+> create mode 100644 test/emacs-show.expected-output/notmuch-show-buttons-filename\r
+>\r
+> diff --git a/NEWS b/NEWS\r
+> index 0f7b1c8..2154872 100644\r
+> --- a/NEWS\r
+> +++ b/NEWS\r
+> @@ -10,6 +10,13 @@ Command-Line Interface\r
+> \r
+> `notmuch show` now includes envelope Content-Description headers.\r
+> \r
+> +Emacs Interface\r
+> +---------------\r
+> +\r
+> +`notmuch-show` mode prefers Content-Description to filename when\r
+> +naming part buttons. This is useful for finding interesting parts of\r
+> +multipart/digest messages, assuming the digest-creator set that field.\r
+> +\r
+> Notmuch 0.17 (2013-12-30)\r
+> =========================\r
+> \r
+> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+> index 1ac80ca..dbff3a8 100644\r
+> --- a/emacs/notmuch-show.el\r
+> +++ b/emacs/notmuch-show.el\r
+> @@ -874,13 +874,15 @@ useful for quoting in replies)."\r
+> content-type))\r
+> (nth (plist-get part :id))\r
+> (beg (point))\r
+> + (name (or (plist-get part :content-description)\r
+> + (plist-get part :filename)))\r
+> ;; Hide the part initially if HIDE is t.\r
+> (show-part (not (equal hide t)))\r
+> ;; We omit the part button for the first (or only) part if\r
+> ;; this is text/plain, or HIDE is 'no-buttons.\r
+> (button (unless (or (equal hide 'no-buttons)\r
+> (and (string= mime-type "text/plain") (<= nth 1)))\r
+> - (notmuch-show-insert-part-header nth mime-type content-type (plist-get part :filename))))\r
+> + (notmuch-show-insert-part-header nth mime-type content-type name)))\r
+> (content-beg (point)))\r
+> \r
+> ;; Store the computed mime-type for later use (e.g. by attachment handlers).\r
+> diff --git a/test/T450-emacs-show.sh b/test/T450-emacs-show.sh\r
+> index 2a3a535..5650f04 100755\r
+> --- a/test/T450-emacs-show.sh\r
+> +++ b/test/T450-emacs-show.sh\r
+> @@ -106,6 +106,18 @@ test_emacs '(notmuch-search "from:lars@seas.harvard.edu and subject:\"Maildir st\r
+> (test-visible-output)'\r
+> test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-indent-thread-content-off\r
+> \r
+> +test_begin_subtest "buttons prefer Content-Description"\r
+> +test_emacs '(let ((notmuch-crypto-process-mime nil))\r
+> + (notmuch-show "id:20091118010116.GC25380@dottiness.seas.harvard.edu")\r
+> + (test-visible-output))'\r
+> +test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-buttons-content-description\r
+> +\r
+> +test_begin_subtest "buttons fallback to filename"\r
+> +test_emacs '(let ((notmuch-crypto-process-mime nil))\r
+> + (notmuch-show "id:20091118005829.GB25380@dottiness.seas.harvard.edu")\r
+> + (test-visible-output))'\r
+> +test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-buttons-filename\r
+> +\r
+> test_begin_subtest "id buttonization"\r
+> add_message '[body]="\r
+> id:abc\r
+> diff --git a/test/corpus/cur/24:2, b/test/corpus/cur/24:2,\r
+> index c800020..f9418d2 100644\r
+> --- a/test/corpus/cur/24:2,\r
+> +++ b/test/corpus/cur/24:2,\r
+> @@ -104,6 +104,7 @@ Harvard University School of Engineering and Applied Sciences\r
+> \r
+> --KdquIMZPjGJQvRdI\r
+> Content-Type: text/plain; charset=us-ascii\r
+> +Content-Description: v2 of the selectable usage() stream patch\r
+> Content-Disposition: attachment; filename="notmuch-help.patch"\r
+> Content-Transfer-Encoding: quoted-printable\r
+> \r
+> 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
+> new file mode 100644\r
+> index 0000000..622c94e\r
+> --- /dev/null\r
+> +++ b/test/emacs-show.expected-output/notmuch-show-buttons-content-description\r
+> @@ -0,0 +1,84 @@\r
+> +Lars Kellogg-Stedman <lars@seas.harvard.edu> (2009-11-18) (attachment inbox signed unread)\r
+> +Subject: [notmuch] "notmuch help" outputs to stderr?\r
+> + Lars Kellogg-Stedman <lars@seas.harvard.edu> (2009-11-18) (attachment inbox signed)\r
+> + Subject: Re: [notmuch] "notmuch help" outputs to stderr?\r
+> + To: notmuch <notmuch@notmuchmail.org>\r
+> + Date: Tue, 17 Nov 2009 20:01:16 -0500\r
+> +\r
+> + [ multipart/mixed ]\r
+> + [ multipart/signed ]\r
+> + [ multipart/mixed ]\r
+> + [ text/plain ]\r
+> + > I've attached a patch that lets usage() take a FILE * argument so that\r
+> + > you can output to stderr in response to usage errors, and stdout in\r
+> + > response to an explicit request.\r
+> +\r
+> + Whoops, missed a couple of stderr's in that last patch. New one\r
+> + attached.\r
+> +\r
+> + [ 4-line signature. Click/Enter to show. ]\r
+> + [ v2 of the selectable usage() stream patch: text/plain ]\r
+> + diff --git a/notmuch.c b/notmuch.c\r
+> + index c47e640..446c810 100644\r
+> + --- a/notmuch.c\r
+> + +++ b/notmuch.c\r
+> + @@ -157,23 +157,23 @@ command_t commands[] = {\r
+> + };\r
+> +\r
+> + static void\r
+> + -usage (void)\r
+> + +usage (FILE *out)\r
+> + {\r
+> + command_t *command;\r
+> + unsigned int i;\r
+> +\r
+> + - fprintf (stderr, "Usage: notmuch <command> [args...]\n");\r
+> + - fprintf (stderr, "\n");\r
+> + - fprintf (stderr, "Where <command> and [args...] are as follows:\n");\r
+> + - fprintf (stderr, "\n");\r
+> + + fprintf (out, "Usage: notmuch <command> [args...]\n");\r
+> + + fprintf (out, "\n");\r
+> + + fprintf (out, "Where <command> and [args...] are as follows:\n");\r
+> + + fprintf (out, "\n");\r
+> +\r
+> + for (i = 0; i < ARRAY_SIZE (commands); i++) {\r
+> + command = &commands[i];\r
+> +\r
+> + - fprintf (stderr, "\t%s\t%s\n\n", command->name, command->summary);\r
+> + + fprintf (out, "\t%s\t%s\n\n", command->name, command->summary);\r
+> + }\r
+> +\r
+> + - fprintf (stderr, "Use \"notmuch help <command>\" for more details on\r
+> + each command.\n\n");\r
+> + + fprintf (out, "Use \"notmuch help <command>\" for more details on each\r
+> + command.\n\n");\r
+> + }\r
+> +\r
+> + static int\r
+> + @@ -183,8 +183,8 @@ notmuch_help_command (unused (void *ctx), int argc, char\r
+> + *argv[])\r
+> + unsigned int i;\r
+> +\r
+> + if (argc == 0) {\r
+> + - fprintf (stderr, "The notmuch mail system.\n\n");\r
+> + - usage ();\r
+> + + fprintf (stdout, "The notmuch mail system.\n\n");\r
+> + + usage (stdout);\r
+> + return 0;\r
+> + }\r
+> +\r
+> + @@ -192,8 +192,8 @@ notmuch_help_command (unused (void *ctx), int argc, char\r
+> + *argv[])\r
+> + command = &commands[i];\r
+> +\r
+> + if (strcmp (argv[0], command->name) == 0) {\r
+> + - fprintf (stderr, "Help for \"notmuch %s\":\n\n", argv[0]);\r
+> + - fprintf (stderr, "\t%s\t%s\n\n%s\n\n", command->name,\r
+> + + fprintf (stdout, "Help for \"notmuch %s\":\n\n", argv[0]);\r
+> + + fprintf (stdout, "\t%s\t%s\n\n%s\n\n", command->name,\r
+> + command->summary, command->documentation);\r
+> + return 0;\r
+> + }\r
+> + [ application/pgp-signature ]\r
+> + [ text/plain ]\r
+> + [ 4-line signature. Click/Enter to show. ]\r
+> diff --git a/test/emacs-show.expected-output/notmuch-show-buttons-filename b/test/emacs-show.expected-output/notmuch-show-buttons-filename\r
+> new file mode 100644\r
+> index 0000000..8fb4d89\r
+> --- /dev/null\r
+> +++ b/test/emacs-show.expected-output/notmuch-show-buttons-filename\r
+> @@ -0,0 +1,74 @@\r
+> +Lars Kellogg-Stedman <lars@seas.harvard.edu> (2009-11-18) (attachment inbox signed)\r
+> +Subject: [notmuch] "notmuch help" outputs to stderr?\r
+> +To: notmuch <notmuch@notmuchmail.org>\r
+> +Date: Tue, 17 Nov 2009 19:58:29 -0500\r
+> +\r
+> +[ multipart/mixed ]\r
+> +[ multipart/signed ]\r
+> +[ multipart/mixed ]\r
+> +[ text/plain ]\r
+> +I'm just noticing that 'notmuch help ...' outputs to stderr, which\r
+> +isn't terribly intuitive. For example, the obvious invocation:\r
+> +\r
+> + notmuch help | less\r
+> +\r
+> +...isn't terribly helpful.\r
+> +\r
+> +I've attached a patch that lets usage() take a FILE * argument so that\r
+> +you can output to stderr in response to usage errors, and stdout in\r
+> +response to an explicit request.\r
+> +\r
+> +[ 4-line signature. Click/Enter to show. ]\r
+> +[ notmuch-help.patch: text/plain ]\r
+> +diff --git a/notmuch.c b/notmuch.c\r
+> +index c47e640..a35cb99 100644\r
+> +--- a/notmuch.c\r
+> ++++ b/notmuch.c\r
+> +@@ -157,23 +157,23 @@ command_t commands[] = {\r
+> + };\r
+> +\r
+> + static void\r
+> +-usage (void)\r
+> ++usage (FILE *out)\r
+> + {\r
+> + command_t *command;\r
+> + unsigned int i;\r
+> +\r
+> +- fprintf (stderr, "Usage: notmuch <command> [args...]\n");\r
+> +- fprintf (stderr, "\n");\r
+> +- fprintf (stderr, "Where <command> and [args...] are as follows:\n");\r
+> +- fprintf (stderr, "\n");\r
+> ++ fprintf (out, "Usage: notmuch <command> [args...]\n");\r
+> ++ fprintf (out, "\n");\r
+> ++ fprintf (out, "Where <command> and [args...] are as follows:\n");\r
+> ++ fprintf (out, "\n");\r
+> +\r
+> + for (i = 0; i < ARRAY_SIZE (commands); i++) {\r
+> + command = &commands[i];\r
+> +\r
+> +- fprintf (stderr, "\t%s\t%s\n\n", command->name, command->summary);\r
+> ++ fprintf (out, "\t%s\t%s\n\n", command->name, command->summary);\r
+> + }\r
+> +\r
+> +- fprintf (stderr, "Use \"notmuch help <command>\" for more details on each\r
+> +command.\n\n");\r
+> ++ fprintf (out, "Use \"notmuch help <command>\" for more details on each\r
+> +command.\n\n");\r
+> + }\r
+> +\r
+> + static int\r
+> +@@ -183,8 +183,8 @@ notmuch_help_command (unused (void *ctx), int argc, char\r
+> +*argv[])\r
+> + unsigned int i;\r
+> +\r
+> + if (argc == 0) {\r
+> +- fprintf (stderr, "The notmuch mail system.\n\n");\r
+> +- usage ();\r
+> ++ fprintf (stdout, "The notmuch mail system.\n\n");\r
+> ++ usage (stdout);\r
+> + return 0;\r
+> + }\r
+> +[ application/pgp-signature ]\r
+> +[ text/plain ]\r
+> +[ 4-line signature. Click/Enter to show. ]\r
+> + Lars Kellogg-Stedman <lars@seas.harvard.edu> (2009-11-18) (attachment inbox signed)\r
+> -- \r
+> 1.8.5.2.8.g0f6c0d1\r