tag 439387 -moreinfo
tag 439387 +patch confirmed pending
thanks
Hi,
the attached file is the new sensible browser patch, which does
not cause the segfault (I've tested on my desktop), I'll contact
Christoph and update the git repository accordingly, so the
patch will be included in the next releases of mutt.
Cheers
Antonio
# vi: ft=diff
This is the sensible browser position patch by Haakon Riiser.
* Found in: <20050309162127.ga5...@s>
http://lists.df7cb.de/mutt/message/20050309.162127.a244a894.en.html
== END PATCH
--- a/menu.c
+++ b/menu.c
@@ -840,8 +840,17 @@
int mutt_menuLoop (MUTTMENU *menu)
{
+ static int last_position = -1;
int i = OP_NULL;
+ 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
{
if (option (OPTMENUCALLER))
@@ -1073,6 +1082,8 @@
break;
default:
+ if (menu->is_mailbox_list)
+ last_position = menu->current;
return (i);
}
}
--- a/browser.c
+++ b/browser.c
@@ -56,6 +56,7 @@
int num;
} FOLDER;
+static char OldLastDir[_POSIX_PATH_MAX] = "";
static char LastDir[_POSIX_PATH_MAX] = "";
static char LastDirBackup[_POSIX_PATH_MAX] = "";
@@ -511,19 +512,38 @@
menu->tagged = 0;
if (buffy)
+ {
+ menu->is_mailbox_list = 1;
snprintf (title, titlelen, _("Mailboxes [%d]"), mutt_buffy_check (0));
+ }
else
{
+ menu->is_mailbox_list = 0;
strfcpy (path, LastDir, sizeof (path));
mutt_pretty_mailbox (path);
#ifdef USE_IMAP
- if (state->imap_browse && option (OPTIMAPLSUB))
- snprintf (title, titlelen, _("Subscribed [%s], File mask: %s"),
- path, NONULL (Mask.pattern));
- else
+ if (state->imap_browse && option (OPTIMAPLSUB))
+ snprintf (title, titlelen, _("Subscribed [%s], File mask: %s"),
+ path, NONULL (Mask.pattern));
+ else
#endif
- snprintf (title, titlelen, _("Directory [%s], File mask: %s"),
- path, NONULL(Mask.pattern));
+ {
+ char *p = strrchr (OldLastDir, '/');
+ if (p && p - OldLastDir == mutt_strlen (LastDir) &&
+ mutt_strncmp (LastDir, OldLastDir, p - OldLastDir) == 0)
+ {
+ /* If we get here, it means that LastDir is the parent directory of
+ * OldLastDir. I.e., we're returning from a subdirectory, and we want
+ * to position the cursor on the directory we're returning from. */
+ int i;
+ for (i = 0; i < state->entrymax; i++)
+ if (mutt_strcmp (state->entry[i].name, p + 1) == 0)
+ menu->current = i;
+ }
+ snprintf (title, titlelen, _("Directory [%s], File mask: %s"),
+ path, NONULL(Mask.pattern));
+ }
+
}
menu->redraw = REDRAW_FULL;
}
@@ -707,7 +727,6 @@
#endif
)
{
- char OldLastDir[_POSIX_PATH_MAX];
/* save the old directory */
strfcpy (OldLastDir, LastDir, sizeof (OldLastDir));
--- a/mutt_menu.h
+++ b/mutt_menu.h
@@ -49,6 +49,7 @@
int offset; /* which screen row to start the index */
int pagelen; /* number of entries per screen */
int tagprefix;
+ int is_mailbox_list;
/* Setting dialog != NULL overrides normal menu behaviour.
* In dialog mode menubar is hidden and prompt keys are checked before