From: x3nb63 <25959223+x3nb63@users.noreply.github.com> Date: Fri, 27 Jul 2018 18:42:50 +0000 (+0200) Subject: add %Fp expando for plain from address X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7eeee8d4cb75bbaf6a76c653fc27ba13dc700a10;p=neomutt add %Fp expando for plain from address --- diff --git a/format_flags.h b/format_flags.h index 9a8299ea8..35213f3b2 100644 --- a/format_flags.h +++ b/format_flags.h @@ -37,7 +37,8 @@ enum FormatFlag MUTT_FORMAT_STAT_FILE = (1 << 4), /**< used by attach_format_str */ MUTT_FORMAT_ARROWCURSOR = (1 << 5), /**< reserve space for arrow_cursor */ MUTT_FORMAT_INDEX = (1 << 6), /**< this is a main index entry */ - MUTT_FORMAT_NOFILTER = (1 << 7) /**< do not allow filtering on this pass */ + MUTT_FORMAT_NOFILTER = (1 << 7), /**< do not allow filtering on this pass */ + MUTT_FORMAT_PLAIN = (1 << 8), /**< do not prepend DISP_TO, DISP_CC ... */ }; /** diff --git a/hdrline.c b/hdrline.c index f1178ccee..d4782e173 100644 --- a/hdrline.c +++ b/hdrline.c @@ -213,6 +213,7 @@ enum FieldType DISP_CC, DISP_BCC, DISP_FROM, + DISP_PLAIN, DISP_NUM }; @@ -250,10 +251,8 @@ static const char *make_from_prefix(enum FieldType disp) /* need 2 bytes at the end, one for the space, another for NUL */ static char padded[8]; static const char *long_prefixes[DISP_NUM] = { - [DISP_TO] = "To ", - [DISP_CC] = "Cc ", - [DISP_BCC] = "Bcc ", - [DISP_FROM] = "", + [DISP_TO] = "To ", [DISP_CC] = "Cc ", [DISP_BCC] = "Bcc ", + [DISP_FROM] = "", [DISP_PLAIN] = "", }; if (!FromChars || !FromChars->chars || (FromChars->len == 0)) @@ -280,7 +279,8 @@ static const char *make_from_prefix(enum FieldType disp) * The field can optionally be prefixed by a character from $from_chars. * If $from_chars is not set, the prefix will be, "To", "Cc", etc */ -static void make_from(struct Envelope *env, char *buf, size_t buflen, bool do_lists) +static void make_from(struct Envelope *env, char *buf, size_t buflen, + bool do_lists, enum FormatFlag flags) { if (!env || !buf) return; @@ -301,7 +301,7 @@ static void make_from(struct Envelope *env, char *buf, size_t buflen, bool do_li if (me && env->to) { - disp = DISP_TO; + disp = (flags & MUTT_FORMAT_PLAIN) ? DISP_PLAIN : DISP_TO; name = env->to; } else if (me && env->cc) @@ -480,6 +480,7 @@ static bool thread_is_old(struct Context *ctx, struct Email *e) * | \%e | Current message number in thread * | \%E | Number of messages in current thread * | \%F | Author name, or recipient name if the message is from you + * | \%Fp | Like %F, but plain. No contextual formatting is applied to recipient name * | \%f | Sender (address + real name), either From: or Return-Path: * | \%g | Message tags (e.g. notmuch tags/imap flags) * | \%Gx | Individual message tag (e.g. notmuch tags/imap flags) @@ -845,13 +846,19 @@ static const char *index_format_str(char *buf, size_t buflen, size_t col, int co case 'F': if (!optional) { + const bool is_plain = (src[0] == 'p'); colorlen = add_index_color(buf, buflen, flags, MT_COLOR_INDEX_AUTHOR); - make_from(e->env, tmp, sizeof(tmp), false); + make_from(e->env, tmp, sizeof(tmp), false, (is_plain ? MUTT_FORMAT_PLAIN : 0)); mutt_format_s(buf + colorlen, buflen - colorlen, prec, tmp); add_index_color(buf + colorlen, buflen - colorlen, flags, MT_COLOR_INDEX); + + if (is_plain) + src++; } else if (mutt_addr_is_user(e->env->from)) + { optional = 0; + } break; case 'g': @@ -975,7 +982,7 @@ static const char *index_format_str(char *buf, size_t buflen, size_t col, int co if (!optional) { colorlen = add_index_color(buf, buflen, flags, MT_COLOR_INDEX_AUTHOR); - make_from(e->env, tmp, sizeof(tmp), true); + make_from(e->env, tmp, sizeof(tmp), true, flags); mutt_format_s(buf + colorlen, buflen - colorlen, prec, tmp); add_index_color(buf + colorlen, buflen - colorlen, flags, MT_COLOR_INDEX); } diff --git a/hook.c b/hook.c index a46ab5e0f..26b719a99 100644 --- a/hook.c +++ b/hook.c @@ -502,7 +502,7 @@ static int addr_hook(char *path, size_t pathlen, int type, struct Context *ctx, if ((mutt_pattern_exec(hook->pattern, 0, ctx, e, &cache) > 0) ^ hook->regex.not) { - mutt_make_string(path, pathlen, hook->command, ctx, e); + mutt_make_string_flags(path, pathlen, hook->command, ctx, e, MUTT_FORMAT_PLAIN); return 0; } } diff --git a/init.h b/init.h index 69263e1bf..13b85fb03 100644 --- a/init.h +++ b/init.h @@ -1628,6 +1628,7 @@ struct ConfigDef MuttVars[] = { ** .dt %e .dd Current message number in thread ** .dt %E .dd Number of messages in current thread ** .dt %F .dd Author name, or recipient name if the message is from you + ** .dt %Fp .dd Like %F, but plain. No contextual formatting is applied to recipient name ** .dt %f .dd Sender (address + real name), either From: or Return-Path: ** .dt %g .dd Newsgroup name (if compiled with NNTP support) ** .dt %g .dd Message tags (e.g. notmuch tags/imap flags)