Is there any way to customise sorting of directories in the index?
Rene Kita
mutt at rkta.de
Sat Apr 10 10:17:39 UTC 2021
On Thu, Apr 08, 2021 at 05:55:05PM +0100, Chris Green wrote:
> On Thu, Apr 08, 2021 at 11:31:34AM +0100, Chris Green wrote:
> > On Thu, Apr 08, 2021 at 11:23:26AM +0100, Chris Green wrote:
> > > I have a about 40 or so folders where I save mails I want to keep,
> > > with names such as 'shopping', 'motorcycle' and so on. By default
> > > these are sorted alphabetically in the index which is not ideal. I
> > > save things in 'shopping' far more frequently than elsewhere so it
> > > would be really handy if that was at the top or at least near the top.
I explicitly configure my important folders in my '.muttrc' with
'mailboxes' in the order I want them to appear in mutt. To have them
appear in the order from '.muttrc' you need to 'set sort_browser=unsorted'.
Additionally I have the following macro to make the folder browser
always show the configured mailboxes:
macro index c "<change-folder>?<toggle-mailboxes>" "open a different folder"
macro pager c "<change-folder>?<toggle-mailboxes>" "open a different folder"
> Anything other than alphabatical sorting is pretty useless with a long
> list of directories, especially as it often puts .. somewhere other
> than at the top. If you have many directories at one level (my
> top level directory has 32) finding anything in it other than by an
> alphabetical sort is painful! (I tried 'date' to see what it did).
I have a patch which automatically changes to alphabetical sorting when
showing directory contents (this requires to build from source).
--- a/PATCHES
+++ b/PATCHES
@@ -0,0 +1 @@
+patch-2.0.4.rkta.unsort_dir_alpha.1
--- a/browser.c
+++ b/browser.c
@@ -438,6 +438,7 @@ static int examine_directory (MUTTMENU *
struct dirent *de;
BUFFER *full_path = NULL;
BUFFY *tmp;
+ short unsort;
while (stat (d, &s) == -1)
{
@@ -505,8 +506,18 @@ static int examine_directory (MUTTMENU *
add_folder (menu, state, de->d_name, mutt_b2s (full_path), &s, tmp);
}
closedir (dp);
+
+ if ((BrowserSort & SORT_MASK) == SORT_ORDER)
+ {
+ unsort = 1;
+ BrowserSort = SORT_SUBJECT;
+ }
+
browser_sort (state);
+ if (unsort)
+ BrowserSort = SORT_ORDER;
+
mutt_buffer_pool_release (&full_path);
return 0;
}
More information about the Mutt-users
mailing list