<<< Date Index >>>     <<< Thread Index >>>

Re: Patch for mutt 1.5.8 that makes it remember menu position



[Tamotsu Takahashi]

> On Tue, Mar 01, 2005 at 08:20:46PM +0100, Haakon Riiser wrote:
> 
>> +  if (menu->title && strncmp("Mailboxes", menu->title, 9) == 0 &&
> 
> This doesn't work with non-English locale.
> And you have to know that _("Mailboxes [%d]") could be
> translated to "Foo [%d] Bar"-style.

It did occur to me that the "Mailboxes" string might not be
written in stone, but I forgot that it wouldn't take more than
changing the locale to mess it up. :-)  If there isn't currently
any other way to determine menuLoop()'s state than the title,
it would probably be better to add a new state variable to the
MUTTMENU struct.  Here's a patch that takes this approach:

--- mutt-1.5.8/mutt_menu.h.orig 2003-10-04 21:29:27.000000000 +0200
+++ mutt-1.5.8/mutt_menu.h      2005-03-02 11:04:38.000000000 +0100
@@ -46,6 +46,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
--- mutt-1.5.8/browser.c.orig   2005-02-03 19:47:52.000000000 +0100
+++ mutt-1.5.8/browser.c        2005-03-02 11:05:11.000000000 +0100
@@ -498,9 +498,13 @@
   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
--- mutt-1.5.8/menu.c.orig      2005-02-12 21:01:55.000000000 +0100
+++ mutt-1.5.8/menu.c   2005-03-02 11:05:50.000000000 +0100
@@ -841,8 +841,12 @@
 
 int mutt_menuLoop (MUTTMENU *menu)
 {
+  static int last_position = -1;
   int i = OP_NULL;
 
+  if (menu->is_mailbox_list && last_position >= 0)
+    menu->current = last_position;
+
   FOREVER
   {
     if (option (OPTMENUCALLER))
@@ -1068,6 +1072,8 @@
        break;
 
       default:
+       if (menu->is_mailbox_list)
+         last_position = menu->current;
        return (i);
     }
   }

-- 
 Haakon