]> granicus.if.org Git - neomutt/commitdiff
feat: use mailbox description for spoolfile 1708/head
authorAustin Ray <austin@austinray.io>
Fri, 10 May 2019 00:05:22 +0000 (20:05 -0400)
committerRichard Russon <rich@flatcap.org>
Fri, 10 May 2019 21:36:36 +0000 (22:36 +0100)
'spoolfile' is limited to mailboxes paths so if one wants to use a
'named-mailboxes' or 'virtual-mailboxes' as the spoolfile, its path must
be duplicated in the 'spoolfile' assignment. 'virtual-mailboxes' has a
helper variable, 'virtual_spoolfile', for selecting the first
'virtual-mailboxes' entry as the spoolfile.

This commit allows one to use a mailbox description for the 'spoolfile,
which removes the need to duplicate a 'named-mailboxes' or
'virtual-mailboxes' path and makes 'virtual_spoolfile' defunct. The
configuration syntax is now more consistent.

It is important to note that mailbox descriptions are preferred to
paths.

To reflect the change, documentation was updated:
 - Add note to 'spoolfile' about using a string to specify a
   'named-mailboxes' or 'virtual-mailboxes' description.
 - Add a note to the 'virtual_spoolfile' documentation saying that it is no
   longer necessary since 'spoolfile' supports descriptions now.

doc/manual.xml.head
init.h
main.c

index 49f5caf1ee76d643890646fc60f8fd561c68265f..3896798de8a331821a0ce96df47a5776fbe0942d 100644 (file)
@@ -15272,12 +15272,13 @@ virtual-mailboxes "My INBOX" "notmuch://?query=tag:inbox"
 
         <table id="table-notmuch-variables">
           <title>Notmuch Variables</title>
-          <tgroup cols="3">
+          <tgroup cols="4">
             <thead>
               <row>
                 <entry>Name</entry>
                 <entry>Type</entry>
                 <entry>Default</entry>
+                <entry>Note</entry>
               </row>
             </thead>
             <tbody>
@@ -15285,51 +15286,64 @@ virtual-mailboxes "My INBOX" "notmuch://?query=tag:inbox"
                 <entry><literal>nm_db_limit</literal></entry>
                 <entry>number</entry>
                 <entry><literal>0</literal></entry>
+                <entry></entry>
               </row>
               <row>
                 <entry><literal>nm_default_uri</literal></entry>
                 <entry>string</entry>
                 <entry>(empty)</entry>
+                <entry></entry>
               </row>
               <row>
                 <entry><literal>nm_exclude_tags</literal></entry>
                 <entry>string</entry>
                 <entry>(empty)</entry>
+                <entry></entry>
               </row>
               <row>
                 <entry><literal>nm_open_timeout</literal></entry>
                 <entry>number</entry>
                 <entry><literal>5</literal></entry>
+                <entry></entry>
               </row>
               <row>
                 <entry><literal>nm_query_type</literal></entry>
                 <entry>string</entry>
                 <entry><literal>messages</literal></entry>
+                <entry></entry>
               </row>
               <row>
                 <entry><literal>nm_record</literal></entry>
                 <entry>boolean</entry>
                 <entry><literal>no</literal></entry>
+                <entry></entry>
               </row>
               <row>
                 <entry><literal>nm_record_tags</literal></entry>
                 <entry>string</entry>
                 <entry>(empty)</entry>
+                <entry></entry>
               </row>
               <row>
                 <entry><literal>nm_unread_tag</literal></entry>
                 <entry>string</entry>
                 <entry><literal>unread</literal></entry>
+                <entry></entry>
               </row>
               <row>
                 <entry><literal>vfolder_format</literal></entry>
                 <entry>string</entry>
                 <entry><literal>%6n(%6N) %f</literal></entry>
+                <entry></entry>
               </row>
               <row>
                 <entry><literal>virtual_spoolfile</literal></entry>
                 <entry>boolean</entry>
                 <entry><literal>no</literal></entry>
+                <entry>
+                  Unnecessary since <link linkend="spoolfile">$spoolfile</link>
+                  supports mailbox descriptions.
+                </entry>
               </row>
             </tbody>
           </tgroup>
diff --git a/init.h b/init.h
index 7cc97cd0f1abf3393fd9bd596c0f54a5304fefea..5c5a45e10a49a846e896ee393a1349d5bf28748b 100644 (file)
--- a/init.h
+++ b/init.h
@@ -4205,7 +4205,8 @@ struct ConfigDef MuttVars[] = {
   /*
   ** .pp
   ** If your spool mailbox is in a non-default place where NeoMutt can't find
-  ** it, you can specify its location with this variable.
+  ** it, you can specify its location with this variable. The description from
+  ** "named-mailboxes" or "virtual-mailboxes" may be used for the spoolfile.
   ** .pp
   ** If not specified, then the environment variables \fC$$$MAIL\fP and
   ** \fC$$$MAILDIR\fP will be checked.
@@ -4684,6 +4685,9 @@ struct ConfigDef MuttVars[] = {
   ** .pp
   ** When \fIset\fP, NeoMutt will use the first defined virtual mailbox (see
   ** virtual-mailboxes) as a spool file.
+  **
+  ** This command is now unnecessary. $$spoolfile has been extended to support
+  ** mailbox descriptions as a value.
   */
 #endif
   { "visual", DT_COMMAND, R_NONE, &C_Visual, IP "vi" },
diff --git a/main.c b/main.c
index a82d9bcf1298d91b664bdb7bd95bd0587ceec2b9..64244ca7c375ec4fbbec268591308cedabd96b47 100644 (file)
--- a/main.c
+++ b/main.c
@@ -1168,7 +1168,14 @@ int main(int argc, char *argv[], char *envp[])
     if (mutt_buffer_len(folder) == 0)
     {
       if (C_Spoolfile)
-        mutt_buffer_strcpy(folder, C_Spoolfile);
+      {
+        // Check if C_Spoolfile corresponds a mailboxes' description.
+        struct Mailbox *desc_m = mutt_find_mailbox_desc(C_Spoolfile);
+        if (desc_m)
+          mutt_buffer_strcpy(folder, desc_m->realpath);
+        else
+          mutt_buffer_strcpy(folder, C_Spoolfile);
+      }
       else if (C_Folder)
         mutt_buffer_strcpy(folder, C_Folder);
       /* else no folder */