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))
(unless loaded-p
(doom-module-enable module submodule flags))
(let ((module-path (doom-module-path module submodule))) (let ((module-path (doom-module-path module submodule)))
(if (file-directory-p module-path) (if (not (file-directory-p module-path))
(lwarn 'doom-modules :warning "Couldn't find module '%s %s'"
module submodule)
(doom-module-enable module submodule flags)
`(condition-case-unless-debug ex `(condition-case-unless-debug ex
(load! config ,module-path t) (load! config ,module-path t)
('error ('error
(lwarn 'doom-modules :error (lwarn 'doom-modules :error
"%s in '%s %s' -> %s" "%s in '%s %s' -> %s"
(car ex) ,module ',submodule (car ex) ,module ',submodule
(error-message-string ex)))) (error-message-string ex))))))))
(lwarn 'doom-modules :warning "Couldn't find module '%s %s'"
module submodule))))))
(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