refactor: introduce doom-module-load-path

This renames doom-modules-dirs to doom-module-load-path, which dictates
where Doom searches for module trees or single modules, in preparation
for more sophisticated module lookups in v3.

This also deprecates doom-modules-dirs, which will be fully removed in
the v3 release.
This commit is contained in:
Henrik Lissner 2024-02-02 18:54:14 -05:00
parent 659f7bfc71
commit fc6934c240
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -8,10 +8,18 @@
(defvar doom-modules (make-hash-table :test 'equal) (defvar doom-modules (make-hash-table :test 'equal)
"A hash table of enabled modules. Set by `doom-initialize-modules'.") "A hash table of enabled modules. Set by `doom-initialize-modules'.")
(defvar doom-modules-dirs (defvar doom-module-load-path
(list (expand-file-name "modules/" doom-user-dir) (list (file-name-concat doom-user-dir "modules")
doom-modules-dir) (file-name-concat doom-emacs-dir "modules"))
"A list of module root directories. Order determines priority.") "A list of paths where Doom should search for modules.
Order determines priority (from highest to lowest).
Each entry is a string; an absolute path to the root directory of a module tree.
In other words, they should contain a two-level nested directory structure,
where the module's group and name was deduced from the first and second level of
directories. For example: if $DOOMDIR/modules/ is an entry, a
$DOOMDIR/modules/lang/ruby/ directory represents a ':lang ruby' module.")
;;; Module file variables ;;; Module file variables
(defvar doom-module-init-file "init.el" (defvar doom-module-init-file "init.el"
@ -41,6 +49,12 @@ NOT IMPLEMENTED YET. This file contains a module's metadata: their version,
maintainers, checks, features, submodules, debug information, etc. And are used maintainers, checks, features, submodules, debug information, etc. And are used
to locate modules in the user's file tree.") to locate modules in the user's file tree.")
;;
;;; Obsolete variables
(define-obsolete-variable-alias 'doom-modules-dirs 'doom-module-load-path "3.0.0")
(defconst doom-obsolete-modules (defconst doom-obsolete-modules
'((:feature (version-control (:emacs vc) (:ui vc-gutter)) '((:feature (version-control (:emacs vc) (:ui vc-gutter))
(spellcheck (:checkers spell)) (spellcheck (:checkers spell))
@ -342,14 +356,15 @@ If ENABLED-ONLY, return nil if the containing module isn't enabled."
((file-in-directory-p path doom-user-dir) ((file-in-directory-p path doom-user-dir)
(cons :user nil)))))) (cons :user nil))))))
(defun doom-module-load-path (&optional module-dirs) (defun doom-module-load-path (&optional module-load-path)
"Return a list of file paths to activated modules. "Return a list of file paths to activated modules.
The list is in no particular order and its file paths are absolute. If The list is in no particular order and its file paths are absolute. If
MODULE-DIRS is non-nil, include all modules (even disabled ones) available in MODULE-DIRS is non-nil, include all modules (even disabled ones) available in
those directories." those directories."
(declare (pure t) (side-effect-free t)) (declare (pure t) (side-effect-free t))
(cl-loop for (cat . mod) in (doom-module-list module-dirs) (cl-loop with module-load-path = (or module-load-path doom-module-load-path)
for (cat . mod) in (doom-module-list module-load-path)
collect (doom-module-locate-path cat mod))) collect (doom-module-locate-path cat mod)))
(defun doom-module-mplist-map (fn mplist) (defun doom-module-mplist-map (fn mplist)