47c92a87c8
This change uses a different patchset for mutt-with-sidebar.
99 lines
3.3 KiB
Diff
99 lines
3.3 KiB
Diff
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 004c795..602f932 100644
|
|
--- a/globals.h
|
|
+++ b/globals.h
|
|
@@ -119,6 +119,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 c664e5f..166671b 100644
|
|
--- a/init.h
|
|
+++ b/init.h
|
|
@@ -2051,6 +2051,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,
|