From: Karel Zak Date: Fri, 4 Oct 2013 18:34:57 +0000 (-0700) Subject: default to the next unread folder X-Git-Tag: neomutt-20160404~13^2~20 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=589b44bc538e103c75ff8f758f72f009bd134cea;p=neomutt default to the next unread folder It means that for example: macro index R will for as expected. Signed-off-by: Karel Zak --- diff --git a/buffy.c b/buffy.c index 094af7256..9af714de3 100644 --- a/buffy.c +++ b/buffy.c @@ -669,8 +669,11 @@ static void buffy_check(BUFFY *tmp, struct stat *contex_sb) tmp->msg_unread = 0; tmp->msg_flagged = 0; nm_nonctx_get_count(tmp->path, &tmp->msg_count, &tmp->msg_unread); - if (tmp->msg_unread > 0) + if (tmp->msg_unread > 0) { BuffyCount++; + tmp->new = 1; + } + sb_set_update_time(); break; #endif } @@ -857,6 +860,35 @@ void mutt_buffy (char *s, size_t slen) *s = '\0'; } +#ifdef USE_NOTMUCH +void mutt_buffy_vfolder (char *s, size_t slen) +{ + BUFFY *tmp; + int pass, found = 0; + + if (mutt_buffy_check (0)) + { + for (pass = 0; pass < 2; pass++) { + for (tmp = VirtIncoming; tmp; tmp = tmp->next) + { + if ((found || pass) && tmp->new) + { + strfcpy (s, tmp->desc, slen); + return; + } + if (mutt_strcmp (s, tmp->path) == 0) + found = 1; + } + } + + mutt_buffy_check (1); /* buffy was wrong - resync things */ + } + + /* no folders with new mail */ + *s = '\0'; +} +#endif + /* fetch buffy object for given path, if present */ static BUFFY* buffy_get (const char *path) { diff --git a/buffy.h b/buffy.h index f7f63797e..98eaeee07 100644 --- a/buffy.h +++ b/buffy.h @@ -54,6 +54,7 @@ WHERE short BuffyTimeout INITVAL (3); #ifdef USE_NOTMUCH WHERE BUFFY *VirtIncoming INITVAL (0); +void mutt_buffy_vfolder (char *s, size_t slen); #endif extern time_t BuffyDoneTime; /* last time we knew for sure how much mail there was */ diff --git a/curs_main.c b/curs_main.c index b67fae3fe..3f8d9de2a 100644 --- a/curs_main.c +++ b/curs_main.c @@ -1534,6 +1534,10 @@ int mutt_index_menu (void) } #ifdef USE_NOTMUCH else if (op == OP_MAIN_CHANGE_VFOLDER) { + if (Context->magic == M_NOTMUCH) { + strfcpy(buf, Context->path, sizeof (buf)); + mutt_buffy_vfolder (buf, sizeof (buf)); + } mutt_enter_vfolder (cp, buf, sizeof (buf), &menu->redraw, 1); if (!buf[0]) {