Rename module library functions in core-packages
+ doom-module-loaded-p => doom-module-enabled-p + doom-module-flags => doom-module-get + Use load! for module config files, rather than require!
This commit is contained in:
parent
b14198dedf
commit
96a232b2ae
1 changed files with 15 additions and 13 deletions
|
@ -260,14 +260,13 @@ added, if the file exists."
|
||||||
if (file-exists-p path)
|
if (file-exists-p path)
|
||||||
collect path))
|
collect path))
|
||||||
|
|
||||||
(defun doom-module-flags (module submodule)
|
(defun doom-module-get (module submodule)
|
||||||
"Returns a list of flags provided for MODULE SUBMODULE."
|
"Returns a list of flags provided for MODULE SUBMODULE."
|
||||||
(and (hash-table-p doom-modules)
|
(gethash (cons module submodule) doom-modules))
|
||||||
(gethash (cons module submodule) doom-modules)))
|
|
||||||
|
|
||||||
(defun doom-module-loaded-p (module submodule)
|
(defun doom-module-enabled-p (module submodule)
|
||||||
"Returns t if MODULE->SUBMODULE is present in `doom-modules'."
|
"Returns t if MODULE->SUBMODULE is present in `doom-modules'."
|
||||||
(and (doom-module-flags module submodule) t))
|
(and (doom-module-get module submodule) t))
|
||||||
|
|
||||||
(defun doom-module-enable (module submodule &optional flags)
|
(defun doom-module-enable (module submodule &optional flags)
|
||||||
"Adds MODULE and SUBMODULE to `doom-modules', overwriting it if it exists.
|
"Adds MODULE and SUBMODULE to `doom-modules', overwriting it if it exists.
|
||||||
|
@ -275,9 +274,12 @@ added, if the file exists."
|
||||||
MODULE is a keyword, SUBMODULE is a symbol. e.g. :lang 'emacs-lisp.
|
MODULE is a keyword, SUBMODULE is a symbol. e.g. :lang 'emacs-lisp.
|
||||||
|
|
||||||
Used by `require!' and `depends-on!'."
|
Used by `require!' and `depends-on!'."
|
||||||
(puthash (cons module submodule)
|
(let ((key (cons module submodule)))
|
||||||
(doom-enlist (or flags t))
|
(puthash key
|
||||||
doom-modules))
|
(or (doom-enlist flags)
|
||||||
|
(gethash key doom-modules)
|
||||||
|
'(t))
|
||||||
|
doom-modules)))
|
||||||
|
|
||||||
(defun doom-module-pairs ()
|
(defun doom-module-pairs ()
|
||||||
"Returns `doom-modules' as a list of (MODULE . SUBMODULE) cons cells. The list
|
"Returns `doom-modules' as a list of (MODULE . SUBMODULE) cons cells. The list
|
||||||
|
@ -316,7 +318,7 @@ MODULES is an malformed plist of modules to load."
|
||||||
,@(cl-loop for (module . submodule) in (doom-module-pairs)
|
,@(cl-loop for (module . submodule) in (doom-module-pairs)
|
||||||
for module-path = (doom-module-path module submodule)
|
for module-path = (doom-module-path module submodule)
|
||||||
collect `(load! init ,module-path t) into inits
|
collect `(load! init ,module-path t) into inits
|
||||||
collect `(require! ,module ,submodule nil t) into configs
|
collect `(load! config ,module-path t) into configs
|
||||||
finally return (append inits configs))
|
finally return (append inits configs))
|
||||||
|
|
||||||
(when (display-graphic-p)
|
(when (display-graphic-p)
|
||||||
|
@ -405,7 +407,7 @@ 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."
|
||||||
(when (or reload-p (not (doom-module-loaded-p module submodule)))
|
(when (or reload-p (not (doom-module-enabled-p module submodule)))
|
||||||
(let ((module-path (doom-module-path module submodule)))
|
(let ((module-path (doom-module-path module submodule)))
|
||||||
(if (not (file-directory-p module-path))
|
(if (not (file-directory-p module-path))
|
||||||
(lwarn 'doom-modules :warning "Couldn't find module '%s %s'"
|
(lwarn 'doom-modules :warning "Couldn't find module '%s %s'"
|
||||||
|
@ -420,7 +422,7 @@ The module is only loaded once. If RELOAD-P is non-nil, load it again."
|
||||||
(error-message-string ex))))))))
|
(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-enabled-p'. It is evaluated at
|
||||||
compile-time/macro-expansion time."
|
compile-time/macro-expansion time."
|
||||||
(unless submodule
|
(unless submodule
|
||||||
(let* ((path (or load-file-name byte-compile-current-file))
|
(let* ((path (or load-file-name byte-compile-current-file))
|
||||||
|
@ -431,8 +433,8 @@ compile-time/macro-expansion time."
|
||||||
module (car module-pair)
|
module (car module-pair)
|
||||||
submodule (cdr module-pair))))
|
submodule (cdr module-pair))))
|
||||||
(if flag
|
(if flag
|
||||||
(and (memq flag (doom-module-flags module submodule)) t)
|
(and (memq flag (doom-module-get module submodule)) t)
|
||||||
(doom-module-loaded-p module submodule)))
|
(doom-module-enabled-p module submodule)))
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue