defvar->defconst for dir vars & expand DIR envvars

- Use defconst so that we can reload core.el if these variables change.
- Expand DIR envvars to ensure their correctness
This commit is contained in:
Henrik Lissner 2019-11-01 15:12:12 -04:00
parent 2a63faf0d2
commit 7b9991711a
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -53,19 +53,19 @@ DEBUG envvar will enable this at startup.")
decrease this. If you experience stuttering, increase this.") decrease this. If you experience stuttering, increase this.")
;;; Directories/files ;;; Directories/files
(defvar doom-emacs-dir (defconst doom-emacs-dir
(eval-when-compile (file-truename user-emacs-directory)) (eval-when-compile (file-truename user-emacs-directory))
"The path to the currently loaded .emacs.d directory. Must end with a slash.") "The path to the currently loaded .emacs.d directory. Must end with a slash.")
(defvar doom-core-dir (concat doom-emacs-dir "core/") (defconst doom-core-dir (concat doom-emacs-dir "core/")
"The root directory of Doom's core files. Must end with a slash.") "The root directory of Doom's core files. Must end with a slash.")
(defvar doom-modules-dir (concat doom-emacs-dir "modules/") (defconst doom-modules-dir (concat doom-emacs-dir "modules/")
"The root directory for Doom's modules. Must end with a slash.") "The root directory for Doom's modules. Must end with a slash.")
(defvar doom-local-dir (defconst doom-local-dir
(if-let (localdir (getenv "DOOMLOCALDIR")) (if-let (localdir (getenv "DOOMLOCALDIR"))
(file-name-as-directory localdir) (expand-file-name (file-name-as-directory localdir))
(concat doom-emacs-dir ".local/")) (concat doom-emacs-dir ".local/"))
"Root directory for local storage. "Root directory for local storage.
@ -73,23 +73,23 @@ Use this as a storage location for this system's installation of Doom Emacs.
These files should not be shared across systems. By default, it is used by These files should not be shared across systems. By default, it is used by
`doom-etc-dir' and `doom-cache-dir'. Must end with a slash.") `doom-etc-dir' and `doom-cache-dir'. Must end with a slash.")
(defvar doom-etc-dir (concat doom-local-dir "etc/") (defconst doom-etc-dir (concat doom-local-dir "etc/")
"Directory for non-volatile local storage. "Directory for non-volatile local storage.
Use this for files that don't change much, like server binaries, external Use this for files that don't change much, like server binaries, external
dependencies or long-term shared data. Must end with a slash.") dependencies or long-term shared data. Must end with a slash.")
(defvar doom-cache-dir (concat doom-local-dir "cache/") (defconst doom-cache-dir (concat doom-local-dir "cache/")
"Directory for volatile local storage. "Directory for volatile local storage.
Use this for files that change often, like cache files. Must end with a slash.") Use this for files that change often, like cache files. Must end with a slash.")
(defvar doom-docs-dir (concat doom-emacs-dir "docs/") (defconst doom-docs-dir (concat doom-emacs-dir "docs/")
"Where Doom's documentation files are stored. Must end with a slash.") "Where Doom's documentation files are stored. Must end with a slash.")
(defvar doom-private-dir (defconst doom-private-dir
(if-let (doomdir (getenv "DOOMDIR")) (if-let (doomdir (getenv "DOOMDIR"))
(file-name-as-directory doomdir) (expand-file-name (file-name-as-directory doomdir))
(or (let ((xdgdir (or (let ((xdgdir
(expand-file-name "doom/" (expand-file-name "doom/"
(or (getenv "XDG_CONFIG_HOME") (or (getenv "XDG_CONFIG_HOME")
@ -101,19 +101,19 @@ Use this for files that change often, like cache files. Must end with a slash.")
Defaults to ~/.config/doom, ~/.doom.d or the value of the DOOMDIR envvar; Defaults to ~/.config/doom, ~/.doom.d or the value of the DOOMDIR envvar;
whichever is found first. Must end in a slash.") whichever is found first. Must end in a slash.")
(defvar doom-autoload-file (concat doom-local-dir "autoloads.el") (defconst doom-autoload-file (concat doom-local-dir "autoloads.el")
"Where `doom-reload-core-autoloads' stores its core autoloads. "Where `doom-reload-core-autoloads' stores its core autoloads.
This file is responsible for informing Emacs where to find all of Doom's This file is responsible for informing Emacs where to find all of Doom's
autoloaded core functions (in core/autoload/*.el).") autoloaded core functions (in core/autoload/*.el).")
(defvar doom-package-autoload-file (concat doom-local-dir "autoloads.pkg.el") (defconst doom-package-autoload-file (concat doom-local-dir "autoloads.pkg.el")
"Where `doom-reload-package-autoloads' stores its package autoloads. "Where `doom-reload-package-autoloads' stores its package autoloads.
This file is compiled from the autoloads files of all installed packages This file is compiled from the autoloads files of all installed packages
combined.") combined.")
(defvar doom-env-file (concat doom-local-dir "env") (defconst doom-env-file (concat doom-local-dir "env")
"The location of your envvar file, generated by `doom env refresh`. "The location of your envvar file, generated by `doom env refresh`.
This file contains environment variables scraped from your shell environment, This file contains environment variables scraped from your shell environment,