Refactor require! macro

This commit is contained in:
Henrik Lissner 2017-12-08 22:58:15 -05:00
parent 2ef38b73a7
commit df93fd8ce4
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -400,21 +400,19 @@ If NOERROR is non-nil, don't throw an error if the file doesn't exist."
"Loads the module specified by MODULE (a property) and SUBMODULE (a symbol). "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." The module is only loaded once. If RELOAD-P is non-nil, load it again."
(let ((loaded-p (doom-module-loaded-p module submodule))) (when (or reload-p (not (doom-module-loaded-p module submodule)))
(when (or reload-p (not loaded-p)) (let ((module-path (doom-module-path module submodule)))
(unless loaded-p (if (not (file-directory-p module-path))
(doom-module-enable module submodule flags))
(let ((module-path (doom-module-path module submodule)))
(if (file-directory-p module-path)
`(condition-case-unless-debug ex
(load! config ,module-path t)
('error
(lwarn 'doom-modules :error
"%s in '%s %s' -> %s"
(car ex) ,module ',submodule
(error-message-string ex))))
(lwarn 'doom-modules :warning "Couldn't find module '%s %s'" (lwarn 'doom-modules :warning "Couldn't find module '%s %s'"
module submodule)))))) module submodule)
(doom-module-enable module submodule flags)
`(condition-case-unless-debug ex
(load! config ,module-path t)
('error
(lwarn 'doom-modules :error
"%s in '%s %s' -> %s"
(car ex) ,module ',submodule
(error-message-string ex))))))))
(defmacro featurep! (module &optional submodule flag) (defmacro featurep! (module &optional submodule flag)
"A convenience macro wrapper for `doom-module-loaded-p'. It is evaluated at "A convenience macro wrapper for `doom-module-loaded-p'. It is evaluated at