From 6be374b7e8d2b1d794b05836493ddf62dd9b427e Mon Sep 17 00:00:00 2001 From: Kevin Decherf Date: Fri, 17 Mar 2017 03:34:20 +0100 Subject: [PATCH] index_format: add support of %K (#452) Unlike %B, %K will remain empty if there is no list detected for the message. Signed-off-by: Kevin Decherf --- hdrline.c | 11 ++++++++++- init.h | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/hdrline.c b/hdrline.c index 3e90bbfe0fb..5e38a3083e2 100644 --- a/hdrline.c +++ b/hdrline.c @@ -420,7 +420,7 @@ static char *apply_subject_mods (ENVELOPE *env) /* %a = address of author * %A = reply-to address (if present; otherwise: address of author * %b = filename of the originating folder - * %B = the list to which the letter was sent + * %B = the list to which the letter was sent, or else the folder name (%b). * %c = size of message in bytes * %C = current message number * %d = date and time of message using $date_format and sender's timezone @@ -433,6 +433,7 @@ static char *apply_subject_mods (ENVELOPE *env) * %g = message labels (e.g. notmuch tags) * %i = message-id * %I = initials of author + * %K = the list to which the letter was sent (if any; otherwise: empty) * %l = number of lines in the message * %L = like %F, except `lists' are displayed first * %m = number of messages in the mailbox @@ -524,6 +525,7 @@ hdr_format_str (char *dest, break; case 'B': + case 'K': if (!first_mailing_list (dest, destlen, hdr->env->to) && !first_mailing_list (dest, destlen, hdr->env->cc)) dest[0] = 0; @@ -533,6 +535,13 @@ hdr_format_str (char *dest, mutt_format_s (dest, destlen, prefix, buf2); break; } + if (op == 'K') + { + if (optional) + optional = 0; + /* break if 'K' returns nothing */ + break; + } /* fall through if 'B' returns nothing */ case 'b': diff --git a/init.h b/init.h index 4980957118e..11ea140b048 100644 --- a/init.h +++ b/init.h @@ -1460,6 +1460,7 @@ struct option_t MuttVars[] = { ** .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 %K .dd the list to which the letter was sent (if any; otherwise: empty). ** .dt %l .dd number of lines in the message (does not work with maildir, ** mh, and possibly IMAP folders) ** .dt %L .dd If an address in the ``To:'' or ``Cc:'' header field matches an address