]> granicus.if.org Git - neomutt/commit
search muttrc file according to XDG Base Specification (closes #3207)
authorDamien Riegel <damien.riegel@gmail.com>
Mon, 14 Nov 2016 02:45:35 +0000 (18:45 -0800)
committerRichard Russon <rich@flatcap.org>
Fri, 30 Dec 2016 20:05:36 +0000 (20:05 +0000)
commita07b7a054869d2765b76a492e9ad26f384235a2d
treea49711ad96c89d02b4b2de966af8ad4382273fd9
parentf6751032805585f10f1774b0d2285d4d3d0ad894
search muttrc file according to XDG Base Specification (closes #3207)

First of all, the MUTT_VERSION symbol is now concatenated (when
possible) at compile time.

Then, the logic to find the config file has been changed a bit to remove
unnecessary calls to access(), so now each possible locations for the
config file is only tested once, and it stops as soon as a valid one has
been found. So instead of:

  access("/home/dkc/.muttrc-1.7.1", F_OK) = -1 ENOENT (No such file or directory)
  access("/home/dkc/.muttrc", F_OK)       = 0
  access("/home/dkc/.muttrc", F_OK)       = 0
  access("/home/dkc/.muttrc", F_OK)       = 0
  [... Tests for Muttrc ... ]
  access("/home/dkc/.muttrc", F_OK)       = 0

We now have:

  access("/home/dkc/.muttrc-1.7+13 (f658e517960e)", F_OK) = -1 ENOENT (No such file or directory)
  access("/home/dkc/.muttrc", F_OK)       = 0

It also cleans up the case where -F is passed on the command line but
points to a non-existent file by moving the error path closer to the
actual fail condition.

Finally, it adds partial support for the XDG Base Directory
Specification. mutt will now try to locate its config at:

  $XDG_CONFIG_HOME/mutt/muttrc-MUTT_VERSION
  $XDG_CONFIG_HOME/mutt/muttrc.

If XDG_CONFIG_HOME is not set, it will use '~/.config' as a default.
init.c