Re: Is there any way to customise sorting of directories in the index?

2021-04-23 Thread Rene Kita
On Thu, Apr 22, 2021 at 04:22:59PM -0500, Derek Martin wrote:
> > > 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.
> [...]
> > I have a patch which automatically changes to alphabetical sorting when
> > showing directory contents (this requires to build from source).
> 
> I have wanted this forever and have just been too lazy to hack up a
> patch for it.  I do not think any other behavior makes sense, and I do
> think this should be the default behavior.  Thanks.
> 
> I haven't (yet) looked at the context of the patch so I won't comment
> on it other than to say I would probably use bool (from stdbool.h)
> instead of short--It conceptually  matches the intent of the code and
> FWIW has been available since C99.
Thanks for the feedback. The reason why I picked a short was to stick as
close as possible to the original coding style (from my limited
knowledge about the code base). Other than that, you raise valid points.

> One could argue there should be a config variable to control this
> sorting behavior, but I personally would neither make nor support that
> argument. =8^)
As you said yourself, no other behavior makes sense. Either you agree
and apply the patch or you don't - no need for a config variable. ;)
And you can still change the sort order while examining the directory.


Re: Is there any way to customise sorting of directories in the index?

2021-04-10 Thread Rene Kita
On Sat, Apr 10, 2021 at 10:04:53AM -0700, Kevin J. McCarthy wrote:
> On Sat, Apr 10, 2021 at 12:17:39PM +0200, Rene Kita wrote:
> > Additionally I have the following macro to make the folder browser
> > always show the configured mailboxes:
> > macro index c "?" "open a different folder"
> > macro pager c "?" "open a different folder"
> 
>  was added in Mutt 1.13 and is bound by default to 'y'.
> Using the function has the advantage of working properly with
> $browser_sticky_cursor.
Good to know. My .muttrc is probably older than 1.13, but I'll try to
fix my habits now. Also didn't know about $browser_sticky_cursor, but I
guess I want it. :)


Re: Is there any way to customise sorting of directories in the index?

2021-04-10 Thread Kevin J. McCarthy

On Sat, Apr 10, 2021 at 12:17:39PM +0200, Rene Kita wrote:
Additionally I have the following macro to make the folder browser 
always show the configured mailboxes:

macro index c "?" "open a different folder"
macro pager c "?" "open a different folder"


 was added in Mutt 1.13 and is bound by default to 
'y'.  Using the function has the advantage of working properly with 
$browser_sticky_cursor.


--
Kevin J. McCarthy
GPG Fingerprint: 8975 A9B3 3AA3 7910 385C  5308 ADEF 7684 8031 6BDA


signature.asc
Description: PGP signature


Re: Is there any way to customise sorting of directories in the index?

2021-04-10 Thread Rene Kita
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 "?" "open a different folder"
macro pager c "?" "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, ) == -1)
   {
@@ -505,8 +506,18 @@ static int examine_directory (MUTTMENU *
 add_folder (menu, state, de->d_name, mutt_b2s (full_path), , 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 (_path);
   return 0;
 }


Re: Is there any way to customise sorting of directories in the index?

2021-04-08 Thread Chris Green
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. 
> > 
> > Is there any way to customise the sort order?  I suppose the ideal
> > would be 'most recently used' at the top but even reverse alphabetical
> > would improve things.
> > 
> > I *could* rename 'shopping' to 'Shopping' to fix that one but I'd
> > really like a more generally applicable solution.
> > 
> Ah, oops, I've just discovered the sort_browser setting which
> addresses this issue to some extent.  However some explanation of the
> settings might be useful:-
> 
> count - does this mean the count of messages in the directory,
> what about if it contains further subdirectories?
> 
> date - date of what?  If it's just the date of the directory it's
> not terribly useful!  
> 
> size - does it work or mean anything with maildir?
> 
> unread - what does this mean?
> 
Sorry, talking to myself here so much!

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 think my solution of changing shopping to Shopping may be the most
sensible one.

-- 
Chris Green


Re: Is there any way to customise sorting of directories in the index?

2021-04-08 Thread Chris Green
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. 
> 
> Is there any way to customise the sort order?  I suppose the ideal
> would be 'most recently used' at the top but even reverse alphabetical
> would improve things.
> 
> I *could* rename 'shopping' to 'Shopping' to fix that one but I'd
> really like a more generally applicable solution.
> 
Ah, oops, I've just discovered the sort_browser setting which
addresses this issue to some extent.  However some explanation of the
settings might be useful:-

count - does this mean the count of messages in the directory,
what about if it contains further subdirectories?

date - date of what?  If it's just the date of the directory it's
not terribly useful!  

size - does it work or mean anything with maildir?

unread - what does this mean?

-- 
Chris Green


Is there any way to customise sorting of directories in the index?

2021-04-08 Thread Chris Green
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. 

Is there any way to customise the sort order?  I suppose the ideal
would be 'most recently used' at the top but even reverse alphabetical
would improve things.

I *could* rename 'shopping' to 'Shopping' to fix that one but I'd
really like a more generally applicable solution.

-- 
Chris Green