refactor: register :core & :user as virtual modules
...that are always enabled. This way, the module API treats them as any other module. This also changes doom-module-load-path. If supplied directories, doom-user-dir will not be the CAR of its return value. If no dirs are supplied, then doom-core-dir and doom-user-dir are included (and will always be the first two items in the returned list).
This commit is contained in:
parent
10eb5db12d
commit
3a0f1aa3ef
5 changed files with 27 additions and 27 deletions
2
.doomrc
2
.doomrc
|
@ -19,7 +19,7 @@
|
|||
|
||||
(after! doom-cli-make
|
||||
;;; Codeowners
|
||||
(dolist (path (cdr (doom-module-load-path (list doom-modules-dir))))
|
||||
(dolist (path (doom-module-load-path (list doom-modules-dir)))
|
||||
;; I will be the default owner for everything in the repo unless a later
|
||||
;; match takes precedence.
|
||||
(add-to-list 'doom-make-codeowners "# The default owner(s) unless another takes precedence")
|
||||
|
|
|
@ -56,7 +56,7 @@ hoist buggy forms into autoloads.")
|
|||
(doom-autoloads--scan
|
||||
(append (doom-glob doom-core-dir "lib/*.el")
|
||||
(cl-loop for dir
|
||||
in (append (cdr (doom-module-load-path 'all-p))
|
||||
in (append (doom-module-load-path doom-modules-dirs)
|
||||
(list doom-user-dir))
|
||||
if (doom-glob dir "autoload.el") collect (car it)
|
||||
if (doom-glob dir "autoload/*.el") append it)
|
||||
|
@ -198,8 +198,7 @@ hoist buggy forms into autoloads.")
|
|||
(generated-autoload-load-name (file-name-sans-extension file))
|
||||
(target-buffer (current-buffer))
|
||||
(module (doom-module-from-path file))
|
||||
(module-enabled-p (and (or (memq (car module) '(:core :user))
|
||||
(doom-module-p (car module) (cdr module)))
|
||||
(module-enabled-p (and (doom-module-p (car module) (cdr module))
|
||||
(doom-file-cookie-p file "if" t))))
|
||||
(save-excursion
|
||||
(when module-enabled-p
|
||||
|
|
|
@ -41,7 +41,7 @@ and your private config files, respectively. To recompile your packages, use
|
|||
;; Only compile Doom's modules
|
||||
(doom-rpartial #'file-in-directory-p doom-emacs-dir)
|
||||
;; Omit `doom-user-dir', which is always first
|
||||
(cdr (doom-module-load-path)))))
|
||||
(doom-module-load-path))))
|
||||
recompile-p
|
||||
verbose-p))
|
||||
|
||||
|
|
|
@ -246,23 +246,19 @@ If ENABLED-ONLY, return nil if the containing module isn't enabled."
|
|||
|
||||
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
|
||||
those directories. The first returned path is always `doom-user-dir'."
|
||||
those directories."
|
||||
(declare (pure t) (side-effect-free t))
|
||||
(append (list doom-user-dir)
|
||||
(if module-dirs
|
||||
(mapcar (lambda (m) (doom-module-locate-path (car m) (cdr m)))
|
||||
(delete-dups
|
||||
(doom-files-in (if (listp module-dirs)
|
||||
module-dirs
|
||||
doom-modules-dirs)
|
||||
(doom-files-in module-dirs
|
||||
:map #'doom-module-from-path
|
||||
:type 'dirs
|
||||
:mindepth 1
|
||||
:depth 1)))
|
||||
(delq
|
||||
nil (cl-loop for (cat . mod) in (doom-module-list)
|
||||
collect (doom-module-get cat mod :path))))
|
||||
nil))
|
||||
nil (cl-loop for (cat . mod) in (cddr (doom-module-list))
|
||||
collect (doom-module-get cat mod :path)))))
|
||||
|
||||
(defun doom-module-mplist-map (fn mplist)
|
||||
"Apply FN to each module in MPLIST."
|
||||
|
@ -327,7 +323,7 @@ they're enabled, and in lexicographical order.
|
|||
|
||||
If ALL-P is `real', only return *real"
|
||||
(if all-p
|
||||
(mapcar #'doom-module-from-path (cdr (doom-module-load-path 'all)))
|
||||
(mapcar #'doom-module-from-path (doom-module-load-path doom-modules-dirs))
|
||||
(hash-table-keys doom-modules)))
|
||||
|
||||
|
||||
|
@ -584,5 +580,14 @@ CATEGORY and MODULE can be omitted When this macro is used from inside a module
|
|||
category module flag (file!)))))
|
||||
t))
|
||||
|
||||
|
||||
;;
|
||||
;;; Defaults
|
||||
|
||||
;; Register Doom's two virtual module categories, representing Doom's core and
|
||||
;; the user's config; which are always enabled.
|
||||
(doom-module-set :core nil :path doom-core-dir)
|
||||
(doom-module-set :user nil :path doom-user-dir)
|
||||
|
||||
(provide 'doom-modules)
|
||||
;;; doom-modules.el ends here
|
||||
|
|
|
@ -163,11 +163,7 @@ each package."
|
|||
(ignore-errors (intern (cadr module)))
|
||||
current-prefix-arg)))
|
||||
(mapc (lambda! ((cat . mod))
|
||||
(if-let (packages-file
|
||||
(pcase cat
|
||||
(:user (car (doom-glob doom-user-dir "packages.el")))
|
||||
(:core (car (doom-glob doom-core-dir "packages.el")))
|
||||
(_ (doom-module-locate-path cat mod "packages.el"))))
|
||||
(if-let (packages-file (doom-module-locate-path cat mod "packages.el"))
|
||||
(with-current-buffer
|
||||
(or (get-file-buffer packages-file)
|
||||
(find-file-noselect packages-file))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue