From: pdmef Date: Fri, 13 Jan 2006 08:51:23 +0000 (+0000) Subject: From: Jean-Baptiste Quenot X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=commitdiff_plain;h=1f02569d622173cfd4c39f56d1e0e1f488b7c73e From: Jean-Baptiste Quenot Rocco Rutte: - be more clever for $muttng_folder_name: strip $folder if present upon match git-svn-id: svn://svn.berlios.de/mutt-ng/trunk@773 e385b8ad-14ed-0310-8656-cc95a2468c6d --- diff --git a/UPGRADING b/UPGRADING index 588f54b..cd4f75c 100644 --- a/UPGRADING +++ b/UPGRADING @@ -10,6 +10,10 @@ This document is not the place for verbose documentation; it only offers the necessary keywords to look them up in the manual, ChangeLog or other sources of information. +2006-01-13: + + The semantics for $muttng_folder_name has slightly changed, see docs. + 2005-10-23: The %u expando for $sidebar_number_format has been added. diff --git a/init.c b/init.c index 32f913b..734f88e 100644 --- a/init.c +++ b/init.c @@ -279,10 +279,26 @@ static void sys_to_string (char* dst, size_t dstlen, val = CurrentFolder; } else if (ascii_strcmp ("muttng_folder_name", option->option) == 0 && CurrentFolder && *CurrentFolder) { - if ((t = strrchr (CurrentFolder, '/')) != NULL) + + size_t Maildirlength = str_len (Maildir); + + /* + * if name starts with $folder, just strip it to keep hierarchy + * $folder=imap://host, path=imap://host/inbox/b -> inbox/b + */ + if (Maildirlength > 0 && str_ncmp (CurrentFolder, Maildir, + Maildirlength) == 0 && + str_len (CurrentFolder) > Maildirlength) { + val = CurrentFolder + Maildirlength; + if (Maildir[strlen(Maildir)-1]!='/') + val += 1; + /* if not $folder, just use everything after last / */ + } else if ((t = strrchr (CurrentFolder, '/')) != NULL) val = t+1; + /* default: use as-is */ else val = CurrentFolder; + } else val = option->init; diff --git a/init.h b/init.h index 6bb6a05..1966bd0 100644 --- a/init.h +++ b/init.h @@ -1529,9 +1529,20 @@ struct option_t MuttVars[] = { /* ** .pp ** \fIThis is a read-only system property and, at runtime, - ** specifies the last part of the full path or URI of the - ** folder currently open (if any), i.e. everything after - ** the last ``/''.\fP + ** specifies the actual name of the folder as far as it could + ** be detected.\fP + ** .pp + ** For detection, $$$folder is first taken into account + ** and simply stripped to form the result when a match is found. For + ** example, with $$$folder being \fTimap://host\fP and the folder is + ** \fTimap://host/INBOX/foo\fP, $$$muttng_folder_name will be just + ** \fTINBOX/foo\fP.) + ** .pp + ** Second, if the initial portion of a name is not $$$folder, + ** the result will be everything after the last ``/''. + ** .pp + ** Third and last, the result will be just the name if neither + ** $$$folder nor a ``/'' were found in the name. */ {"muttng_pwd", DT_SYS, R_NONE, 0, "" }, /*