Split lines confuse `notmuch count --batch`, so we remove embedded
newlines before calling notmuch count.
+`notmuch-show` mode prefers Content-Description to filename when
+naming part buttons. This is useful for finding interesting parts of
+multipart/digest messages, assuming the digest-creator set that field.
+
Notmuch 0.17 (2013-12-30)
=========================
content-type))
(nth (plist-get part :id))
(beg (point))
+ (name (or (plist-get part :content-description)
+ (plist-get part :filename)))
;; Hide the part initially if HIDE is t.
(show-part (not (equal hide t)))
;; We omit the part button for the first (or only) part if
;; this is text/plain, or HIDE is 'no-buttons.
(button (unless (or (equal hide 'no-buttons)
(and (string= mime-type "text/plain") (<= nth 1)))
- (notmuch-show-insert-part-header nth mime-type content-type (plist-get part :filename))))
+ (notmuch-show-insert-part-header nth mime-type content-type name)))
(content-beg (point)))
;; Store the computed mime-type for later use (e.g. by attachment handlers).
(test-visible-output)'
test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-indent-thread-content-off
+test_begin_subtest "buttons prefer Content-Description"
+test_emacs '(let ((notmuch-crypto-process-mime nil))
+ (notmuch-show "id:20091118010116.GC25380@dottiness.seas.harvard.edu")
+ (test-visible-output))'
+test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-buttons-content-description
+
+test_begin_subtest "buttons fallback to filename"
+test_emacs '(let ((notmuch-crypto-process-mime nil))
+ (notmuch-show "id:20091118005829.GB25380@dottiness.seas.harvard.edu")
+ (test-visible-output))'
+test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-buttons-filename
+
test_begin_subtest "id buttonization"
add_message '[body]="
id:abc
--KdquIMZPjGJQvRdI
Content-Type: text/plain; charset=us-ascii
+Content-Description: v2 of the selectable usage() stream patch
Content-Disposition: attachment; filename="notmuch-help.patch"
Content-Transfer-Encoding: quoted-printable
--- /dev/null
+Lars Kellogg-Stedman <lars@seas.harvard.edu> (2009-11-18) (attachment inbox signed unread)
+Subject: [notmuch] "notmuch help" outputs to stderr?
+ Lars Kellogg-Stedman <lars@seas.harvard.edu> (2009-11-18) (attachment inbox signed)
+ Subject: Re: [notmuch] "notmuch help" outputs to stderr?
+ To: notmuch <notmuch@notmuchmail.org>
+ Date: Tue, 17 Nov 2009 20:01:16 -0500
+
+ [ multipart/mixed ]
+ [ multipart/signed ]
+ [ multipart/mixed ]
+ [ text/plain ]
+ > I've attached a patch that lets usage() take a FILE * argument so that
+ > you can output to stderr in response to usage errors, and stdout in
+ > response to an explicit request.
+
+ Whoops, missed a couple of stderr's in that last patch. New one
+ attached.
+
+ [ 4-line signature. Click/Enter to show. ]
+ [ v2 of the selectable usage() stream patch: text/plain ]
+ diff --git a/notmuch.c b/notmuch.c
+ index c47e640..446c810 100644
+ --- a/notmuch.c
+ +++ b/notmuch.c
+ @@ -157,23 +157,23 @@ command_t commands[] = {
+ };
+
+ static void
+ -usage (void)
+ +usage (FILE *out)
+ {
+ command_t *command;
+ unsigned int i;
+
+ - fprintf (stderr, "Usage: notmuch <command> [args...]\n");
+ - fprintf (stderr, "\n");
+ - fprintf (stderr, "Where <command> and [args...] are as follows:\n");
+ - fprintf (stderr, "\n");
+ + fprintf (out, "Usage: notmuch <command> [args...]\n");
+ + fprintf (out, "\n");
+ + fprintf (out, "Where <command> and [args...] are as follows:\n");
+ + fprintf (out, "\n");
+
+ for (i = 0; i < ARRAY_SIZE (commands); i++) {
+ command = &commands[i];
+
+ - fprintf (stderr, "\t%s\t%s\n\n", command->name, command->summary);
+ + fprintf (out, "\t%s\t%s\n\n", command->name, command->summary);
+ }
+
+ - fprintf (stderr, "Use \"notmuch help <command>\" for more details on
+ each command.\n\n");
+ + fprintf (out, "Use \"notmuch help <command>\" for more details on each
+ command.\n\n");
+ }
+
+ static int
+ @@ -183,8 +183,8 @@ notmuch_help_command (unused (void *ctx), int argc, char
+ *argv[])
+ unsigned int i;
+
+ if (argc == 0) {
+ - fprintf (stderr, "The notmuch mail system.\n\n");
+ - usage ();
+ + fprintf (stdout, "The notmuch mail system.\n\n");
+ + usage (stdout);
+ return 0;
+ }
+
+ @@ -192,8 +192,8 @@ notmuch_help_command (unused (void *ctx), int argc, char
+ *argv[])
+ command = &commands[i];
+
+ if (strcmp (argv[0], command->name) == 0) {
+ - fprintf (stderr, "Help for \"notmuch %s\":\n\n", argv[0]);
+ - fprintf (stderr, "\t%s\t%s\n\n%s\n\n", command->name,
+ + fprintf (stdout, "Help for \"notmuch %s\":\n\n", argv[0]);
+ + fprintf (stdout, "\t%s\t%s\n\n%s\n\n", command->name,
+ command->summary, command->documentation);
+ return 0;
+ }
+ [ application/pgp-signature ]
+ [ text/plain ]
+ [ 4-line signature. Click/Enter to show. ]
--- /dev/null
+Lars Kellogg-Stedman <lars@seas.harvard.edu> (2009-11-18) (attachment inbox signed)
+Subject: [notmuch] "notmuch help" outputs to stderr?
+To: notmuch <notmuch@notmuchmail.org>
+Date: Tue, 17 Nov 2009 19:58:29 -0500
+
+[ multipart/mixed ]
+[ multipart/signed ]
+[ multipart/mixed ]
+[ text/plain ]
+I'm just noticing that 'notmuch help ...' outputs to stderr, which
+isn't terribly intuitive. For example, the obvious invocation:
+
+ notmuch help | less
+
+...isn't terribly helpful.
+
+I've attached a patch that lets usage() take a FILE * argument so that
+you can output to stderr in response to usage errors, and stdout in
+response to an explicit request.
+
+[ 4-line signature. Click/Enter to show. ]
+[ notmuch-help.patch: text/plain ]
+diff --git a/notmuch.c b/notmuch.c
+index c47e640..a35cb99 100644
+--- a/notmuch.c
++++ b/notmuch.c
+@@ -157,23 +157,23 @@ command_t commands[] = {
+ };
+
+ static void
+-usage (void)
++usage (FILE *out)
+ {
+ command_t *command;
+ unsigned int i;
+
+- fprintf (stderr, "Usage: notmuch <command> [args...]\n");
+- fprintf (stderr, "\n");
+- fprintf (stderr, "Where <command> and [args...] are as follows:\n");
+- fprintf (stderr, "\n");
++ fprintf (out, "Usage: notmuch <command> [args...]\n");
++ fprintf (out, "\n");
++ fprintf (out, "Where <command> and [args...] are as follows:\n");
++ fprintf (out, "\n");
+
+ for (i = 0; i < ARRAY_SIZE (commands); i++) {
+ command = &commands[i];
+
+- fprintf (stderr, "\t%s\t%s\n\n", command->name, command->summary);
++ fprintf (out, "\t%s\t%s\n\n", command->name, command->summary);
+ }
+
+- fprintf (stderr, "Use \"notmuch help <command>\" for more details on each
+command.\n\n");
++ fprintf (out, "Use \"notmuch help <command>\" for more details on each
+command.\n\n");
+ }
+
+ static int
+@@ -183,8 +183,8 @@ notmuch_help_command (unused (void *ctx), int argc, char
+*argv[])
+ unsigned int i;
+
+ if (argc == 0) {
+- fprintf (stderr, "The notmuch mail system.\n\n");
+- usage ();
++ fprintf (stdout, "The notmuch mail system.\n\n");
++ usage (stdout);
+ return 0;
+ }
+[ application/pgp-signature ]
+[ text/plain ]
+[ 4-line signature. Click/Enter to show. ]
+ Lars Kellogg-Stedman <lars@seas.harvard.edu> (2009-11-18) (attachment inbox signed)