Freeze doom-modules in between 'doom sync'
The coming CLI rewrite makes bin/doom atomic, but also "freezes" more of your config in between 'doom sync's and 'doom upgrade's. This is necessary to implement a robust rollback system. However, that also means that `doom!` shouldn't do anything when read in an interactive session (and should only be read when running `doom sync`). Indirectly fixes #2612
This commit is contained in:
parent
2c2a4c5c8a
commit
519a402f62
1 changed files with 91 additions and 91 deletions
|
@ -3,7 +3,7 @@
|
||||||
(defvar doom-init-modules-p nil
|
(defvar doom-init-modules-p nil
|
||||||
"Non-nil if `doom-initialize-modules' has run.")
|
"Non-nil if `doom-initialize-modules' has run.")
|
||||||
|
|
||||||
(defvar doom-modules ()
|
(defvar doom-modules (make-hash-table :test 'equal)
|
||||||
"A hash table of enabled modules. Set by `doom-initialize-modules'.")
|
"A hash table of enabled modules. Set by `doom-initialize-modules'.")
|
||||||
|
|
||||||
(defvar doom-modules-dirs
|
(defvar doom-modules-dirs
|
||||||
|
@ -249,21 +249,67 @@ those directories. The first returned path is always `doom-private-dir'."
|
||||||
collect (plist-get plist :path)))
|
collect (plist-get plist :path)))
|
||||||
nil))
|
nil))
|
||||||
|
|
||||||
|
(defun doom-module-mplist-map (fn mplist)
|
||||||
|
"Apply FN to each module in MPLIST."
|
||||||
|
(let ((mplist (copy-sequence mplist))
|
||||||
|
(inhibit-message doom-inhibit-module-warnings)
|
||||||
|
obsolete
|
||||||
|
results
|
||||||
|
category m)
|
||||||
|
(while mplist
|
||||||
|
(setq m (pop mplist))
|
||||||
|
(cond ((keywordp m)
|
||||||
|
(setq category m
|
||||||
|
obsolete (assq m doom-obsolete-modules)))
|
||||||
|
((null category)
|
||||||
|
(error "No module category specified for %s" m))
|
||||||
|
((and (listp m) (keywordp (car m)))
|
||||||
|
(pcase (car m)
|
||||||
|
(:cond
|
||||||
|
(cl-loop for (cond . mods) in (cdr m)
|
||||||
|
if (eval cond t)
|
||||||
|
return (prependq! mplist mods)))
|
||||||
|
(:if (if (eval (cadr m) t)
|
||||||
|
(push (caddr m) mplist)
|
||||||
|
(prependq! mplist (cdddr m))))
|
||||||
|
(test (if (or (eval (cadr m) t)
|
||||||
|
(eq test :unless))
|
||||||
|
(prependq! mplist (cddr m))))))
|
||||||
|
((catch 'doom-modules
|
||||||
|
(let* ((module (if (listp m) (car m) m))
|
||||||
|
(flags (if (listp m) (cdr m))))
|
||||||
|
(when-let (new (assq module obsolete))
|
||||||
|
(let ((newkeys (cdr new)))
|
||||||
|
(if (null newkeys)
|
||||||
|
(message "WARNING %s module was removed" key)
|
||||||
|
(if (cdr newkeys)
|
||||||
|
(message "WARNING %s module was removed and split into the %s modules"
|
||||||
|
(list category module) (mapconcat #'prin1-to-string newkeys ", "))
|
||||||
|
(message "WARNING %s module was moved to %s"
|
||||||
|
(list category module) (car newkeys)))
|
||||||
|
(push category mplist)
|
||||||
|
(dolist (key newkeys)
|
||||||
|
(push (if flags
|
||||||
|
(nconc (cdr key) flags)
|
||||||
|
(cdr key))
|
||||||
|
mplist)
|
||||||
|
(push (car key) mplist))
|
||||||
|
(throw 'doom-modules t))))
|
||||||
|
(push (funcall fn category module
|
||||||
|
:flags (if (listp m) (cdr m))
|
||||||
|
:path (doom-module-locate-path category module))
|
||||||
|
results))))))
|
||||||
|
(unless doom-interactive-p
|
||||||
|
(setq doom-inhibit-module-warnings t))
|
||||||
|
(nreverse results)))
|
||||||
|
|
||||||
(defun doom-module-list (&optional all-p)
|
(defun doom-module-list (&optional all-p)
|
||||||
"Minimally initialize `doom-modules' (a hash table) and return it.
|
"Minimally initialize `doom-modules' (a hash table) and return it.
|
||||||
This value is cached. If REFRESH-P, then don't use the cached value."
|
This value is cached. If REFRESH-P, then don't use the cached value."
|
||||||
(if all-p
|
(if all-p
|
||||||
(cl-loop for path in (cdr (doom-module-load-path 'all))
|
(cl-loop for path in (cdr (doom-module-load-path 'all))
|
||||||
collect (doom-module-from-path path))
|
collect (doom-module-from-path path))
|
||||||
(or doom-modules
|
doom-modules))
|
||||||
(let (doom-interactive-p
|
|
||||||
doom-modules
|
|
||||||
doom-init-modules-p)
|
|
||||||
(load! "init" doom-private-dir t)
|
|
||||||
(or doom-modules
|
|
||||||
(make-hash-table :test 'equal
|
|
||||||
:size 20
|
|
||||||
:rehash-threshold 1.0))))))
|
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
@ -402,62 +448,16 @@ The overall load order of Doom is as follows:
|
||||||
Module load order is determined by your `doom!' block. See `doom-modules-dirs'
|
Module load order is determined by your `doom!' block. See `doom-modules-dirs'
|
||||||
for a list of all recognized module trees. Order defines precedence (from most
|
for a list of all recognized module trees. Order defines precedence (from most
|
||||||
to least)."
|
to least)."
|
||||||
`(let ((modules
|
`(unless doom-interactive-p
|
||||||
|
(doom-module-mplist-map
|
||||||
|
(lambda (category module &rest plist)
|
||||||
|
(if (plist-get plist :path)
|
||||||
|
(apply #'doom-module-set category module plist)
|
||||||
|
(message "WARNING Couldn't find the %s %s module" category module)))
|
||||||
,@(if (keywordp (car modules))
|
,@(if (keywordp (car modules))
|
||||||
(list (list 'quote modules))
|
(list (list 'quote modules))
|
||||||
modules)))
|
modules))
|
||||||
(unless doom-modules
|
doom-modules))
|
||||||
(setq doom-modules
|
|
||||||
(make-hash-table :test 'equal
|
|
||||||
:size (if modules (length modules) 150)
|
|
||||||
:rehash-threshold 1.0)))
|
|
||||||
(let ((inhibit-message doom-inhibit-module-warnings)
|
|
||||||
obsolete category m)
|
|
||||||
(while modules
|
|
||||||
(setq m (pop modules))
|
|
||||||
(cond ((keywordp m)
|
|
||||||
(setq category m
|
|
||||||
obsolete (assq m doom-obsolete-modules)))
|
|
||||||
((not category)
|
|
||||||
(error "No module category specified for %s" m))
|
|
||||||
((and (listp m) (keywordp (car m)))
|
|
||||||
(pcase (car m)
|
|
||||||
(:cond
|
|
||||||
(cl-loop for (cond . mods) in (cdr m)
|
|
||||||
if (eval cond t)
|
|
||||||
return (prependq! modules mods)))
|
|
||||||
(:if (if (eval (cadr m) t)
|
|
||||||
(push (caddr m) modules)
|
|
||||||
(prependq! modules (cdddr m))))
|
|
||||||
(fn (if (or (eval (cadr m) t)
|
|
||||||
(eq fn :unless))
|
|
||||||
(prependq! modules (cddr m))))))
|
|
||||||
((catch 'doom-modules
|
|
||||||
(let* ((module (if (listp m) (car m) m))
|
|
||||||
(flags (if (listp m) (cdr m))))
|
|
||||||
(when-let (new (assq module obsolete))
|
|
||||||
(let ((newkeys (cdr new)))
|
|
||||||
(if (null newkeys)
|
|
||||||
(message "WARNING %s module was removed" key)
|
|
||||||
(if (cdr newkeys)
|
|
||||||
(message "WARNING %s module was removed and split into the %s modules"
|
|
||||||
(list category module) (mapconcat #'prin1-to-string newkeys ", "))
|
|
||||||
(message "WARNING %s module was moved to %s"
|
|
||||||
(list category module) (car newkeys)))
|
|
||||||
(push category modules)
|
|
||||||
(dolist (key newkeys)
|
|
||||||
(push (if flags
|
|
||||||
(nconc (cdr key) flags)
|
|
||||||
(cdr key))
|
|
||||||
modules)
|
|
||||||
(push (car key) modules))
|
|
||||||
(throw 'doom-modules t))))
|
|
||||||
(if-let (path (doom-module-locate-path category module))
|
|
||||||
(doom-module-set category module :flags flags :path path)
|
|
||||||
(message "WARNING Couldn't find the %s %s module" category module)))))))
|
|
||||||
(unless doom-interactive-p
|
|
||||||
(setq doom-inhibit-module-warnings t))
|
|
||||||
doom-modules)))
|
|
||||||
|
|
||||||
(defvar doom-disabled-packages)
|
(defvar doom-disabled-packages)
|
||||||
(defmacro use-package! (name &rest plist)
|
(defmacro use-package! (name &rest plist)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue