Refactor require! macro
This commit is contained in:
parent
b53df20dd5
commit
9ba76b60dc
1 changed files with 20 additions and 23 deletions
|
@ -644,29 +644,26 @@ If NOERROR is non-nil, don't throw an error if the file doesn't exist."
|
|||
filename)
|
||||
,noerror ,(not doom-debug-mode)))
|
||||
|
||||
(defmacro require! (module submodule &optional reload-p &rest plist)
|
||||
"Loads the module specified by MODULE (a property) and SUBMODULE (a symbol).
|
||||
|
||||
The module is only loaded once. If RELOAD-P is non-nil, load it again."
|
||||
(let ((enabled-p (doom-module-p module submodule)))
|
||||
(when (or (not enabled-p) plist)
|
||||
(apply #'doom-module-set module submodule
|
||||
(mapcar #'eval plist)))
|
||||
(when (or reload-p (not enabled-p))
|
||||
(let ((module-path (doom-module-locate-path module submodule)))
|
||||
(if (file-directory-p module-path)
|
||||
`(condition-case-unless-debug ex
|
||||
(let ((doom--current-module ',(cons module submodule)))
|
||||
(load! "init" ,module-path :noerror)
|
||||
(let ((doom--stage 'config))
|
||||
(load! "config" ,module-path :noerror)))
|
||||
('error
|
||||
(lwarn 'doom-modules :error
|
||||
"%s in '%s %s' -> %s"
|
||||
(car ex) ,module ',submodule
|
||||
(error-message-string ex))))
|
||||
(warn 'doom-modules :warning "Couldn't find module '%s %s'"
|
||||
module submodule))))))
|
||||
(defmacro require! (category module &rest plist)
|
||||
"Loads the module specified by CATEGORY (a keyword) and MODULE (a symbol)."
|
||||
(let ((enabled-p (doom-module-p category module))
|
||||
(doom-modules (copy-hash-table doom-modules)))
|
||||
(apply #'doom-module-set category module
|
||||
(mapcar #'eval plist))
|
||||
(let ((module-path (doom-module-locate-path category module)))
|
||||
(if (directory-name-p module-path)
|
||||
`(condition-case-unless-debug ex
|
||||
(let ((doom--current-module ',(cons category module)))
|
||||
(load! "init" ,module-path :noerror)
|
||||
(let ((doom--stage 'config))
|
||||
(load! "config" ,module-path :noerror)))
|
||||
('error
|
||||
(lwarn 'doom-modules :error
|
||||
"%s in '%s %s' -> %s"
|
||||
(car ex) ,category ',module
|
||||
(error-message-string ex))))
|
||||
(warn 'doom-modules :warning "Couldn't find module '%s %s'"
|
||||
category module)))))
|
||||
|
||||
(defmacro featurep! (module &optional submodule flag)
|
||||
"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