[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Default emacs init file location confusion
From: |
Robert Pluim |
Subject: |
Re: Default emacs init file location confusion |
Date: |
Wed, 08 Jan 2020 09:04:25 +0100 |
>>>>> On Wed, 8 Jan 2020 13:33:20 +0800, Elias Mårtenson <address@hidden> said:
Elias> Having thought about it some more, I came up with this proposal:
Emacs
Elias> could check if both directories exist, and if so, provide an
interactive
Elias> choice for the user to pick which one to use. If the user don't want
to
Elias> have to answer this question every time Emacs starts up, they can
delete
Elias> one of the directories.
That seems like the worst of both worlds. Iʼd say the principle of
least surprise says that emacs should prefer ~/.emacs.d if neither of
two directories exist (which would end up creating it), and prefer
~/.config/emacs if that exists (but not create it), which allows
people who want to use the xdg stuff to do so easily. Concretely:
diff --git a/lisp/startup.el b/lisp/startup.el
index 04a37bf59e..ebf9d33a97 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -497,28 +497,20 @@ startup--xdg-config-default
(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 unless it does not exist, in which case we prefer the
+;; .emacs.d location (even if it does not exist)
(defun startup--xdg-or-homedot (xdg-dir user-name)
+ (let ((user-name (if (and user-name (not (string-equal user-name "")))
+ user-name
+ init-file-user)))
(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))))
+ (concat "~" user-name
+ (if (eq system-type 'ms-dos)
+ "/_emacs.d/"
+ "/.emacs.d/")))))
(defun normal-top-level ()
"Emacs calls this function when it first starts up.
- Re: Default emacs init file location confusion, (continued)
- Re: Default emacs init file location confusion, chad, 2020/01/08
- Re: Default emacs init file location confusion, Stefan Monnier, 2020/01/08
- Re: Default emacs init file location confusion, Eli Zaretskii, 2020/01/08
- Re: Default emacs init file location confusion, HaiJun Zhang, 2020/01/08
- Re: Default emacs init file location confusion, 황병희, 2020/01/09
- Re: Default emacs init file location confusion, Mario Lang, 2020/01/08
- Re: Default emacs init file location confusion, Eli Zaretskii, 2020/01/08
- Re: Default emacs init file location confusion, Elias Mårtenson, 2020/01/08
- Re: Default emacs init file location confusion,
Robert Pluim <=
- Re: Default emacs init file location confusion, Stefan Monnier, 2020/01/07
- Re: Default emacs init file location confusion, Stefan Monnier, 2020/01/07
- Re: Default emacs init file location confusion, Eli Zaretskii, 2020/01/07
- Re: Default emacs init file location confusion, Stefan Monnier, 2020/01/07
- Re: Default emacs init file location confusion, Yuan Fu, 2020/01/07
- Re: Default emacs init file location confusion, Greg Farough, 2020/01/07
- Re: Default emacs init file location confusion, Andrea Corallo, 2020/01/07
- Re: Default emacs init file location confusion, Yuan Fu, 2020/01/07
- Re: Default emacs init file location confusion, Yuan Fu, 2020/01/07
- Re: Default emacs init file location confusion, Elias Mårtenson, 2020/01/07