]> granicus.if.org Git - neomutt/commitdiff
format: support optional modifier for g (notmuch labels)
authorDavid Sterba <dsterba@suse.cz>
Sat, 1 Sep 2012 07:31:54 +0000 (09:31 +0200)
committerRichard Russon <rich@flatcap.org>
Mon, 4 Apr 2016 15:30:06 +0000 (16:30 +0100)
Used in index_format like this %?g?(%g)? will show nothing if there are
no notmuch labels, eg. in mixed mail setups.

Signed-off-by: David Sterba <dsterba@suse.cz>
hdrline.c
init.h

index 1b27d4637c6bb62e5259c63db1562ccba7f8e5ae..50f2966d984c006c3508bd2f6a77b5fc30265081 100644 (file)
--- a/hdrline.c
+++ b/hdrline.c
@@ -591,7 +591,10 @@ hdr_format_str (char *dest,
       break;
 #ifdef USE_NOTMUCH
     case 'g':
-      mutt_format_s (dest, destlen, prefix, nm_header_get_tags(hdr));
+      if (!optional)
+        mutt_format_s (dest, destlen, prefix, nm_header_get_tags(hdr));
+      else if (!nm_header_get_tags(hdr))
+        optional = 0;
       break;
 #endif
     case 'H':
diff --git a/init.h b/init.h
index 9145100ec233f36cd1483836a457c00118fc0618..50f93a846a163ed305fd0298d0f843f89efbb471 100644 (file)
--- a/init.h
+++ b/init.h
@@ -1316,6 +1316,7 @@ struct option_t MuttVars[] = {
   ** .dt %E .dd number of messages in current thread
   ** .dt %f .dd sender (address + real name), either From: or Return-Path:
   ** .dt %F .dd author name, or recipient name if the message is from you
+  ** .dt %g .dd message labels (e.g. notmuch tags)
   ** .dt %H .dd spam attribute(s) of this message
   ** .dt %i .dd message-id of the current message
   ** .dt %l .dd number of lines in the message (does not work with maildir,