X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=buffy.c;h=2b77b2dce5b22e4d92d69bb2a7113922c1e7bd3d;hp=dfadbe8538dc61dbf6767bdffe9309d8dae31bb0;hb=c0d71a35d690605434605578a0d34ce101f754bb;hpb=e6c3d6c782080832a49192a8bd88599ef230678e diff --git a/buffy.c b/buffy.c index dfadbe8..2b77b2d 100644 --- a/buffy.c +++ b/buffy.c @@ -157,14 +157,18 @@ static inline void buffy_free (BUFFY** p) { p_delete(p); } +/* Return the index number of path in Incoming list */ int buffy_lookup (const char* path) { int i = 0; + if (list_empty(Incoming) || !path || !*path) return (-1); + for (i = 0; i < Incoming->length; i++) { - if (!m_strcmp(((BUFFY*)Incoming->data[i])->path, path) ) + if (!m_strcmp(((BUFFY *)Incoming->data[i])->path, path)) return (i); } + return (-1); } @@ -466,7 +470,7 @@ int buffy_check (int force) tmp->has_new = tmp->new > 0; } if (BuffyCount > 0 && force != 2) - sidebar_draw (CurrentMenu); + sidebar_draw (); return (BuffyCount); } @@ -512,7 +516,7 @@ int buffy_list (void) } if (!first) { /* on new mail: redraw sidebar */ - sidebar_draw (CurrentMenu); + sidebar_draw (); mutt_message ("%s", buffylist); return (1); } @@ -549,15 +553,16 @@ void buffy_next (char *s, size_t slen) } /* - * If buffy_lookup returns the index, + * buffy_lookup returns the index, * or -1 if not found (-1..Incoming->length-1); * plus one --> (0..Incoming->length). * Modulo mapps it into the correct range. */ i = 1 + buffy_lookup (s); - for (l=0; l < Incoming->length; l++) { + for (l = 0; l < Incoming->length; l++) { c = (l+i) % Incoming->length; - if ((!Context || !Context->path || m_strcmp(((BUFFY*) Incoming->data[c])->path, Context->path)) && + + if (m_strcmp(((BUFFY*) Incoming->data[c])->path, s) && ((BUFFY*) Incoming->data[c])->new > 0) break; } @@ -565,7 +570,7 @@ void buffy_next (char *s, size_t slen) *s = '\0'; /* something went wrong since we're here when buffy_check * reported new mail */ - buffy_check (0); + buffy_check (1); } else { m_strcpy(s, slen, ((BUFFY*)Incoming->data[c])->path); mutt_pretty_mailbox (s);