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

Re: Feature request for somewhen



On (19:11 18/06/07), David Woodfall <dave@xxxxxxxxxxxxxxx> put forth the 
proposition:
> On (20:58 16/06/07), Adeodato Simó <dato@xxxxxxxxxxxxxx> put forth the 
> proposition:
> > * David Woodfall [Sat, 16 Jun 2007 00:07:50 +0100]:
> > 
> > > When entering an mbox from a folder, and then exiting back to the folder,
> > > presently the cursor returns to the top of the folder. It would be nice if
> > > the cursor remained opposite the mbox exited from, in the same way that
> > > when browsing an mbox and exiting an email/thread does.
> > 
> > > It would save an awful lot of scrolling down when, say, checking new posts
> > > in mailing lists.
> > 
> > > Just a thought anyway.
> > 
> > Hello. The feature you want is implemented in the sensible_browser_position
> > patch by Haakon Riiser:
> > 
> >   http://does-not-exist.org/mail-archives/mutt-dev/msg02623.html
> >     OR
> >   
> > http://hg.debian.org/hg/pkg-mutt/debian-mutt?cmd=file;file=debian/patches/not-applied/patch-1.5.8.hr.sensible_browser_position.3;filenode=4f3e410fcc58a5721d0c7910a8ab2e2cd1996d22;style=raw
> 
> Thanks. I've edited the patch slightly so that it works with out having to
> toggle mailbox view (tab). It now works in any view. I'm not a experienced
> programmer at all. I just changed a couple of lines:
> 
> 'if (menu->is_mailbox_list)' to 'if (true)'
> 'if (menu->is_mailbox_list && last_position >= 0)' to 
> 'if (last_position >= 0)'
> 
> I think that is all. Haven't a clue if it breaks something else though.

Behaves wrongly in nested folders.

> 
> --- mutt-1.5.8/menu.c.orig    2005-02-12 21:01:55.000000000 +0100
> +++ mutt-1.5.8/menu.c 2005-03-09 16:39:49.000000000 +0100
> @@ -841,8 +841,12 @@
>  
>  int mutt_menuLoop (MUTTMENU *menu)
>  {
> +  static int last_position = -1;
>    int i = OP_NULL;
>  
> +  if (last_position >= 0)
> +    menu->current = last_position;
> +
>    FOREVER
>    {
>      if (option (OPTMENUCALLER))
> @@ -1068,6 +1072,8 @@
>       break;
>  
>        default:
> +     if (true)
> +       last_position = menu->current;
>       return (i);
>      }
>    }
> --- mutt-1.5.8/browser.c.orig 2005-02-03 19:47:52.000000000 +0100
> +++ mutt-1.5.8/browser.c      2005-03-09 16:48:31.000000000 +0100
> @@ -54,6 +54,7 @@
>    int num;
>  } FOLDER;
>  
> +static char OldLastDir[_POSIX_PATH_MAX] = "";
>  static char LastDir[_POSIX_PATH_MAX] = "";
>  static char LastDirBackup[_POSIX_PATH_MAX] = "";
>  
> @@ -498,19 +499,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;
>  }
> @@ -685,7 +705,6 @@
>  #endif
>           )
>         {
> -         char OldLastDir[_POSIX_PATH_MAX];
>  
>           /* save the old directory */
>           strfcpy (OldLastDir, LastDir, sizeof (OldLastDir));
> --- 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-09 16:39:49.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;
> 
> 
> > 
> > I suggested it for 1.6, but received no feedback AFAICR.
> > 
> > Cheers,
> > 
> > -- 
> > Adeodato Simó                                     dato at net.com.org.es
> > Debian Developer                                  adeodato at debian.org
> >  
> > This is my boyfriend, Chester Fleet. [...] It's kind of a weird day to meet 
> > him
> > because he lost a bet with me, and that means that for the entire day, he 
> > can
> > only talk in clichés. It is so much fun.
> >                 -- Tana Schrick
> 
> -- 
> Universe, n.:
>       The problem.

-- 
Just when you thought you were winning the rat race, along comes a
faster rat!!!