From: Richard Russon Date: Tue, 6 Sep 2016 21:15:36 +0000 (+0100) Subject: tweak the behaviour of the sensible-browser code X-Git-Tag: neomutt-20160910~18^2~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=26628f17de297ca610461ef6906f2e8838eecbaf;p=neomutt tweak the behaviour of the sensible-browser code * fix crash when used with notmuch * drop unnecessary breaks * enabled for unsorted mailboxes * don't select '..' if sorted by count, etc --- diff --git a/browser.c b/browser.c index 075b75458..1337e5b34 100644 --- a/browser.c +++ b/browser.c @@ -180,23 +180,17 @@ static int browser_compare (const void *a, const void *b) { case SORT_DATE: return browser_compare_date(a, b); - break; case SORT_SIZE: return browser_compare_size(a, b); - break; case SORT_DESC: return browser_compare_desc(a, b); - break; case SORT_COUNT: return browser_compare_count(a, b); - break; case SORT_COUNT_NEW: return browser_compare_count_new(a, b); - break; case SORT_SUBJECT: default: return browser_compare_subject(a, b); - break; } } @@ -933,7 +927,8 @@ static void init_menu (struct browser_state *state, MUTTMENU *menu, char *title, * The goal is to highlight the good directory if LastDir is the parent dir * of OldLastDir (this occurs mostly when one hit "../"). */ - if (mutt_strncmp (LastDir, OldLastDir, mutt_strlen (LastDir)) == 0) + int ldlen = mutt_strlen (LastDir); + if ((ldlen > 0) && (mutt_strncmp (LastDir, OldLastDir, ldlen) == 0)) { char TargetDir[_POSIX_PATH_MAX] = ""; #ifdef USE_IMAP @@ -957,9 +952,16 @@ static void init_menu (struct browser_state *state, MUTTMENU *menu, char *title, if (mutt_strcmp (state->entry[i].name, TargetDir) == 0) { menu->current = i; + break; } } } + else + { + if ((mutt_strcmp (state->entry[0].desc, "..") == 0) || + (mutt_strcmp (state->entry[0].desc, "../") == 0)) + menu->current = 1; + } snprintf (title, titlelen, _("Directory [%s], File mask: %s"), path, NONULL(Mask.pattern)); } @@ -1102,7 +1104,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, int *num getcwd (LastDir, sizeof (LastDir)); else { - /* Should we use the tracking feature of the browser depends + /* Whether we use the tracking feature of the browser depends * on which sort method we chose to use. This variable is defined * only to help readability of the code. */ @@ -1112,6 +1114,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, int *num { case SORT_DESC: case SORT_SUBJECT: + case SORT_ORDER: browser_track = 1; break; diff --git a/curs_main.c b/curs_main.c index 68da7134d..eb3934151 100644 --- a/curs_main.c +++ b/curs_main.c @@ -1838,9 +1838,8 @@ int mutt_index_menu (void) } else #endif - /* Let's fill by default buf with the next mailbox containing - * unread mails - */ + /* By default, fill buf with the next mailbox that contains unread + * mail */ mutt_buffy (buf, sizeof (buf)); if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1) diff --git a/imap/util.c b/imap/util.c index 8c77c88a9..cb911a112 100644 --- a/imap/util.c +++ b/imap/util.c @@ -84,17 +84,15 @@ void imap_get_parent (char *output, const char *mbox, size_t olen, char delim) { int n; - /* If both pointers are on the same memory part - * strfcpy is useless - */ + /* Make a copy of the mailbox name, but only if the pointers are different */ if (mbox != output) strfcpy (output, mbox, olen); n = mutt_strlen (output); - /* Let's go backwards untill the next delimiter + /* Let's go backwards until the next delimiter * - * If output[n] is a '/', the first n-- will allow + * If output[n] is a '/', the first n-- will allow us * to ignore it. If it isn't, then output looks like * "/aaaaa/bbbb". There is at least one "b", so we can't skip * the "/" after the 'a's. @@ -104,7 +102,7 @@ void imap_get_parent (char *output, const char *mbox, size_t olen, char delim) */ for (n--; n >= 0 && output[n] != delim ; n--); - /* We stopped before the begining. There is a trailing + /* We stopped before the beginning. There is a trailing * slash. */ if (n > 0) diff --git a/menu.c b/menu.c index d56c5a45d..7e3293ce9 100644 --- a/menu.c +++ b/menu.c @@ -944,13 +944,9 @@ int mutt_menuLoop (MUTTMENU *menu) if (menu->max && menu->is_mailbox_list) { if (last_position > (menu->max - 1)) - { last_position = -1; - } else if (last_position >= 0) - { menu->current = last_position; - } } FOREVER diff --git a/muttlib.c b/muttlib.c index 13af56b91..8af711ceb 100644 --- a/muttlib.c +++ b/muttlib.c @@ -2180,7 +2180,7 @@ void mutt_get_parent_path (char *output, char *path, size_t olen) strfcpy (output, path, olen); int n = mutt_strlen (output); - /* Remove everything untill the next slash */ + /* Remove everything until the next slash */ for (n--; ((n >= 0) && (output[n] != '/')); n--); if (n > 0)