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:
Henrik Lissner 2018-06-23 22:23:35 +02:00
parent 4c4a35ae86
commit e4b23d78da
No known key found for this signature in database
GPG Key ID: 5F6C0EA160557395

View File

@ -332,23 +332,21 @@ to have them return non-nil (or exploit that to overwrite Doom's config)."
(defmacro require! (category module &rest plist)
"Loads the module specified by CATEGORY (a keyword) and MODULE (a symbol)."
(let ((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)))))
`(let ((module-path (doom-module-locate-path ,category ',module)))
(doom-module-set ,category ',module ,@plist)
(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