Refactor require!
Defer its compile-time segments to run-time, which would cause many issues in conditions wrapped around it. In any case, avoid using require!, it was a poor choice to implement it and should only be used for unit tests.
This commit is contained in:
parent
4c4a35ae86
commit
e4b23d78da
1 changed files with 15 additions and 17 deletions
|
@ -332,23 +332,21 @@ to have them return non-nil (or exploit that to overwrite Doom's config)."
|
||||||
|
|
||||||
(defmacro require! (category module &rest plist)
|
(defmacro require! (category module &rest plist)
|
||||||
"Loads the module specified by CATEGORY (a keyword) and MODULE (a symbol)."
|
"Loads the module specified by CATEGORY (a keyword) and MODULE (a symbol)."
|
||||||
(let ((doom-modules (copy-hash-table doom-modules)))
|
`(let ((module-path (doom-module-locate-path ,category ',module)))
|
||||||
(apply #'doom-module-set category module
|
(doom-module-set ,category ',module ,@plist)
|
||||||
(mapcar #'eval plist))
|
(if (directory-name-p module-path)
|
||||||
(let ((module-path (doom-module-locate-path category module)))
|
(condition-case-unless-debug ex
|
||||||
(if (directory-name-p module-path)
|
(let ((doom--current-module ',(cons category module)))
|
||||||
`(condition-case-unless-debug ex
|
(load! "init" module-path :noerror)
|
||||||
(let ((doom--current-module ',(cons category module)))
|
(let ((doom--stage 'config))
|
||||||
(load! "init" ,module-path :noerror)
|
(load! "config" module-path :noerror)))
|
||||||
(let ((doom--stage 'config))
|
('error
|
||||||
(load! "config" ,module-path :noerror)))
|
(lwarn 'doom-modules :error
|
||||||
('error
|
"%s in '%s %s' -> %s"
|
||||||
(lwarn 'doom-modules :error
|
(car ex) ,category ',module
|
||||||
"%s in '%s %s' -> %s"
|
(error-message-string ex))))
|
||||||
(car ex) ,category ',module
|
(warn 'doom-modules :warning "Couldn't find module '%s %s'"
|
||||||
(error-message-string ex))))
|
,category ',module))))
|
||||||
(warn 'doom-modules :warning "Couldn't find module '%s %s'"
|
|
||||||
category module)))))
|
|
||||||
|
|
||||||
(defmacro featurep! (module &optional submodule flag)
|
(defmacro featurep! (module &optional submodule flag)
|
||||||
"Returns t if MODULE SUBMODULE is enabled. If FLAG is provided, returns t if
|
"Returns t if MODULE SUBMODULE is enabled. If FLAG is provided, returns t if
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue