Re: change_folder_next patch
Hi Brendan,
On Friday, 13 April, 2007 at 15:51:21 +0100, N.J. Mann wrote:
> On Friday, 13 April, 2007 at 12:24:14 +0100, N.J. Mann wrote:
> > On Thursday, 29 March, 2007 at 16:03:15 -0700, Brendan Cully wrote:
> > > On Monday, 05 March 2007 at 13:43, Antoine Reilles wrote:
> > > > Hi,
> > > >
> > > > A patch to add a (change_folder_next) option to mutt was proposed long
> > > > time ago. It allow the change-folder command to start at the folder
> > > > after the current folder. The reason is that it may be annoying
> > > > that the 'c' (change-folder) command always starts from the first
> > > > folder in the mailboxes list.
> > > >
> > > > The patch was proposed by Simon Burge in
> > > > http://permalink.gmane.org/gmane.mail.mutt.devel/714
> > > >
> > > > Since then, it is integrated as a pkgsrc patch (http://www.pkgsrc.org/)
> > > > but i would really prefer to see it in mutt. Also, i think it may be of
> > > > use for many mutt users.
> > > >
> > > > I'm including the current pkgsrc patches or that feature, if you want to
> > > > pick this up. The option name is not necessarily well chosen, so feel
> > > > free to do any change.
> > >
> > > I'm not sure whether it's worth it, but I think if we want this, it
> > > might be nicer as a second command than a configuration
> > > variable. Perhaps <next-folder> ? It wouldn't even need to prompt.
> >
> > As there hadn't been any followup on the list for this I had a go
> > myself. This is the first time I have hacked on Mutt, so I have
> > probably missed something. My patch (below) is based on mutt 1.15.5
> > (FreeBSD). Does this look okay?
>
> I had a rethink about this over lunch and I have now changed my patch to
> work exactly as you suggested. It isn't quite right yet so I'll hold
> back on publishing it, I just wanted to let you know that a new patch is
> in the works. Comments about the original one would be welcome.
Okay, here is the latest version of my patch.
Cheers,
Nick.
--
Please do not CC me on replies, I read the list and don't need the dupes.
--- functions.h~ Sun Apr 1 22:58:55 2007
+++ functions.h Thu Apr 12 20:52:01 2007
@@ -88,6 +88,7 @@
{ "break-thread", OP_MAIN_BREAK_THREAD, "#" },
{ "change-folder", OP_MAIN_CHANGE_FOLDER, "c" },
{ "change-folder-readonly", OP_MAIN_CHANGE_FOLDER_READONLY, "\033c" },
+ { "next-folder", OP_MAIN_NEXT_FOLDER, "," },
{ "collapse-thread", OP_MAIN_COLLAPSE_THREAD, "\033v" },
{ "collapse-all", OP_MAIN_COLLAPSE_ALL, "\033V" },
{ "copy-message", OP_COPY_MESSAGE, "C" },
@@ -176,6 +177,7 @@
{ "bounce-message", OP_BOUNCE_MESSAGE, "b" },
{ "change-folder", OP_MAIN_CHANGE_FOLDER, "c" },
{ "change-folder-readonly", OP_MAIN_CHANGE_FOLDER_READONLY, "\033c" },
+ { "next-folder", OP_MAIN_NEXT_FOLDER, "," },
{ "copy-message", OP_COPY_MESSAGE, "C" },
{ "decode-copy", OP_DECODE_COPY, "\033C" },
{ "delete-message", OP_DELETE, "d" },
--- OPS~ Sun Apr 1 22:58:55 2007
+++ OPS Thu Apr 12 21:07:23 2007
@@ -107,6 +107,7 @@
OP_MAIN_LAST_MESSAGE "move to the last message"
OP_MAIN_LIMIT "show only messages matching a pattern"
OP_MAIN_LINK_THREADS "link tagged message to the current one"
+OP_MAIN_NEXT_FOLDER "open next folder"
OP_MAIN_NEXT_NEW "jump to the next new message"
OP_MAIN_NEXT_NEW_THEN_UNREAD "jump to the next new or unread message"
OP_MAIN_NEXT_SUBTHREAD "jump to the next subthread"
--- curs_main.c~ Fri Apr 13 15:17:02 2007
+++ curs_main.c Fri Apr 13 15:59:56 2007
@@ -1052,6 +1052,7 @@
break;
case OP_MAIN_CHANGE_FOLDER:
+ case OP_MAIN_NEXT_FOLDER:
if (attach_msg)
op = OP_MAIN_CHANGE_FOLDER_READONLY;
@@ -1066,18 +1067,27 @@
cp = _("Open mailbox");
buf[0] = '\0';
- mutt_buffy (buf, sizeof (buf));
+ if ((op == OP_MAIN_NEXT_FOLDER) && Context && Context->path)
+ {
+ strfcpy (buf, Context->path, sizeof (buf));
+ mutt_pretty_mailbox (buf);
+ mutt_buffy (buf, sizeof (buf));
+ }
+ else
+ {
+ mutt_buffy (buf, sizeof (buf));
- if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
- {
- if (menu->menu == MENU_PAGER)
- {
- op = OP_DISPLAY_MESSAGE;
- continue;
- }
- else
- break;
- }
+ if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
+ {
+ if (menu->menu == MENU_PAGER)
+ {
+ op = OP_DISPLAY_MESSAGE;
+ continue;
+ }
+ else
+ break;
+ }
+ }
if (!buf[0])
{
CLEARLINE (LINES-1);