]> git.llucax.com Git - software/mutt-debian.git/blob - debian/patches/mutt-patched/sidebar-sorted
a better way of closing 603186 (sidebar-{sorted,dotted} documentation)
[software/mutt-debian.git] / debian / patches / mutt-patched / sidebar-sorted
1 From: Evgeni Golov <sargentd@die-welt.net>
2 License: 3-BSD
3
4 When using IMAP and imap_check_subscribed, the server reports the
5 dirs in a random order.
6 This patch introduces a new option, sidebar_sort. Which, when it is
7 set, sorts the dirs in the sidebar alphabetically.
8
9 I hope, it's usefull for someone ;)
10
11 PS: This has to be applied ontop of my sidebar-dotted patch, but it
12 should be easy to adopt it to a vanilla mutt.
13
14 --- a/sidebar.c
15 +++ b/sidebar.c
16 @@ -54,6 +54,35 @@
17         for ( ; tmp->next != 0; tmp = tmp->next )
18                 tmp->next->prev = tmp;
19  
20 +       if (option(OPTSIDEBARSORT)) {
21 +               int needsort=1;
22 +               BUFFY *prev;
23 +               BUFFY *next;
24 +               BUFFY *tmp2;
25 +               while (needsort==1) {
26 +                       needsort=0;
27 +                       tmp = Incoming;
28 +                       for ( ; tmp ; tmp=tmp->next ) {
29 +                               if (tmp->next != NULL && strcoll(tmp->path, tmp->next->path) > 0) {
30 +                                       needsort=1;
31 +                                       prev = tmp->prev;
32 +                                       next = tmp->next;
33 +                                       if (prev != NULL)
34 +                                               prev->next = next;
35 +                                       else
36 +                                               Incoming = next;
37 +                                       next->prev = prev;
38 +                                       tmp2 = next->next;
39 +                                       next->next = tmp;
40 +                                       tmp->prev = next;
41 +                                       tmp->next = tmp2;
42 +                                       if (tmp2 != NULL)
43 +                                               tmp2->prev = tmp;
44 +                               }
45 +                       }
46 +               }
47 +       }
48 +
49         if ( TopBuffy == 0 && BottomBuffy == 0 )
50                 TopBuffy = Incoming;
51         if ( BottomBuffy == 0 ) {
52 --- a/init.h
53 +++ b/init.h
54 @@ -1986,6 +1986,11 @@
55    ** .pp
56    ** Should the sidebar shorten the path showed.
57    */
58 +  { "sidebar_sort", DT_BOOL, R_BOTH, OPTSIDEBARSORT, 0 },
59 +  /*
60 +  ** .pp
61 +  ** Should the sidebar be sorted.
62 +  */
63    { "pgp_use_gpg_agent", DT_BOOL, R_NONE, OPTUSEGPGAGENT, 0},
64    /*
65    ** .pp
66 --- a/mutt.h
67 +++ b/mutt.h
68 @@ -433,6 +433,7 @@
69    OPTSCORE,
70    OPTSIDEBAR,
71    OPTSIDEBARSHORTPATH,
72 +  OPTSIDEBARSORT,
73    OPTSIGDASHES,
74    OPTSIGONTOP,
75    OPTSORTRE,