Package: mutt-patched
Version: 1.5.18-6
Severity: wishlist
Tags: patch

Hi,

I'm using mutt-patched to read mails from my courier imap server with
imap_check_subscribed (so not listing the mailboxes in my muttrc).

While doing so, I discovered some things with the sidebar, that could be 
improved:

1. Courier uses a "." instead of "/" as hierarchy-separator, so my mailboxes are
 INBOX
 INBOX.debian
 INBOX.debian.devel
 etc
 Because of that, the sidebar does not indent the folders correctly (well, not 
at all)
 and allways displays the "full" name. What I would like to have is something 
like
 INBOX
  debian
   devel
   games
  ml
   radeonhd
 ...

2. When using imap_check_subscribed, one gets the list of folders/mailboxes in a
   completelly random order, so I get something like
 INBOX.debian
 INBOX
 INBOX.ml.radeonhd
 INBOX.debian.devel

That for I wrote the two attached patches (against .18, didn't try .19 yet)

sidebar-dotted.patch adds support for the "." in folder names, so they will be
indented correctly. Additionally, when you set sidebar_shortpath, it will 
display
only the last part of the path (kind of basename), not the full one told by the 
server.
This should prolly be ported to the imap_delim_chars config instead of 
hardcoding the "."

sidebar-sorted.patch adds some simple bubble-sort to the sidebar, when 
sidebar_sort
is set, thus sorting the folders correctly (or at least as I wanted: 
alpabetically).

I hope those are usefull and can be integrated.

TIA
Evgeni

-- System Information:
Debian Release: squeeze/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing'), (500, 'stable'), (1, 
'experimental')
Architecture: i386 (i686)

Kernel: Linux 2.6.29-rc6-x31-1
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages mutt-patched depends on:
ii  libc6                    2.9-6           GNU C Library: Shared libraries
ii  libgdbm3                 1.8.3-4         GNU dbm database routines (runtime
ii  libgnutls26              2.6.4-2         the GNU TLS library - runtime libr
ii  libidn11                 1.12-1          GNU Libidn library, implementation
ii  libncursesw5             5.7+20090404-1  shared libraries for terminal hand
ii  libsasl2-2               2.1.22.dfsg1-23 Cyrus SASL - authentication abstra
ii  mutt                     1.5.18-6        text-based mailreader supporting M

mutt-patched recommends no packages.

mutt-patched suggests no packages.
--- Begin Message ---
When using IMAP, a '.' is often used as a separator instead of '/'.
This patch enables mutt to find these dots and
1. correctly intend the dir in the sidebar
2. if "sidebar_shortpath" is set, shorten the dir to the part after
   the last dot

I hope, it's usefull for someone ;)

Index: mutt-1.5.18/sidebar.c
===================================================================
--- mutt-1.5.18.orig/sidebar.c  2008-11-06 18:36:26.000000000 +0100
+++ mutt-1.5.18/sidebar.c       2008-11-06 18:37:18.000000000 +0100
@@ -255,14 +255,23 @@
                        int i;
                        tmp_folder_name = tmp->path + strlen(Maildir);
                        for (i = 0; i < strlen(tmp->path) - strlen(Maildir); 
i++) {
-                               if (tmp_folder_name[i] == '/') 
sidebar_folder_depth++;
+                               if (tmp_folder_name[i] == '/'  || 
tmp_folder_name[i] == '.') sidebar_folder_depth++;
                        }   
                        if (sidebar_folder_depth > 0) {
-                               sidebar_folder_name = 
malloc(strlen(basename(tmp->path)) + sidebar_folder_depth + 1);
+                               if (option(OPTSIDEBARSHORTPATH)) {
+                                       tmp_folder_name = strrchr(tmp->path, 
'.');
+                                       if (tmp_folder_name == NULL)
+                                               tmp_folder_name = tmp->path;
+                                       else
+                                               tmp_folder_name++;
+                               }
+                               else
+                                       tmp_folder_name = tmp->path;
+                               sidebar_folder_name = 
malloc(strlen(basename(tmp_folder_name)) + sidebar_folder_depth + 1);
                                for (i=0; i < sidebar_folder_depth; i++)
                                        sidebar_folder_name[i]=' ';
                                sidebar_folder_name[i]=0;
-                               strncat(sidebar_folder_name, 
basename(tmp->path), strlen(basename(tmp->path)) + sidebar_folder_depth);
+                               strncat(sidebar_folder_name, 
basename(tmp_folder_name), strlen(basename(tmp_folder_name)) + 
sidebar_folder_depth);
                        }
                }
                printw( "%.*s", SidebarWidth - delim_len + 1,
Index: mutt-1.5.18/init.h
===================================================================
--- mutt-1.5.18.orig/init.h     2008-11-06 18:37:26.000000000 +0100
+++ mutt-1.5.18/init.h  2008-11-06 18:37:47.000000000 +0100
@@ -1548,6 +1548,11 @@
   ** .pp
   ** The width of the sidebar.
   */
+  { "sidebar_shortpath", DT_BOOL, R_BOTH, OPTSIDEBARSHORTPATH, 0 },
+  /*
+  ** .pp
+  ** Should the sidebar shorten the path showed.
+  */
   { "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:37:55.000000000 +0100
+++ mutt-1.5.18/mutt.h  2008-11-06 18:38:10.000000000 +0100
@@ -438,6 +438,7 @@
   OPTSAVENAME,
   OPTSCORE,
   OPTSIDEBAR,
+  OPTSIDEBARSHORTPATH,
   OPTSIGDASHES,
   OPTSIGONTOP,
   OPTSORTRE,

--- End Message ---
--- Begin Message ---
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,

--- End Message ---

Reply via email to