aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2019-08-29 22:29:52 -0700
committerPaul Eggert2019-08-30 00:24:46 -0700
commita4144af909c3a6baf381659bf158e254b28ee002 (patch)
tree3f252887407f71a35561c34ab2cf1649826b71c4
parent462be72f41580a3137e8f4f1e48580ac6bcc371f (diff)
downloademacs-a4144af909c3a6baf381659bf158e254b28ee002.tar.gz
emacs-a4144af909c3a6baf381659bf158e254b28ee002.zip
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.
-rw-r--r--lisp/files.el2
-rw-r--r--lisp/startup.el15
-rw-r--r--lisp/subr.el11
3 files changed, 17 insertions, 11 deletions
diff --git a/lisp/files.el b/lisp/files.el
index 2a84c2c48f5..ce4dd99bd53 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -1043,7 +1043,7 @@ directory if it does not exist."
1043 (setq errtype "access")) 1043 (setq errtype "access"))
1044 (with-file-modes ?\700 1044 (with-file-modes ?\700
1045 (condition-case nil 1045 (condition-case nil
1046 (make-directory user-emacs-directory) 1046 (make-directory user-emacs-directory t)
1047 (error (setq errtype "create"))))) 1047 (error (setq errtype "create")))))
1048 (when (and errtype 1048 (when (and errtype
1049 user-emacs-directory-warning 1049 user-emacs-directory-warning
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")
1170 ;; This is typically equivalent to ~/.config/emacs if the user is 1170 ;; This is typically equivalent to ~/.config/emacs if the user is
1171 ;; following the XDG convention, and is ~INIT-FILE-USER/.emacs.d 1171 ;; following the XDG convention, and is ~INIT-FILE-USER/.emacs.d
1172 ;; on other systems. 1172 ;; on other systems.
1173 (setq xdg-dir 1173 (setq xdg-dir (concat (or (getenv "XDG_CONFIG_HOME")
1174 (let* ((dir (concat (or (getenv "XDG_CONFIG_HOME")
1175 (concat "~" init-file-user "/.config")) 1174 (concat "~" init-file-user "/.config"))
1176 "/emacs/"))) 1175 "/emacs/"))
1177 (if (file-exists-p dir) dir)))
1178 (setq startup-init-directory 1176 (setq startup-init-directory
1179 (or xdg-dir (concat "~" init-file-user "/.emacs.d/"))) 1177 (if (file-exists-p xdg-dir)
1178 xdg-dir
1179 (let ((emacs-d-dir (concat "~" init-file-user "/.emacs.d/")))
1180 (if (file-exists-p emacs-d-dir)
1181 emacs-d-dir
1182 xdg-dir))))
1180 1183
1181 ;; Load the early init file, if found. 1184 ;; Load the early init file, if found.
1182 (startup--load-user-init-file 1185 (startup--load-user-init-file
@@ -1325,7 +1328,7 @@ please check its value")
1325 (startup--load-user-init-file 1328 (startup--load-user-init-file
1326 (lambda () 1329 (lambda ()
1327 (cond 1330 (cond
1328 (xdg-dir nil) 1331 ((eq startup-init-directory xdg-dir) nil)
1329 ((eq system-type 'ms-dos) 1332 ((eq system-type 'ms-dos)
1330 (concat "~" init-file-user "/_emacs")) 1333 (concat "~" init-file-user "/_emacs"))
1331 ((not (eq system-type 'windows-nt)) 1334 ((not (eq system-type 'windows-nt))
diff --git a/lisp/subr.el b/lisp/subr.el
index 3cf395787eb..566a3fc758e 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -2943,10 +2943,13 @@ mode.")
2943 "/emacs/"))) 2943 "/emacs/")))
2944 (if (file-exists-p config-dir) 2944 (if (file-exists-p config-dir)
2945 config-dir 2945 config-dir
2946 (if (eq system-type 'ms-dos) 2946 (let ((emacs-d-dir (if (eq system-type 'ms-dos)
2947 ;; MS-DOS cannot have initial dot. 2947 ;; MS-DOS cannot have initial dot.
2948 "~/_emacs.d/" 2948 "~/_emacs.d/"
2949 "~/.emacs.d/"))) 2949 "~/.emacs.d/")))
2950 (if (file-exists-p emacs-d-dir)
2951 emacs-d-dir
2952 config-dir))))
2950 "Directory beneath which additional per-user Emacs-specific files are placed. 2953 "Directory beneath which additional per-user Emacs-specific files are placed.
2951Various programs in Emacs store information in this directory. 2954Various programs in Emacs store information in this directory.
2952Note that this should end with a directory separator. 2955Note that this should end with a directory separator.