From a3aa28265dbb1a3406c3bb19e93e71f83058a4ac Mon Sep 17 00:00:00 2001 From: David Sterba Date: Sat, 1 Sep 2012 09:31:54 +0200 Subject: [PATCH] format: support optional modifier for g (notmuch labels) 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 --- hdrline.c | 5 ++++- init.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/hdrline.c b/hdrline.c index 1b27d4637..50f2966d9 100644 --- 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 9145100ec..50f93a846 100644 --- 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, -- 2.50.1