From: Evgeni Golov License: 3-BSD When using IMAP and imap_check_subscribed, the server reports the dirs in a random order. This patch introduces a new option, sidebar_sort. Which, when it is set, sorts the dirs in the sidebar alphabetically. I hope, it's usefull for someone ;) PS: This has to be applied ontop of my sidebar-dotted patch, but it should be easy to adopt it to a vanilla mutt. --- a/sidebar.c +++ b/sidebar.c @@ -54,6 +54,35 @@ for ( ; tmp->next != 0; tmp = tmp->next ) tmp->next->prev = tmp; + if (option(OPTSIDEBARSORT)) { + int needsort=1; + BUFFY *prev; + BUFFY *next; + BUFFY *tmp2; + while (needsort==1) { + needsort=0; + tmp = Incoming; + for ( ; tmp ; tmp=tmp->next ) { + if (tmp->next != NULL && strcmp(tmp->path, tmp->next->path) > 0) { + needsort=1; + prev = tmp->prev; + next = tmp->next; + if (prev != NULL) + prev->next = next; + else + Incoming = next; + next->prev = prev; + tmp2 = next->next; + next->next = tmp; + tmp->prev = next; + tmp->next = tmp2; + if (tmp2 != NULL) + tmp2->prev = tmp; + } + } + } + } + if ( TopBuffy == 0 && BottomBuffy == 0 ) TopBuffy = Incoming; if ( BottomBuffy == 0 ) { --- a/init.h +++ b/init.h @@ -1986,6 +1986,11 @@ ** .pp ** Should the sidebar shorten the path showed. */ + { "sidebar_sort", DT_BOOL, R_BOTH, OPTSIDEBARSORT, 0 }, + /* + ** .pp + ** Should the sidebar be sorted. + */ { "pgp_use_gpg_agent", DT_BOOL, R_NONE, OPTUSEGPGAGENT, 0}, /* ** .pp --- a/mutt.h +++ b/mutt.h @@ -433,6 +433,7 @@ OPTSCORE, OPTSIDEBAR, OPTSIDEBARSHORTPATH, + OPTSIDEBARSORT, OPTSIGDASHES, OPTSIGONTOP, OPTSORTRE,