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
8 Index: debian-mutt/menu.c
9 ===================================================================
10 --- debian-mutt.orig/menu.c 2007-03-24 18:45:30.000000000 +0100
11 +++ debian-mutt/menu.c 2007-06-28 21:48:47.000000000 +0200
12 @@ -840,8 +840,12 @@ int menu_redraw (MUTTMENU *menu)
14 int mutt_menuLoop (MUTTMENU *menu)
16 + static int last_position = -1;
19 + if (menu->is_mailbox_list && last_position >= 0)
20 + menu->current = last_position;
24 if (option (OPTMENUCALLER))
25 @@ -1073,6 +1077,8 @@ int mutt_menuLoop (MUTTMENU *menu)
29 + if (menu->is_mailbox_list)
30 + last_position = menu->current;
34 Index: debian-mutt/browser.c
35 ===================================================================
36 --- debian-mutt.orig/browser.c 2007-06-28 21:41:27.000000000 +0200
37 +++ debian-mutt/browser.c 2007-06-28 21:48:47.000000000 +0200
38 @@ -56,6 +56,7 @@ typedef struct folder_t
42 +static char OldLastDir[_POSIX_PATH_MAX] = "";
43 static char LastDir[_POSIX_PATH_MAX] = "";
44 static char LastDirBackup[_POSIX_PATH_MAX] = "";
46 @@ -510,19 +511,38 @@ static void init_menu (struct browser_st
51 + menu->is_mailbox_list = 1;
52 snprintf (title, titlelen, _("Mailboxes [%d]"), mutt_buffy_check (0));
56 + menu->is_mailbox_list = 0;
57 strfcpy (path, LastDir, sizeof (path));
58 mutt_pretty_mailbox (path);
60 - if (state->imap_browse && option (OPTIMAPLSUB))
61 - snprintf (title, titlelen, _("Subscribed [%s], File mask: %s"),
62 - path, NONULL (Mask.pattern));
64 + if (state->imap_browse && option (OPTIMAPLSUB))
65 + snprintf (title, titlelen, _("Subscribed [%s], File mask: %s"),
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));
89 menu->redraw = REDRAW_FULL;
91 @@ -706,7 +726,6 @@ void _mutt_select_file (char *f, size_t
95 - char OldLastDir[_POSIX_PATH_MAX];
97 /* save the old directory */
98 strfcpy (OldLastDir, LastDir, sizeof (OldLastDir));
99 Index: debian-mutt/mutt_menu.h
100 ===================================================================
101 --- debian-mutt.orig/mutt_menu.h 2007-03-20 20:42:04.000000000 +0100
102 +++ debian-mutt/mutt_menu.h 2007-06-28 21:48:47.000000000 +0200
103 @@ -49,6 +49,7 @@ typedef struct menu_t
104 int offset; /* which screen row to start the index */
105 int pagelen; /* number of entries per screen */
107 + int is_mailbox_list;
109 /* Setting dialog != NULL overrides normal menu behaviour.
110 * In dialog mode menubar is hidden and prompt keys are checked before
111 Index: debian-mutt/PATCHES
112 ===================================================================
113 --- debian-mutt.orig/PATCHES 2007-06-28 21:49:06.000000000 +0200
114 +++ debian-mutt/PATCHES 2007-06-28 21:49:20.000000000 +0200
115 @@ -4,3 +4,4 @@ patch-1.5.13.nt+ab.xtitles.4
116 patch-1.5.6.dw.maildir-mtime.1
117 patch-1.5.13.cd.ifdef.2
118 patch-1.5.16.rr.compressed.1
119 +patch-1.5.8.hr.sensible_browser_position.3