summaryrefslogtreecommitdiff
path: root/lisp/startup.el
diff options
context:
space:
mode:
authorRobert Pluim <rpluim@gmail.com>2020-01-15 12:24:43 +0100
committerRobert Pluim <rpluim@gmail.com>2020-01-16 16:05:45 +0100
commit13995f31a219bfcb24da5887136583cbf2deff4c (patch)
treeb8abcb0057271c7ed2d6d90144c6925beaaea128 /lisp/startup.el
parent91cac24952806c6c4addc3c045854c2c314c2e31 (diff)
downloademacs-13995f31a219bfcb24da5887136583cbf2deff4c.tar.gz
emacs-13995f31a219bfcb24da5887136583cbf2deff4c.tar.bz2
emacs-13995f31a219bfcb24da5887136583cbf2deff4c.zip
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.
Diffstat (limited to 'lisp/startup.el')
-rw-r--r--lisp/startup.el42
1 files changed, 21 insertions, 21 deletions
diff --git a/lisp/startup.el b/lisp/startup.el
index 2a85c004da1..1f545c66922 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -497,28 +497,28 @@ DIRS are relative."
(defvar startup--xdg-config-home-emacs)
;; Return the name of the init file directory for Emacs, assuming
-;; XDG-DIR is the XDG location and USER-NAME is the user name.
-;; If USER-NAME is nil or "", use the current user.
-;; Prefer the XDG location unless it does does not exist and the
-;; .emacs.d location does exist.
+;; XDG-DIR is the XDG location and USER-NAME is the user name. If
+;; USER-NAME is nil or "", use the current user. Prefer the XDG
+;; location only if the .emacs.d location does not exist.
(defun startup--xdg-or-homedot (xdg-dir user-name)
- (if (file-exists-p xdg-dir)
- xdg-dir
- (let ((emacs-d-dir (concat "~" user-name
- (if (eq system-type 'ms-dos)
- "/_emacs.d/"
- "/.emacs.d/"))))
- (if (or (file-exists-p emacs-d-dir)
- (if (eq system-type 'windows-nt)
- (if (file-directory-p (concat "~" user-name))
- (directory-files (concat "~" user-name) nil
- "\\`[._]emacs\\(\\.elc?\\)?\\'"))
- (file-exists-p (concat "~" init-file-user
- (if (eq system-type 'ms-dos)
- "/_emacs"
- "/.emacs")))))
- emacs-d-dir
- xdg-dir))))
+ (let ((emacs-d-dir (concat "~" user-name
+ (if (eq system-type 'ms-dos)
+ "/_emacs.d/"
+ "/.emacs.d/"))))
+ (cond
+ ((or (file-exists-p emacs-d-dir)
+ (if (eq system-type 'windows-nt)
+ (if (file-directory-p (concat "~" user-name))
+ (directory-files (concat "~" user-name) nil
+ "\\`[._]emacs\\(\\.elc?\\)?\\'"))
+ (file-exists-p (concat "~" init-file-user
+ (if (eq system-type 'ms-dos)
+ "/_emacs"
+ "/.emacs")))))
+ emacs-d-dir)
+ ((file-exists-p xdg-dir)
+ xdg-dir)
+ (t emacs-d-dir))))
(defun normal-top-level ()
"Emacs calls this function when it first starts up.