Make emacs prefer an existing ~/.emacs.d to an existing XDG location

* doc/emacs/custom.texi (Find Init): Update description of how Emacs
finds its init file directory and the interaction with
$XDG_CONFIG_HOME
(Early Init File): Correct XDG location of early-init.el

* etc/NEWS: Update description to make it clear the ~/.emacs.d is
preferred, even if the XDG location exists.

* lisp/startup.el: Prefer ~/.emacs.d even if the XDG location exists.

* lib-src/emacsclient.c (open_config): Prefer home directory the XDG
location.
This commit is contained in:
Robert Pluim 2020-01-15 12:24:43 +01:00
parent 91cac24952
commit 13995f31a2
4 changed files with 73 additions and 62 deletions

View file

@ -924,21 +924,22 @@ open_config (char const *home, char const *xdg, char const *config_file)
char *configname = xmalloc (max (xdgsubdirsize, homesubdirsizemax)
+ strlen (config_file));
FILE *config;
if (xdg || home)
if (home)
{
strcpy ((xdg
? stpcpy (stpcpy (configname, xdg), "/emacs/server/")
: stpcpy (stpcpy (configname, home), "/.config/emacs/server/")),
config_file);
strcpy (stpcpy (stpcpy (configname, home), "/.emacs.d/server/"),
config_file);
config = fopen (configname, "rb");
}
else
config = NULL;
if (! config && home)
if (! config && (xdg || home))
{
strcpy (stpcpy (stpcpy (configname, home), "/.emacs.d/server/"),
config_file);
strcpy ((xdg
? stpcpy (stpcpy (configname, xdg), "/emacs/server/")
: stpcpy (stpcpy (configname, home), "/.config/emacs/server/")),
config_file);
config = fopen (configname, "rb");
}