emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master a4144af 1/2: Prefer ~/.config/emacs to ~/.emacs.d i


From: Paul Eggert
Subject: [Emacs-diffs] master a4144af 1/2: Prefer ~/.config/emacs to ~/.emacs.d if neither exists
Date: Fri, 30 Aug 2019 03:24:52 -0400 (EDT)

branch: master
commit a4144af909c3a6baf381659bf158e254b28ee002
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>

    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.
---
 lisp/files.el   |  2 +-
 lisp/startup.el | 15 +++++++++------
 lisp/subr.el    | 11 +++++++----
 3 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/lisp/files.el b/lisp/files.el
index 2a84c2c..ce4dd99 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -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
                        user-emacs-directory-warning
diff --git a/lisp/startup.el b/lisp/startup.el
index 4d584a0..c1e429b 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))
diff --git a/lisp/subr.el b/lisp/subr.el
index 3cf3957..566a3fc 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -2943,10 +2943,13 @@ mode.")
                            "/emacs/")))
     (if (file-exists-p config-dir)
        config-dir
-      (if (eq system-type 'ms-dos)
-         ;; MS-DOS cannot have initial dot.
-         "~/_emacs.d/"
-       "~/.emacs.d/")))
+      (let ((emacs-d-dir (if (eq system-type 'ms-dos)
+                            ;; MS-DOS cannot have initial dot.
+                            "~/_emacs.d/"
+                          "~/.emacs.d/")))
+       (if (file-exists-p emacs-d-dir)
+           emacs-d-dir
+         config-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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]