2 This is the sensible browser position patch by Haakon Riiser.
4 * Found in: <20050309162127.GA5656@s>
5 http://lists.df7cb.de/mutt/message/20050309.162127.a244a894.en.html
9 ===================================================================
10 --- mutt.orig/menu.c 2009-06-25 12:35:36.000000000 +0200
11 +++ mutt/menu.c 2009-06-25 12:36:19.000000000 +0200
14 int mutt_menuLoop (MUTTMENU *menu)
16 + static int last_position = -1;
19 + if ( menu->max && menu->is_mailbox_list ) {
20 + if ( last_position > (menu->max-1) ) {
22 + } else if (last_position >= 0) {
23 + menu->current = last_position;
29 if (option (OPTMENUCALLER))
34 + if (menu->is_mailbox_list)
35 + last_position = menu->current;
40 ===================================================================
41 --- mutt.orig/browser.c 2009-06-25 12:35:37.000000000 +0200
42 +++ mutt/browser.c 2009-06-25 12:36:19.000000000 +0200
47 +static char OldLastDir[_POSIX_PATH_MAX] = "";
48 static char LastDir[_POSIX_PATH_MAX] = "";
49 static char LastDirBackup[_POSIX_PATH_MAX] = "";
56 + menu->is_mailbox_list = 1;
57 snprintf (title, titlelen, _("Mailboxes [%d]"), mutt_buffy_check (0));
61 + menu->is_mailbox_list = 0;
62 strfcpy (path, LastDir, sizeof (path));
63 mutt_pretty_mailbox (path, sizeof (path));
66 path, NONULL (Mask.pattern));
69 - snprintf (title, titlelen, _("Directory [%s], File mask: %s"),
70 - path, NONULL(Mask.pattern));
72 + char *p = strrchr (OldLastDir, '/');
73 + if (p && p - OldLastDir == mutt_strlen (LastDir) &&
74 + mutt_strncmp (LastDir, OldLastDir, p - OldLastDir) == 0)
76 + /* If we get here, it means that LastDir is the parent directory of
77 + * OldLastDir. I.e., we're returning from a subdirectory, and we want
78 + * to position the cursor on the directory we're returning from. */
80 + for (i = 0; i < state->entrymax; i++)
81 + if (mutt_strcmp (state->entry[i].name, p + 1) == 0)
84 + snprintf (title, titlelen, _("Directory [%s], File mask: %s"),
85 + path, NONULL(Mask.pattern));
88 menu->redraw = REDRAW_FULL;
94 - char OldLastDir[_POSIX_PATH_MAX];
96 /* save the old directory */
97 strfcpy (OldLastDir, LastDir, sizeof (OldLastDir));
98 Index: mutt/mutt_menu.h
99 ===================================================================
100 --- mutt.orig/mutt_menu.h 2009-06-25 12:35:44.000000000 +0200
101 +++ mutt/mutt_menu.h 2009-06-25 12:36:19.000000000 +0200
103 int offset; /* which screen row to start the index */
104 int pagelen; /* number of entries per screen */
106 + int is_mailbox_list;
108 /* Setting dialog != NULL overrides normal menu behaviour.
109 * In dialog mode menubar is hidden and prompt keys are checked before