]> granicus.if.org Git - neomutt/commitdiff
sync xdg config file handling
authorRichard Russon <rich@flatcap.org>
Wed, 28 Dec 2016 22:54:37 +0000 (22:54 +0000)
committerRichard Russon <rich@flatcap.org>
Fri, 30 Dec 2016 20:05:36 +0000 (20:05 +0000)
doc/Makefile.am
doc/manual.xml.head
init.c
muttlib.c

index 51d9c271a632caa890e3ab4543aea69c5af1a379..9c511380f3e825e9d9554f2bc3b28c392c50f676 100644 (file)
@@ -218,8 +218,8 @@ smime_keys.1: $(srcdir)/smime_keys.man
 stamp-doc-xml: makedoc$(EXEEXT) $(top_srcdir)/init.h \
                manual.xml.head $(top_srcdir)/functions.h $(top_srcdir)/OPS* manual.xml.tail \
                $(srcdir)/gen-map-doc
-       ( date=`head -n 1 $(top_srcdir)/ChangeLog.neomutt | LC_ALL=C cut -b 1-10` && \
-         sed -e "s/@VERSION\@/$(PACKAGE_VERSION) (1.7.1)/" $(srcdir)/manual.xml.head && \
+       ( mutt_ver=`sed -n -e '/MUTT_VERSION/s/.*"\(.*\)".*/\1/p' $(top_srcdir)/config.h` && \
+         sed -e "s/@VERSION\@/$(PACKAGE_VERSION) ($$mutt_ver)/" $(srcdir)/manual.xml.head && \
          $(MAKEDOC_CPP) $(top_srcdir)/init.h | ./makedoc$(EXEEXT) -s && \
          $(MAKEDOC_CPP) $(top_srcdir)/functions.h | \
            perl $(srcdir)/gen-map-doc $(srcdir)/manual.xml.tail $(top_srcdir)/OPS* \
index 03d5911e9050d88cdf026c854642a6c651b37b14..a91e3a248a843b589b8678ea9f1ad904fa8fa6c6 100644 (file)
@@ -2349,75 +2349,126 @@ See also the <link linkend="postpone">$postpone</link> quad-option.
 <title>Location of Initialization Files</title>
 
 <para>
-  When Mutt starts up it looks for two configuration files -- a
-  <quote>system</quote> file and a <quote>user</quote> file.
+  When Mutt starts up it looks for two configuration files -- one
+  <quote>system</quote> file and one <quote>user</quote> file.
 </para>
 
 <para>
-  Mutt will search for a system config file in several places.  The filenames
-  may depend on the version number of Mutt.  Mutt will read just one file, the
-  first file it finds, from the list below.
+  Mutt searches for several different file names when looking for config.  It
+  looks for NeoMutt config files before Mutt config files and versioned config
+  before plain config.  For example:
 </para>
 
-<para>
-  The system config file will not be read if the <quote>-n</quote>
-  option is used on the <link linkend="commandline">command line</link>.
-</para>
-
-<table id="system-muttrc">
-  <title>Mutt system config file locations</title>
+<table id="muttrc-order">
+  <title>Mutt config file search order</title>
   <tgroup cols="1">
-    <thead>
-      <row><entry>File Location</entry></row>
-    </thead>
     <tbody>
-      <row><entry>$XDG_CONFIG_DIRS/neomutt/config</entry></row>
-      <row><entry>/etc/NeoMuttrc</entry></row>
-      <row><entry>/etc/Muttrc-20161104</entry></row>
-      <row><entry>/etc/Muttrc</entry></row>
-      <row><entry>/usr/share/mutt/Muttrc-20161104</entry></row>
-      <row><entry>/usr/share/mutt/Muttrc</entry></row>
+      <row><entry>neomuttrc-20161126</entry></row> 
+      <row><entry>neomuttrc</entry></row>          
+      <row><entry>muttrc-1.7.2</entry></row>       
+      <row><entry>muttrc</entry></row>             
     </tbody>
   </tgroup>
 </table>
 
 <para>
-  <emphasis>($XDG_CONFIG_DIRS defaults to "/etc/xdg".)</emphasis>
+  This allows the user to create separate Mutt and NeoMutt config files on the
+  same system.
 </para>
 
-<para>
-  Mutt will search for a user config file in several places in your home
-  directory.  The filenames may depend on the version number of Mutt.  Mutt
-  will read just one file, the first file it finds, from the list below.
-</para>
+<sect2 id="muttrc-system">
+  <title>Location of Mutt system config files</title>
 
-<para>
-  You may specify your own location for the user config file using the
-  <quote>-F</quote> option on the <link linkend="commandline">command line</link>.
-</para>
+  <para>
+    Mutt will search for a system config file in a <literal>mutt</literal>
+    directory in several places.  First it searches the locations specified in
+    the <literal>XDG_CONFIG_DIRS</literal> environment variable, which defaults
+    to <literal>/etc/xdg</literal>.  Next, it looks in <literal>/etc</literal>.
+    Finally, it tries <literal>/usr/share</literal>.
+  </para>
 
-<table id="user-muttrc">
-  <title>Mutt user config file locations</title>
-  <tgroup cols="1">
-    <thead>
-      <row><entry>File Location</entry></row>
-    </thead>
-    <tbody>
-      <row><entry>$XDG_CONFIG_HOME/neomutt/config</entry></row>
-      <row><entry>~/.neomuttrc</entry></row>
-      <row><entry>~/.mutt/neomuttrc</entry></row>
-      <row><entry>~/.muttrc-20161104</entry></row>
-      <row><entry>~/.muttrc</entry></row>
-      <row><entry>~/.mutt/muttrc-20161104</entry></row>
-      <row><entry>~/.mutt/muttrc</entry></row>
-      <row><entry>~/.muttrc</entry></row>
-    </tbody>
-  </tgroup>
-</table>
+  <para>
+    The system config file will not be read if the <quote>-n</quote>
+    option is used on the <link linkend="commandline">command line</link>.
+  </para>
 
-<para>
-  <emphasis>($XDG_CONFIG_HOME defaults to "$HOME/.config".)</emphasis>
-</para>
+  <para>
+    Mutt will read just one file, the first file it finds, from the list below.
+  </para>
+
+  <table id="muttrc-system-files">
+    <title>Mutt system config file locations</title>
+    <tgroup cols="2">
+      <thead>
+        <row>
+          <entry>File Location</entry>
+          <entry>Notes</entry>
+        </row>
+      </thead>
+      <tbody>
+        <row><entry>/etc/xdg/mutt/neomuttrc-20161126</entry><entry>NeoMutt release version</entry></row> 
+        <row><entry>/etc/xdg/mutt/neomuttrc</entry></row>          
+        <row><entry>/etc/xdg/mutt/Muttrc-1.7.2</entry><entry>Mutt release version, Note the case of the filename</entry></row>       
+        <row><entry>/etc/xdg/mutt/Muttrc</entry><entry>Note the case of the filename</entry></row>             
+        <row><entry>/etc/mutt/neomuttrc-20161126</entry><entry>NeoMutt release version</entry></row> 
+        <row><entry>/etc/mutt/neomuttrc</entry></row>          
+        <row><entry>/etc/mutt/Muttrc-1.7.2</entry><entry>Mutt release version, Note the case of the filename</entry></row>       
+        <row><entry>/etc/mutt/Muttrc</entry><entry>Note the case of the filename</entry></row>             
+        <row><entry>/usr/share/mutt/neomuttrc-20161126</entry><entry>NeoMutt release version</entry></row>
+        <row><entry>/usr/share/mutt/neomuttrc</entry></row>
+        <row><entry>/usr/share/mutt/Muttrc-1.7.2</entry><entry>Mutt release version, Note the case of the filename</entry></row>
+        <row><entry>/usr/share/mutt/Muttrc</entry><entry>Note the case of the filename</entry></row>
+      </tbody>
+    </tgroup>
+  </table>
+</sect2>
+
+<sect2 id="muttrc-user">
+  <title>Location of Mutt system config files</title>
+
+  <para>
+    Mutt will search for a user config file in several places.  First it looks
+    in the directory specified in the <literal>XDG_CONFIG_HOME</literal>
+    environment variable, which defaults to <literal>~/.config/mutt</literal>.
+    Next, it looks in <literal>~</literal> (your home directory).  Finally, it
+    tries <literal>~/.mutt</literal>.
+  </para>
+
+  <para>
+    You may specify your own location for the user config file using the
+    <quote>-F</quote> option on the <link linkend="commandline">command line</link>.
+  </para>
+
+  <para>
+    Mutt will read just one file, the first file it finds, from the list below.
+  </para>
+
+  <table id="muttrc-user-files">
+    <title>Mutt user config file locations</title>
+    <tgroup cols="2">
+      <thead>
+        <row>
+          <entry>File Location</entry>
+          <entry>Notes</entry>
+        </row>
+      </thead>
+      <tbody>
+        <row><entry>~/.config/mutt/neomuttrc-20161126</entry><entry>NeoMutt release version</entry></row> 
+        <row><entry>~/.config/mutt/neomuttrc</entry></row>          
+        <row><entry>~/.config/mutt/muttrc-1.7.2</entry><entry>Mutt release version</entry></row>       
+        <row><entry>~/.config/mutt/muttrc</entry></row>             
+        <row><entry>~/.neomuttrc-20161126</entry><entry>NeoMutt release version</entry></row> 
+        <row><entry>~/.neomuttrc</entry></row>          
+        <row><entry>~/.muttrc-1.7.2</entry><entry>Mutt release version</entry></row>       
+        <row><entry>~/.muttrc</entry></row>             
+        <row><entry>~/.mutt/neomuttrc-20161126</entry><entry>NeoMutt release version</entry></row> 
+        <row><entry>~/.mutt/neomuttrc</entry></row>          
+        <row><entry>~/.mutt/muttrc-1.7.2</entry><entry>Mutt release version</entry></row>       
+        <row><entry>~/.mutt/muttrc</entry></row>             
+      </tbody>
+    </tgroup>
+  </table>
+</sect2>
 
 </sect1>
 
diff --git a/init.c b/init.c
index 8618343499cb12420f20ec8962536ed5c1425a2f..58e465b03f99f92a35453bba24bdd6e3137cfc57 100644 (file)
--- a/init.c
+++ b/init.c
@@ -3426,6 +3426,8 @@ static char* mutt_find_cfg (const char *home, const char *xdg_cfg_home)
 {
   const char* names[] =
   {
+    "neomuttrc-" PACKAGE_VERSION,
+    "neomuttrc",
     "muttrc-" MUTT_VERSION,
     "muttrc",
     NULL,
@@ -3433,9 +3435,9 @@ static char* mutt_find_cfg (const char *home, const char *xdg_cfg_home)
 
   const char* locations[][2] =
   {
+    { xdg_cfg_home, "mutt/", },
     { home, ".", },
     { home, ".mutt/" },
-    { xdg_cfg_home, "mutt/", },
     { NULL, NULL },
   };
 
@@ -3736,11 +3738,15 @@ void mutt_init (int skip_sys_rc, LIST *commands)
       if (mutt_set_xdg_path (kXDGConfigDirs, buffer, sizeof buffer))
         break;
 
-      snprintf (buffer, sizeof buffer, "%s/NeoMuttrc", SYSCONFDIR);
+      snprintf (buffer, sizeof buffer, "%s/neomuttrc-%s", SYSCONFDIR, PACKAGE_VERSION);
+      if (access (buffer, F_OK) == 0)
+        break;
+
+      snprintf (buffer, sizeof buffer, "%s/neomuttrc", SYSCONFDIR);
       if (access (buffer, F_OK) == 0)
         break;
 
-      snprintf (buffer, sizeof buffer, "%s/Muttrc-%s", SYSCONFDIR, PACKAGE_VERSION);
+      snprintf (buffer, sizeof buffer, "%s/Muttrc-%s", SYSCONFDIR, MUTT_VERSION);
       if (access (buffer, F_OK) == 0)
         break;
 
@@ -3748,7 +3754,15 @@ void mutt_init (int skip_sys_rc, LIST *commands)
       if (access (buffer, F_OK) == 0)
         break;
 
-      snprintf (buffer, sizeof buffer, "%s/Muttrc-%s", PKGDATADIR, PACKAGE_VERSION);
+      snprintf (buffer, sizeof buffer, "%s/neomuttrc-%s", PKGDATADIR, PACKAGE_VERSION);
+      if (access (buffer, F_OK) == 0)
+        break;
+
+      snprintf (buffer, sizeof buffer, "%s/neomuttrc", PKGDATADIR);
+      if (access (buffer, F_OK) == 0)
+        break;
+
+      snprintf (buffer, sizeof buffer, "%s/Muttrc-%s", PKGDATADIR, MUTT_VERSION);
       if (access (buffer, F_OK) == 0)
         break;
 
index c1719337be94f1ab65125b70e7d1f926bb4517c2..f482ed31168cc3b13cd19bcfc4633914567cda65 100644 (file)
--- a/muttlib.c
+++ b/muttlib.c
@@ -2175,21 +2175,49 @@ int mutt_set_xdg_path(const XDGType type, char *buf, size_t bufsize)
   char *xdg     = (xdg_env && *xdg_env) ? safe_strdup (xdg_env) : safe_strdup (xdg_defaults[type]);
   char *x       = xdg;  /* strsep() changes xdg, so free x instead later */
   char *token   = NULL;
+  int   rc      = 0;
 
   while ((token = strsep (&xdg, ":")))
   {
-    if (snprintf (buf, bufsize, "%s/neomutt/config", token) < 0)
+    if (snprintf (buf, bufsize, "%s/%s/neomuttrc-%s", token, PACKAGE, PACKAGE_VERSION) < 0)
       continue;
     mutt_expand_path (buf, bufsize);
     if (access (buf, F_OK) == 0)
     {
-      FREE (&x);
-      return 1;
+      rc = 1;
+      break;
+    }
+
+    if (snprintf (buf, bufsize, "%s/%s/neomuttrc", token, PACKAGE) < 0)
+      continue;
+    mutt_expand_path (buf, bufsize);
+    if (access (buf, F_OK) == 0)
+    {
+      rc = 1;
+      break;
+    }
+
+    if (snprintf (buf, bufsize, "%s/%s/Muttrc-%s", token, PACKAGE, MUTT_VERSION) < 0)
+      continue;
+    mutt_expand_path (buf, bufsize);
+    if (access (buf, F_OK) == 0)
+    {
+      rc = 1;
+      break;
+    }
+
+    if (snprintf (buf, bufsize, "%s/%s/Muttrc", token, PACKAGE) < 0)
+      continue;
+    mutt_expand_path (buf, bufsize);
+    if (access (buf, F_OK) == 0)
+    {
+      rc = 1;
+      break;
     }
   }
 
   FREE (&x);
-  return 0;
+  return rc;
 }
 
 void mutt_get_parent_path (char *output, char *path, size_t olen)