summaryrefslogtreecommitdiff
path: root/lisp/startup.el
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2019-05-25 13:22:44 -0400
committerEric S. Raymond <esr@thyrsus.com>2019-05-25 13:23:46 -0400
commitd68ed152ffe4369b3fe082cf39d631cc5360143b (patch)
treef0123dfb8c9e93842b4d2185437fff0d35467092 /lisp/startup.el
parentcd7a0bd00802b9331229dfe4a70ea9690d2d70fc (diff)
downloademacs-d68ed152ffe4369b3fe082cf39d631cc5360143b.tar.gz
emacs-d68ed152ffe4369b3fe082cf39d631cc5360143b.tar.bz2
emacs-d68ed152ffe4369b3fe082cf39d631cc5360143b.zip
Implement and document XDG-style startup files under ~/.config.
* lisp/startup.el (command-line): Allow XDG-style as well as old style init paths. * doc/startup.texi: Document the above change.
Diffstat (limited to 'lisp/startup.el')
-rw-r--r--lisp/startup.el17
1 files changed, 13 insertions, 4 deletions
diff --git a/lisp/startup.el b/lisp/startup.el
index a88118e3b9a..f853ceccc51 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -1,4 +1,4 @@
-;;; startup.el --- process Emacs shell arguments -*- lexical-binding: t -*-
+;; startup.el --- process Emacs shell arguments -*- lexical-binding: t -*-
;; Copyright (C) 1985-1986, 1992, 1994-2019 Free Software Foundation,
;; Inc.
@@ -970,6 +970,15 @@ the `--debug-init' option to view a complete error backtrace."
(when debug-on-error-should-be-set
(setq debug-on-error debug-on-error-from-init-file))))
+(defun find-init-path (fn)
+ "Look in ~/.config/FOO or ~/.FOO for the dotfile or dot directory FOO.
+It is expected that the output will undergo ~ expansion. Implements the
+XDG convention for dotfiles."
+ (let* ((xdg-path (concat "~" init-file-user "/.config/" fn))
+ (oldstyle-path (concat "~" init-file-user "/." fn))
+ (found-path (if (file-exists-p xdg-path) xdg-path oldstyle-path)))
+ found-path))
+
(defun command-line ()
"A subroutine of `normal-top-level'.
Amongst another things, it parses the command-line arguments."
@@ -1171,7 +1180,7 @@ please check its value")
;; "early-init" without an extension, as it does for ".emacs".
"early-init.el"
(file-name-as-directory
- (concat "~" init-file-user "/.emacs.d")))))
+ (find-init-path "emacs.d")))))
(setq early-init-file user-init-file)
;; If any package directory exists, initialize the package system.
@@ -1312,7 +1321,7 @@ please check its value")
((eq system-type 'ms-dos)
(concat "~" init-file-user "/_emacs"))
((not (eq system-type 'windows-nt))
- (concat "~" init-file-user "/.emacs"))
+ (find-init-path "emacs"))
;; Else deal with the Windows situation.
((directory-files "~" nil "^\\.emacs\\(\\.elc?\\)?$")
;; Prefer .emacs on Windows.
@@ -1330,7 +1339,7 @@ please check its value")
(expand-file-name
"init"
(file-name-as-directory
- (concat "~" init-file-user "/.emacs.d"))))
+ (find-init-path "emacs.d"))))
(not inhibit-default-init))
(when (and deactivate-mark transient-mark-mode)