Commit a4144af9 authored by Paul Eggert's avatar Paul Eggert

Prefer ~/.config/emacs to ~/.emacs.d if neither exists

That way, when Emacs starts in a fresh home directory,
it prefers the new (XDG) convention rather than the old one.
* lisp/files.el (locate-user-emacs-file): Make the parent
directories of user-emacs-directory if needed.  This is useful
if user-emacs-directory is "~/.config/emacs" and "~/.config"
does not yet exist.
* lisp/startup.el (command-line):
* lisp/subr.el (user-emacs-directory):
Prefer XDG_CONFIG_HOME to ~/.emacs.d if neither exists.
parent 462be72f
......@@ -1043,7 +1043,7 @@ directory if it does not exist."
(setq errtype "access"))
(with-file-modes ?\700
(condition-case nil
(make-directory user-emacs-directory)
(make-directory user-emacs-directory t)
(error (setq errtype "create")))))
(when (and errtype
......@@ -1170,13 +1170,16 @@ please check its value")
;; This is typically equivalent to ~/.config/emacs if the user is
;; following the XDG convention, and is ~INIT-FILE-USER/.emacs.d
;; on other systems.
(setq xdg-dir
(let* ((dir (concat (or (getenv "XDG_CONFIG_HOME")
(setq xdg-dir (concat (or (getenv "XDG_CONFIG_HOME")
(concat "~" init-file-user "/.config"))
(if (file-exists-p dir) dir)))
(setq startup-init-directory
(or xdg-dir (concat "~" init-file-user "/.emacs.d/")))
(if (file-exists-p xdg-dir)
(let ((emacs-d-dir (concat "~" init-file-user "/.emacs.d/")))
(if (file-exists-p emacs-d-dir)
;; Load the early init file, if found.
......@@ -1325,7 +1328,7 @@ please check its value")
(lambda ()
(xdg-dir nil)
((eq startup-init-directory xdg-dir) nil)
((eq system-type 'ms-dos)
(concat "~" init-file-user "/_emacs"))
((not (eq system-type 'windows-nt))
......@@ -2943,10 +2943,13 @@ mode.")
(if (file-exists-p config-dir)
(if (eq system-type 'ms-dos)
;; MS-DOS cannot have initial dot.
(let ((emacs-d-dir (if (eq system-type 'ms-dos)
;; MS-DOS cannot have initial dot.
(if (file-exists-p emacs-d-dir)
"Directory beneath which additional per-user Emacs-specific files are placed.
Various programs in Emacs store information in this directory.
Note that this should end with a directory separator.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment