summaryrefslogtreecommitdiff
path: root/lisp/startup.el
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2019-08-29 22:29:52 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2019-08-30 00:24:46 -0700
commita4144af909c3a6baf381659bf158e254b28ee002 (patch)
tree3f252887407f71a35561c34ab2cf1649826b71c4 /lisp/startup.el
parent462be72f41580a3137e8f4f1e48580ac6bcc371f (diff)
downloademacs-a4144af909c3a6baf381659bf158e254b28ee002.tar.gz
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.
Diffstat (limited to 'lisp/startup.el')
-rw-r--r--lisp/startup.el15
1 files changed, 9 insertions, 6 deletions
diff --git a/lisp/startup.el b/lisp/startup.el
index 4d584a0cb59..c1e429b8db7 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -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"))
- "/emacs/")))
- (if (file-exists-p dir) dir)))
+ "/emacs/"))
(setq startup-init-directory
- (or xdg-dir (concat "~" init-file-user "/.emacs.d/")))
+ (if (file-exists-p xdg-dir)
+ xdg-dir
+ (let ((emacs-d-dir (concat "~" init-file-user "/.emacs.d/")))
+ (if (file-exists-p emacs-d-dir)
+ emacs-d-dir
+ xdg-dir))))
;; Load the early init file, if found.
(startup--load-user-init-file
@@ -1325,7 +1328,7 @@ please check its value")
(startup--load-user-init-file
(lambda ()
(cond
- (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))