refactor: how doom prevents $EMACSDIR litter
I change `user-emacs-directory' because most (if not all) packages -- even built-in ones -- abuse it exclusively to build paths for storage/cache files (instead of correctly using `locate-user-emacs-file'). This ensures your $EMACSDIR isn't littered with data files *and* saves us the trouble of setting every directory/file variable under the sun. Granted, this introduces an edge case for any legitimate uses of the variable (e.g. where the caller seeks to locate the user's initfiles), but I've found no such uses in any of the packages I've audited for Doom or elsewhere.
This commit is contained in:
parent
4071d27263
commit
46844b55de
1 changed files with 26 additions and 18 deletions
44
core/core.el
44
core/core.el
|
@ -181,26 +181,34 @@ users).")
|
||||||
;;
|
;;
|
||||||
;;; Don't litter `doom-emacs-dir'
|
;;; Don't litter `doom-emacs-dir'
|
||||||
|
|
||||||
;; We avoid `no-littering' because it's a mote too opinionated for our needs.
|
;; I change `user-emacs-directory' because many packages (even built-in ones)
|
||||||
(setq async-byte-compile-log-file (concat doom-etc-dir "async-bytecomp.log")
|
;; abuse it to build paths for storage/cache files (instead of correctly using
|
||||||
custom-file (concat doom-private-dir "custom.el")
|
;; `locate-user-emacs-file'). This change ensures that said data files are never
|
||||||
desktop-dirname (concat doom-etc-dir "desktop")
|
;; saved to the root of your emacs directory *and* saves us the trouble setting
|
||||||
desktop-base-file-name "autosave"
|
;; a million directory/file variables.
|
||||||
desktop-base-lock-name "autosave-lock"
|
(setq user-emacs-directory doom-cache-dir)
|
||||||
pcache-directory (concat doom-cache-dir "pcache/")
|
|
||||||
request-storage-directory (concat doom-cache-dir "request")
|
|
||||||
shared-game-score-directory (concat doom-etc-dir "shared-game-score/"))
|
|
||||||
|
|
||||||
(defadvice! doom--write-to-sane-paths-a (fn &rest args)
|
;; ...However, this may surprise packages (and users) that read
|
||||||
"Write 3rd party files to `doom-etc-dir' to keep `user-emacs-directory' clean.
|
;; `user-emacs-directory' expecting to find the location of your Emacs config,
|
||||||
|
;; such as server.el!
|
||||||
|
(setq server-auth-dir (expand-file-name "server/" doom-emacs-dir))
|
||||||
|
|
||||||
Also writes `put' calls for saved safe-local-variables to `custom-file' instead
|
;; Packages with file/dir settings that don't use `user-emacs-directory' or
|
||||||
of `user-init-file' (which `en/disable-command' in novice.el.gz is hardcoded to
|
;; `locate-user-emacs-file' to initialize will need to set explicitly, to stop
|
||||||
do)."
|
;; them from littering in ~/.emacs.d/.
|
||||||
:around #'en/disable-command
|
(setq desktop-dirname (expand-file-name "desktop" doom-cache-dir)
|
||||||
:around #'locate-user-emacs-file
|
pcache-directory (expand-file-name "pcache/" doom-cache-dir))
|
||||||
(let ((user-emacs-directory doom-etc-dir)
|
|
||||||
(user-init-file custom-file))
|
;; Allow the user to store custom.el-saved settings and themes in their Doom
|
||||||
|
;; config (e.g. ~/.doom.d/).
|
||||||
|
(setq custom-file (expand-file-name "custom.el" doom-private-dir))
|
||||||
|
|
||||||
|
(define-advice en/disable-command (:around (fn &rest args) write-to-data-dir)
|
||||||
|
"Write saved safe-local-variables to `custom-file' instead.
|
||||||
|
|
||||||
|
Otherwise, `en/disable-command' (in novice.el.gz) is hardcoded to write them to
|
||||||
|
`user-init-file')."
|
||||||
|
(let ((user-init-file custom-file))
|
||||||
(apply fn args)))
|
(apply fn args)))
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue