From: Anton Lindqvist Date: Fri, 29 Jun 2018 03:17:23 +0000 (-0700) Subject: Add check-stats function to calculate mailbox statistics. X-Git-Tag: mutt-1-11-rel~125 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ac7e28906c1c55f98a955f58367734801e4d26e5;p=mutt Add check-stats function to calculate mailbox statistics. This allows the statistics to be updated without setting $mail_check_stats or before $mail_check_stats_interval has passed. --- diff --git a/OPS b/OPS index 679f5dbd..c0c95806 100644 --- a/OPS +++ b/OPS @@ -181,6 +181,7 @@ OP_VERSION "show the Mutt version number and date" OP_VIEW_ATTACH "view attachment using mailcap entry if necessary" OP_VIEW_ATTACHMENTS "show MIME attachments" OP_WHAT_KEY "display the keycode for a key press" +OP_CHECK_STATS "calculate message statistics for all mailboxes" OP_MAIN_SHOW_LIMIT "show currently active limit pattern" OP_MAIN_COLLAPSE_THREAD "collapse/uncollapse current thread" OP_MAIN_COLLAPSE_ALL "collapse/uncollapse all threads" diff --git a/buffy.c b/buffy.c index eab17e6e..6d7fbe56 100644 --- a/buffy.c +++ b/buffy.c @@ -505,7 +505,9 @@ static int buffy_mbox_check (BUFFY* mailbox, struct stat *sb, int check_stats) } /* Check all Incoming for new mail and total/new/flagged messages - * force: if true, ignore BuffyTimeout and check for new mail anyway + * The force argument may be any combination of the following values: + * MUTT_BUFFY_CHECK_FORCE ignore BuffyTimeout and check for new mail + * MUTT_BUFFY_CHECK_FORCE_STATS ignore BuffyTimeout and calculate statistics */ int mutt_buffy_check (int force) { @@ -525,7 +527,7 @@ int mutt_buffy_check (int force) #ifdef USE_IMAP /* update postponed count as well, on force */ - if (force) + if (force & MUTT_BUFFY_CHECK_FORCE) mutt_update_num_postponed (); #endif @@ -536,8 +538,9 @@ int mutt_buffy_check (int force) if (!force && (t - BuffyTime < BuffyTimeout)) return BuffyCount; - if (option (OPTMAILCHECKSTATS) && - (t - BuffyStatsTime >= BuffyCheckStatsInterval)) + if ((force & MUTT_BUFFY_CHECK_FORCE_STATS) || + (option (OPTMAILCHECKSTATS) && + (t - BuffyStatsTime >= BuffyCheckStatsInterval))) { check_stats = 1; BuffyStatsTime = t; @@ -744,7 +747,8 @@ void mutt_buffy (char *s, size_t slen) found = 1; } - mutt_buffy_check (1); /* buffy was wrong - resync things */ + mutt_buffy_check (MUTT_BUFFY_CHECK_FORCE); /* buffy was wrong - resync + things */ } /* no folders with new mail */ diff --git a/buffy.h b/buffy.h index c0cfddf4..aecad530 100644 --- a/buffy.h +++ b/buffy.h @@ -63,4 +63,8 @@ void mutt_buffy_setnotified (const char *path); int mh_buffy (BUFFY *, int); +/* force flags passed to mutt_buffy_check() */ +#define MUTT_BUFFY_CHECK_FORCE 1 +#define MUTT_BUFFY_CHECK_FORCE_STATS (1<<1) + #endif /* _BUFFY_H */ diff --git a/commands.c b/commands.c index 3654fc0d..cd65a0d2 100644 --- a/commands.c +++ b/commands.c @@ -1028,4 +1028,7 @@ int mutt_check_traditional_pgp (HEADER *h, int *redraw) return rv; } - +void mutt_check_stats (void) +{ + mutt_buffy_check (MUTT_BUFFY_CHECK_FORCE | MUTT_BUFFY_CHECK_FORCE_STATS); +} diff --git a/curs_main.c b/curs_main.c index c149d4a9..703a0660 100644 --- a/curs_main.c +++ b/curs_main.c @@ -579,8 +579,10 @@ int mutt_index_menu (void) menu->custom_menu_redraw = index_menu_redraw; mutt_push_current_menu (menu); - if (!attach_msg) - mutt_buffy_check(1); /* force the buffy check after we enter the folder */ + if (!attach_msg) { + mutt_buffy_check(MUTT_BUFFY_CHECK_FORCE); /* force the buffy check after we + enter the folder */ + } #ifdef USE_INOTIFY mutt_monitor_add (NULL); #endif @@ -1339,8 +1341,9 @@ int mutt_index_menu (void) #endif mutt_clear_error (); - mutt_buffy_check(1); /* force the buffy check after we have changed - the folder */ + mutt_buffy_check(MUTT_BUFFY_CHECK_FORCE); /* force the buffy check after + we have changed the + folder */ menu->redraw = REDRAW_FULL; set_option (OPTSEARCHINVALID); break; @@ -2467,6 +2470,10 @@ int mutt_index_menu (void) mutt_what_key(); break; + case OP_CHECK_STATS: + mutt_check_stats(); + break; + #ifdef USE_SIDEBAR case OP_SIDEBAR_NEXT: case OP_SIDEBAR_NEXT_NEW: diff --git a/doc/manual.xml.head b/doc/manual.xml.head index 8ac8fd9d..38ff9425 100644 --- a/doc/manual.xml.head +++ b/doc/manual.xml.head @@ -953,6 +953,20 @@ In addition, the index and + + +<check-stats> + + + +Calculate statistics for all monitored mailboxes declared using the +mailboxes command. +It will calculate statistics despite +$mail_check_stats being unset. + + + + <create-alias> diff --git a/functions.h b/functions.h index 95d00d8b..442531ad 100644 --- a/functions.h +++ b/functions.h @@ -80,6 +80,7 @@ const struct binding_t OpGeneric[] = { /* map: generic */ { "current-bottom", OP_CURRENT_BOTTOM, NULL }, { "error-history", OP_ERROR_HISTORY, NULL }, { "what-key", OP_WHAT_KEY, NULL }, + { "check-stats", OP_CHECK_STATS, NULL }, { NULL, 0, NULL } }; @@ -290,6 +291,7 @@ const struct binding_t OpPager[] = { /* map: pager */ { "decrypt-save", OP_DECRYPT_SAVE, NULL }, { "what-key", OP_WHAT_KEY, NULL }, + { "check-stats", OP_CHECK_STATS, NULL }, #ifdef USE_SIDEBAR { "sidebar-next", OP_SIDEBAR_NEXT, NULL }, diff --git a/init.h b/init.h index 9fcae45d..a2ac91aa 100644 --- a/init.h +++ b/init.h @@ -1546,6 +1546,10 @@ struct option_t MuttVars[] = { ** this operation is more performance intensive, it defaults to ** \fIunset\fP, and has a separate option, $$mail_check_stats_interval, to ** control how often to update these counts. + ** .pp + ** Message statistics can also be explicitly calculated by invoking the + ** \fC\fP + ** function. */ { "mail_check_stats_interval", DT_NUM, R_NONE, UL &BuffyCheckStatsInterval, 60 }, /* diff --git a/menu.c b/menu.c index dd7fad03..b9031935 100644 --- a/menu.c +++ b/menu.c @@ -1195,6 +1195,10 @@ int mutt_menuLoop (MUTTMENU *menu) mutt_what_key (); break; + case OP_CHECK_STATS: + mutt_check_stats (); + break; + case OP_REDRAW: clearok (stdscr, TRUE); menu->redraw = REDRAW_FULL; diff --git a/pager.c b/pager.c index 5419fa27..ab3d4ade 100644 --- a/pager.c +++ b/pager.c @@ -2884,6 +2884,10 @@ search_next: mutt_what_key (); break; + case OP_CHECK_STATS: + mutt_check_stats (); + break; + #ifdef USE_SIDEBAR case OP_SIDEBAR_NEXT: case OP_SIDEBAR_NEXT_NEW: diff --git a/protos.h b/protos.h index 432304e5..67d3ae80 100644 --- a/protos.h +++ b/protos.h @@ -178,6 +178,7 @@ void mutt_break_thread (HEADER *); void mutt_buffy (char *, size_t); int mutt_buffy_list (void); void mutt_canonical_charset (char *, size_t, const char *); +void mutt_check_stats(void); int mutt_count_body_parts (CONTEXT *, HEADER *); void mutt_check_rescore (CONTEXT *); void mutt_clear_error (void);