aboutsummaryrefslogtreecommitdiff
blob: 8a164dddde31b310ee60065897ae3f60c46675aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
From: Evgeni Golov <sargentd@die-welt.net>
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.

Index: mutt-1.5.18/sidebar.c
===================================================================
--- mutt-1.5.18.orig/sidebar.c	2008-11-06 18:58:19.000000000 +0100
+++ mutt-1.5.18/sidebar.c	2008-11-06 18:59:16.000000000 +0100
@@ -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 ) {
Index: mutt-1.5.18/init.h
===================================================================
--- mutt-1.5.18.orig/init.h	2008-11-06 18:58:19.000000000 +0100
+++ mutt-1.5.18/init.h	2008-11-06 18:58:19.000000000 +0100
@@ -1553,6 +1553,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
Index: mutt-1.5.18/mutt.h
===================================================================
--- mutt-1.5.18.orig/mutt.h	2008-11-06 18:58:19.000000000 +0100
+++ mutt-1.5.18/mutt.h	2008-11-06 18:58:19.000000000 +0100
@@ -439,6 +439,7 @@
   OPTSCORE,
   OPTSIDEBAR,
   OPTSIDEBARSHORTPATH,
+  OPTSIDEBARSORT,
   OPTSIGDASHES,
   OPTSIGONTOP,
   OPTSORTRE,