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
10 @@ -840,8 +840,12 @@ int menu_redraw (MUTTMENU *menu)
12 int mutt_menuLoop (MUTTMENU *menu)
14 + static int last_position = -1;
17 + if (menu->is_mailbox_list && last_position >= 0)
18 + menu->current = last_position;
22 if (option (OPTMENUCALLER))
23 @@ -1073,6 +1077,8 @@ int mutt_menuLoop (MUTTMENU *menu)
27 + if (menu->is_mailbox_list)
28 + last_position = menu->current;
34 @@ -56,6 +56,7 @@ typedef struct folder_t
38 +static char OldLastDir[_POSIX_PATH_MAX] = "";
39 static char LastDir[_POSIX_PATH_MAX] = "";
40 static char LastDirBackup[_POSIX_PATH_MAX] = "";
42 @@ -506,19 +507,38 @@ static void init_menu (struct browser_st
47 + menu->is_mailbox_list = 1;
48 snprintf (title, titlelen, _("Mailboxes [%d]"), mutt_buffy_check (0));
52 + menu->is_mailbox_list = 0;
53 strfcpy (path, LastDir, sizeof (path));
54 mutt_pretty_mailbox (path);
56 - if (state->imap_browse && option (OPTIMAPLSUB))
57 - snprintf (title, titlelen, _("Subscribed [%s], File mask: %s"),
58 - path, NONULL (Mask.pattern));
60 + if (state->imap_browse && option (OPTIMAPLSUB))
61 + snprintf (title, titlelen, _("Subscribed [%s], File mask: %s"),
62 + path, NONULL (Mask.pattern));
65 - snprintf (title, titlelen, _("Directory [%s], File mask: %s"),
66 - path, NONULL(Mask.pattern));
68 + char *p = strrchr (OldLastDir, '/');
69 + if (p && p - OldLastDir == mutt_strlen (LastDir) &&
70 + mutt_strncmp (LastDir, OldLastDir, p - OldLastDir) == 0)
72 + /* If we get here, it means that LastDir is the parent directory of
73 + * OldLastDir. I.e., we're returning from a subdirectory, and we want
74 + * to position the cursor on the directory we're returning from. */
76 + for (i = 0; i < state->entrymax; i++)
77 + if (mutt_strcmp (state->entry[i].name, p + 1) == 0)
80 + snprintf (title, titlelen, _("Directory [%s], File mask: %s"),
81 + path, NONULL(Mask.pattern));
85 menu->redraw = REDRAW_FULL;
87 @@ -694,7 +714,6 @@ void _mutt_select_file (char *f, size_t
91 - char OldLastDir[_POSIX_PATH_MAX];
93 /* save the old directory */
94 strfcpy (OldLastDir, LastDir, sizeof (OldLastDir));
97 @@ -49,6 +49,7 @@ typedef struct menu_t
98 int offset; /* which screen row to start the index */
99 int pagelen; /* number of entries per screen */
101 + int is_mailbox_list;
103 /* Setting dialog != NULL overrides normal menu behaviour.
104 * In dialog mode menubar is hidden and prompt keys are checked before
107 @@ -3,3 +3,4 @@ patch-1.5.13.cd.purge_message.3.4
108 patch-1.5.13.nt+ab.xtitles.4
109 patch-1.5.6.dw.maildir-mtime.1
110 patch-1.5.13.cd.ifdef.2
111 +patch-1.5.8.hr.sensible_browser_position.3