summarylogtreecommitdiffstats
path: root/sidebar-dotpathsep.patch
diff options
context:
space:
mode:
authorOscar Morante2015-06-11 14:34:58 +0300
committerOscar Morante2015-06-11 14:35:29 +0300
commite6384b51f68c57d993111a2a0faf8a2bdd69bb32 (patch)
tree30ecb81ba7e885e11deb6ba536bf6893bacc0c5f /sidebar-dotpathsep.patch
downloadaur-e6384b51f68c57d993111a2a0faf8a2bdd69bb32.tar.gz
initial import
Diffstat (limited to 'sidebar-dotpathsep.patch')
-rw-r--r--sidebar-dotpathsep.patch98
1 files changed, 98 insertions, 0 deletions
diff --git a/sidebar-dotpathsep.patch b/sidebar-dotpathsep.patch
new file mode 100644
index 000000000000..5649ca4bdb21
--- /dev/null
+++ b/sidebar-dotpathsep.patch
@@ -0,0 +1,98 @@
+From: Fabian Groffen <grobian@gentoo.org>
+Date: Tue, 4 Mar 2014 21:12:15 +0100
+Subject: sidebar-dotpathsep
+
+Make path separators for sidebar folders configurable.
+
+When using IMAP, a '.' is often used as path separator, hence make the
+path separators configurable through sidebar_delim_chars variable.
+It defaults to "/." to work for both mboxes as well as IMAP folders. It
+can be set to only "/" or "." or whichever character desired as needed.
+
+Gbp-Pq: Topic mutt-patched
+---
+ globals.h | 1 +
+ init.h | 8 ++++++++
+ sidebar.c | 31 ++++++++++++++++++++++++-------
+ 3 files changed, 33 insertions(+), 7 deletions(-)
+
+diff --git a/globals.h b/globals.h
+index 3f83328..61765a4 100644
+--- a/globals.h
++++ b/globals.h
+@@ -118,6 +118,7 @@ WHERE char *SendCharset;
+ WHERE char *Sendmail;
+ WHERE char *Shell;
+ WHERE char *SidebarDelim;
++WHERE char *SidebarDelimChars INITVAL (NULL);
+ WHERE char *Signature;
+ WHERE char *SimpleSearch;
+ #if USE_SMTP
+diff --git a/init.h b/init.h
+index 502f570..b0784d8 100644
+--- a/init.h
++++ b/init.h
+@@ -2001,6 +2001,14 @@ struct option_t MuttVars[] = {
+ ** .pp
+ ** The width of the sidebar.
+ */
++ { "sidebar_delim_chars", DT_STR, R_NONE, UL &SidebarDelimChars, UL "/." },
++ /*
++ ** .pp
++ ** This contains the list of characters which you would like to treat
++ ** as folder separators for displaying paths in the sidebar. If
++ ** you're not using IMAP folders, you probably prefer setting this to "/"
++ ** alone.
++ */
+ { "pgp_use_gpg_agent", DT_BOOL, R_NONE, OPTUSEGPGAGENT, 0},
+ /*
+ ** .pp
+diff --git a/sidebar.c b/sidebar.c
+index 6098c2a..4356ffc 100644
+--- a/sidebar.c
++++ b/sidebar.c
+@@ -249,20 +249,37 @@ int draw_sidebar(int menu) {
+ // calculate depth of current folder and generate its display name with indented spaces
+ int sidebar_folder_depth = 0;
+ char *sidebar_folder_name;
+- sidebar_folder_name = basename(tmp->path);
++ int i;
++ sidebar_folder_name = tmp->path;
++ /* disregard a trailing separator, so strlen() - 2
++ * https://bugs.gentoo.org/show_bug.cgi?id=373197#c16 */
++ for (i = strlen(sidebar_folder_name) - 2; i >= 0; i--) {
++ if (SidebarDelimChars &&
++ strchr(SidebarDelimChars, sidebar_folder_name[i]))
++ {
++ sidebar_folder_name += i + 1;
++ break;
++ }
++ }
+ if ( maildir_is_prefix ) {
+ char *tmp_folder_name;
+- int i;
++ int lastsep = 0;
+ 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++;
+- }
++ for (i = 0; i < strlen(tmp_folder_name) - 1; i++) {
++ if (SidebarDelimChars &&
++ strchr(SidebarDelimChars, tmp_folder_name[i]))
++ {
++ sidebar_folder_depth++;
++ lastsep = i + 1;
++ }
++ }
+ if (sidebar_folder_depth > 0) {
+- sidebar_folder_name = malloc(strlen(basename(tmp->path)) + sidebar_folder_depth + 1);
++ tmp_folder_name += lastsep; /* basename */
++ sidebar_folder_name = malloc(strlen(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, tmp_folder_name, strlen(tmp_folder_name) + sidebar_folder_depth);
+ }
+ }
+ printw( "%.*s", SidebarWidth - delim_len + 1,