From: Jean-Baptiste Quenot <jb.quenot@caraldi.com>
authorpdmef <pdmef@e385b8ad-14ed-0310-8656-cc95a2468c6d>
Fri, 13 Jan 2006 08:51:23 +0000 (08:51 +0000)
committerpdmef <pdmef@e385b8ad-14ed-0310-8656-cc95a2468c6d>
Fri, 13 Jan 2006 08:51:23 +0000 (08:51 +0000)
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

UPGRADING
init.c
init.h

index 588f54b..cd4f75c 100644 (file)
--- 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 (file)
--- 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 (file)
--- 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, "" },
   /*