This keeps things in order: first locate and source global config file, then locate and source user's config file. That way, it's obvious that user settings overrides global settings. --- init.c | 61 +++++++++++++++++++++++++++++-------------------------------- 1 file changed, 29 insertions(+), 32 deletions(-)
diff --git a/init.c b/init.c index d594c74..ab2b398 100644 --- a/init.c +++ b/init.c @@ -3186,38 +3186,6 @@ void mutt_init (int skip_sys_rc, LIST *commands) * */ - if (!Muttrc) - { - char *xdg_cfg_home = getenv ("XDG_CONFIG_HOME"); - - if (!xdg_cfg_home && Homedir) - { - snprintf (buffer, sizeof (buffer), "%s/.config", Homedir); - xdg_cfg_home = buffer; - } - - Muttrc = mutt_find_cfg (Homedir, xdg_cfg_home); - } - else - { - strfcpy (buffer, Muttrc, sizeof (buffer)); - FREE (&Muttrc); - mutt_expand_path (buffer, sizeof (buffer)); - Muttrc = safe_strdup (buffer); - if (access (Muttrc, F_OK)) - { - snprintf (buffer, sizeof (buffer), "%s: %s", Muttrc, strerror (errno)); - mutt_endwin (buffer); - exit (1); - } - } - - if (Muttrc) - { - FREE (&AliasFile); - AliasFile = safe_strdup (Muttrc); - } - /* Process the global rc file if it exists and the user hasn't explicity requested not to via "-n". */ if (!skip_sys_rc) @@ -3250,9 +3218,38 @@ void mutt_init (int skip_sys_rc, LIST *commands) } } + if (!Muttrc) + { + char *xdg_cfg_home = getenv ("XDG_CONFIG_HOME"); + + if (!xdg_cfg_home && Homedir) + { + snprintf (buffer, sizeof (buffer), "%s/.config", Homedir); + xdg_cfg_home = buffer; + } + + Muttrc = mutt_find_cfg (Homedir, xdg_cfg_home); + } + else + { + strfcpy (buffer, Muttrc, sizeof (buffer)); + FREE (&Muttrc); + mutt_expand_path (buffer, sizeof (buffer)); + Muttrc = safe_strdup (buffer); + if (access (Muttrc, F_OK)) + { + snprintf (buffer, sizeof (buffer), "%s: %s", Muttrc, strerror (errno)); + mutt_endwin (buffer); + exit (1); + } + } + /* Read the user's initialization file. */ if (Muttrc) { + FREE (&AliasFile); + AliasFile = safe_strdup (Muttrc); + if (!option (OPTNOCURSES)) endwin (); if (source_rc (Muttrc, &err) != 0) -- 2.10.2