From: Stefan Assmann Date: Mon, 8 Aug 2016 12:41:44 +0000 (+0200) Subject: check for new mail while in pager when idle X-Git-Tag: neomutt-20160910~19 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4ed2b6f0f8e69b61c9e872ad9322bdc6f326ce5f;p=neomutt check for new mail while in pager when idle Currently, when the pager is open and mutt is idle the mailboxes aren't checked for new mails. Change the behaviour to get notified of newly arrived mail. Closes #19 - new-mail doesn't fire if pager open Closes #100 - check for new mail while in pager when idle --- diff --git a/curs_main.c b/curs_main.c index a1ad012ba..3bc2fbbdf 100644 --- a/curs_main.c +++ b/curs_main.c @@ -358,7 +358,7 @@ static int mx_toggle_write (CONTEXT *ctx) return 0; } -static void update_index (MUTTMENU *menu, CONTEXT *ctx, int check, +void update_index (MUTTMENU *menu, CONTEXT *ctx, int check, int oldcount, int index_hint) { /* store pointers to the newly added messages */ diff --git a/pager.c b/pager.c index 82858c6f2..1c759300b 100644 --- a/pager.c +++ b/pager.c @@ -29,6 +29,7 @@ #include "pager.h" #include "attach.h" #include "mbyte.h" +#include "mailbox.h" #ifdef USE_SIDEBAR #include "sidebar.h" #endif @@ -1622,6 +1623,9 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) int indicator = indexlen / 3; /* the indicator line of the PI */ int old_PagerIndexLines; /* some people want to resize it * while inside the pager... */ + int index_hint = 0; /* used to restore cursor position */ + int oldcount = -1; + int check; #ifdef USE_NNTP char *followup_to; @@ -1945,6 +1949,40 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) mutt_clear_error (); mutt_curs_set (1); + if (Context && !option (OPTATTACHMSG)) + { + /* check for new mail */ + check = mx_check_mailbox (Context, &index_hint); + if (check < 0) + { + if (!Context->path) + { + /* fatal error occurred */ + FREE (&Context); + redraw = REDRAW_FULL; + ch = -1; + } + } + else if ((check == MUTT_NEW_MAIL) || (check == MUTT_REOPENED) || (check == MUTT_FLAGS)) + { + oldcount = Context ? Context->msgcount : 0; + update_index (index, Context, check, oldcount, index_hint); + } + /* notify user of newly arrived mail */ + if (mutt_buffy_notify()) + { + redraw |= REDRAW_STATUS; + if (option (OPTBEEPNEW)) + beep(); + if (NewMailCmd) + { + char cmd[LONG_STRING]; + menu_status_line (cmd, sizeof (cmd), index, NONULL (NewMailCmd)); + mutt_system (cmd); + } + } + } + if (SigInt) { mutt_query_exit (); diff --git a/pager.h b/pager.h index 36c8725e2..ae8866f67 100644 --- a/pager.h +++ b/pager.h @@ -48,3 +48,4 @@ typedef struct int mutt_do_pager (const char *, const char *, int, pager_t *); int mutt_pager (const char *, const char *, int, pager_t *); +void update_index (MUTTMENU *menu, CONTEXT *ctx, int check, int oldcount, int index_hint);