From 2f35d2fdb99de2f35453a2f73a64a8702f35640a Mon Sep 17 00:00:00 2001 From: Kevin McCarthy Date: Sat, 19 Nov 2022 13:20:25 -0800 Subject: Reset header color after mutt_set_flag(). I partially changed this to lazily update after a thread update in commit c9fa0414, but unfortunately didn't investigate the reason for the color update while setting a flag. Since it was that way, I assumed it was for a purpose. However, it turns out there is no need to actively set the header color in that function. Many places in Mutt already simply reset the color values to 0 to invalidate and cause a recheck later. Setting the color there so can even be detrimental, if the user has slow 'color index' lines. For example doing a ~A will cause the color to be computed for the *entire* mailbox. Now, the user ought to not have a slow color index line, but if they do, this causes unnecessary pain. Note that the header->color doesn't have an actual "unset" value, which could also help performance. Maybe in the future in master branch. --- flags.c | 14 ++++---------- mutt.h | 1 - protos.h | 2 +- score.c | 9 +++------ 4 files changed, 8 insertions(+), 18 deletions(-) diff --git a/flags.c b/flags.c index 5b016559..bc76a3a6 100644 --- a/flags.c +++ b/flags.c @@ -33,7 +33,6 @@ void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag, int bf, int upd_flags) int tagged = ctx->tagged; int flagged = ctx->flagged; int upd_ctx = (upd_flags & MUTT_SET_FLAG_UPDATE_CONTEXT); - int upd_color = (upd_flags & MUTT_SET_FLAG_UPDATE_COLOR); int update = 0; if (ctx->readonly && flag != MUTT_TAG) @@ -274,13 +273,8 @@ void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag, int bf, int upd_flags) if (update) { - if (upd_color) - mutt_set_header_color (ctx, h); - else - { - h->color.pair = 0; - h->color.attrs = 0; - } + h->color.pair = 0; + h->color.attrs = 0; #ifdef USE_SIDEBAR mutt_set_current_menu_redraw (REDRAW_SIDEBAR); #endif @@ -326,7 +320,7 @@ int mutt_thread_set_flag (HEADER *hdr, int flag, int bf, int subthread) */ if (cur->message) { - _mutt_set_flag (Context, cur->message, flag, bf, MUTT_SET_FLAG_UPDATE_CONTEXT); + mutt_set_flag (Context, cur->message, flag, bf); cur->message->color.pair = cur->message->color.attrs = 0; } @@ -337,7 +331,7 @@ int mutt_thread_set_flag (HEADER *hdr, int flag, int bf, int subthread) { if (cur->message) { - _mutt_set_flag (Context, cur->message, flag, bf, MUTT_SET_FLAG_UPDATE_CONTEXT); + mutt_set_flag (Context, cur->message, flag, bf); cur->message->color.pair = cur->message->color.attrs = 0; } diff --git a/mutt.h b/mutt.h index bb29e7a6..2946c78b 100644 --- a/mutt.h +++ b/mutt.h @@ -383,7 +383,6 @@ enum /* flags for _mutt_set_flag() */ #define MUTT_SET_FLAG_UPDATE_CONTEXT (1<<0) -#define MUTT_SET_FLAG_UPDATE_COLOR (1<<1) /* flags for _mutt_buffer_expand_path() */ #define MUTT_EXPAND_PATH_RX (1<<0) diff --git a/protos.h b/protos.h index b8f83b26..a055d1a2 100644 --- a/protos.h +++ b/protos.h @@ -275,7 +275,7 @@ void _mutt_buffer_select_file (BUFFER *, int, char ***, int *); void mutt_message_hook (CONTEXT *, HEADER *, int); void mutt_reset_child_signals (void); void _mutt_set_flag (CONTEXT *, HEADER *, int, int, int); -#define mutt_set_flag(a,b,c,d) _mutt_set_flag(a,b,c,d,MUTT_SET_FLAG_UPDATE_CONTEXT|MUTT_SET_FLAG_UPDATE_COLOR) +#define mutt_set_flag(a,b,c,d) _mutt_set_flag(a,b,c,d,MUTT_SET_FLAG_UPDATE_CONTEXT) void mutt_shell_escape (void); void mutt_show_error (void); void mutt_signal_init (void); diff --git a/score.c b/score.c index 338d73fb..3adf39db 100644 --- a/score.c +++ b/score.c @@ -159,16 +159,13 @@ void mutt_score_message (CONTEXT *ctx, HEADER *hdr, int upd_ctx) if (hdr->score <= ScoreThresholdDelete) _mutt_set_flag (ctx, hdr, MUTT_DELETE, 1, - (upd_ctx ? MUTT_SET_FLAG_UPDATE_CONTEXT : 0) | - MUTT_SET_FLAG_UPDATE_COLOR); + upd_ctx ? MUTT_SET_FLAG_UPDATE_CONTEXT : 0); if (hdr->score <= ScoreThresholdRead) _mutt_set_flag (ctx, hdr, MUTT_READ, 1, - (upd_ctx ? MUTT_SET_FLAG_UPDATE_CONTEXT : 0) | - MUTT_SET_FLAG_UPDATE_COLOR); + upd_ctx ? MUTT_SET_FLAG_UPDATE_CONTEXT : 0); if (hdr->score >= ScoreThresholdFlag) _mutt_set_flag (ctx, hdr, MUTT_FLAG, 1, - (upd_ctx ? MUTT_SET_FLAG_UPDATE_CONTEXT : 0) | - MUTT_SET_FLAG_UPDATE_COLOR); + upd_ctx ? MUTT_SET_FLAG_UPDATE_CONTEXT : 0); } int mutt_parse_unscore (BUFFER *buf, BUFFER *s, union pointer_long_t udata, BUFFER *err) -- cgit v1.2.3