Use symbol plists instead of internal variables
More in line with Emacs' built-in practice of storing a variable's standard-value in a symbol property of the same name, with the added benefit of less global state.
This commit is contained in:
parent
464ce5ec02
commit
df10383a26
5 changed files with 18 additions and 18 deletions
2
bin/doom
2
bin/doom
|
@ -104,7 +104,7 @@
|
|||
(save-match-data
|
||||
(cl-loop for env
|
||||
in (cl-set-difference process-environment
|
||||
doom--initial-process-environment
|
||||
(get 'process-environment 'initial-value)
|
||||
:test #'equal)
|
||||
if (string-match "^\\([a-zA-Z0-9_]+\\)=\\(.+\\)$" env)
|
||||
concat (format "%s=%s \\\n"
|
||||
|
|
|
@ -60,8 +60,7 @@
|
|||
forms
|
||||
`(progn
|
||||
;; doom variables
|
||||
(setq doom--initial-load-path load-path
|
||||
doom-debug-p t
|
||||
(setq doom-debug-p t
|
||||
doom-emacs-dir ,doom-emacs-dir
|
||||
doom-cache-dir ,(expand-file-name "cache/" doom-sandbox-dir)
|
||||
doom-etc-dir ,(expand-file-name "etc/" doom-sandbox-dir))
|
||||
|
@ -74,8 +73,8 @@
|
|||
after-init-time nil
|
||||
init-file-debug doom-debug-p
|
||||
noninteractive nil
|
||||
process-environment ',doom--initial-process-environment
|
||||
exec-path ',doom--initial-exec-path
|
||||
process-environment (get 'process-environment 'initial-value)
|
||||
exec-path (get 'exec-path 'initial-value)
|
||||
load-path ',load-path
|
||||
user-init-file load-file-name)
|
||||
;; package.el
|
||||
|
|
|
@ -123,7 +123,7 @@ default, on Linux, this is '$SHELL -ic /usr/bin/env'. Variables in
|
|||
(let ((blacklist (remq nil (append blacklist doom-env-blacklist)))
|
||||
(whitelist (remq nil (append whitelist doom-env-whitelist))))
|
||||
(insert "(")
|
||||
(dolist (env doom--initial-process-environment)
|
||||
(dolist (env (get 'process-environment 'initial-value))
|
||||
(catch 'skip
|
||||
(let* ((var (car (split-string env "=")))
|
||||
(pred (doom-rpartial #'string-match-p var)))
|
||||
|
|
|
@ -477,7 +477,7 @@ elsewhere."
|
|||
(when built-in
|
||||
(when (and (not ignore)
|
||||
(equal built-in '(quote prefer)))
|
||||
(setq built-in `(locate-library ,(symbol-name name) nil doom--initial-load-path)))
|
||||
(setq built-in `(locate-library ,(symbol-name name) nil (get 'load-path 'initial-value))))
|
||||
(plist-delete! plist :built-in)
|
||||
(plist-put! plist :ignore built-in))
|
||||
`(let* ((name ',name)
|
||||
|
|
23
core/core.el
23
core/core.el
|
@ -28,6 +28,15 @@ envvar will enable this at startup.")
|
|||
(defconst IS-WINDOWS (memq system-type '(cygwin windows-nt ms-dos)))
|
||||
(defconst IS-BSD (or IS-MAC (eq system-type 'berkeley-unix)))
|
||||
|
||||
;; Ensure Doom's core libraries are visible for loading
|
||||
(add-to-list 'load-path (file-name-directory load-file-name))
|
||||
|
||||
;; Remember these variables' initial values, so we can safely reset them at a
|
||||
;; later time, or consult them without fear of contamination.
|
||||
(dolist (var '(exec-path load-path process-environment))
|
||||
(unless (get var 'initial-value)
|
||||
(put var 'initial-value (default-value var))))
|
||||
|
||||
;; Unix tools look for HOME, but this is normally not defined on Windows.
|
||||
(when (and IS-WINDOWS (null (getenv-internal "HOME")))
|
||||
(setenv "HOME" (getenv "USERPROFILE"))
|
||||
|
@ -178,9 +187,6 @@ users).")
|
|||
;;
|
||||
;;; Core libraries
|
||||
|
||||
;; Ensure Doom's core libraries are visible for loading
|
||||
(add-to-list 'load-path doom-core-dir)
|
||||
|
||||
;; Just the... bear necessities~
|
||||
(require 'subr-x)
|
||||
(require 'cl-lib)
|
||||
|
@ -467,7 +473,7 @@ If this is a daemon session, load them all immediately instead."
|
|||
If RETURN-P, return the message as a string instead of displaying it."
|
||||
(funcall (if return-p #'format #'message)
|
||||
"Doom loaded %d packages across %d modules in %.03fs"
|
||||
(- (length load-path) (length doom--initial-load-path))
|
||||
(- (length load-path) (length (get 'load-path 'initial-value)))
|
||||
(if doom-modules (hash-table-count doom-modules) 0)
|
||||
(or doom-init-time
|
||||
(setq doom-init-time
|
||||
|
@ -537,10 +543,6 @@ TRIGGER-HOOK is a list of quoted hooks and/or sharp-quoted functions."
|
|||
;;
|
||||
;;; Bootstrapper
|
||||
|
||||
(defvar doom--initial-exec-path exec-path)
|
||||
(defvar doom--initial-load-path load-path)
|
||||
(defvar doom--initial-process-environment process-environment)
|
||||
|
||||
(defun doom-initialize (&optional force-p)
|
||||
"Bootstrap Doom, if it hasn't already (or if FORCE-P is non-nil).
|
||||
|
||||
|
@ -573,9 +575,8 @@ to least)."
|
|||
|
||||
;; Reset as much state as possible, so `doom-initialize' can be treated like
|
||||
;; a reset function. e.g. when reloading the config.
|
||||
(setq-default exec-path doom--initial-exec-path
|
||||
load-path doom--initial-load-path
|
||||
process-environment doom--initial-process-environment)
|
||||
(dolist (var '(exec-path load-path process-environment))
|
||||
(set-default var (get var 'initial-value)))
|
||||
|
||||
;; Doom caches a lot of information in `doom-autoloads-file'. Module and
|
||||
;; package autoloads, autodefs like `set-company-backend!', and variables
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue