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
|
(after! doom-cli-make
|
||||||
;;; Codeowners
|
;;; 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
|
;; I will be the default owner for everything in the repo unless a later
|
||||||
;; match takes precedence.
|
;; match takes precedence.
|
||||||
(add-to-list 'doom-make-codeowners "# The default owner(s) unless another 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
|
(doom-autoloads--scan
|
||||||
(append (doom-glob doom-core-dir "lib/*.el")
|
(append (doom-glob doom-core-dir "lib/*.el")
|
||||||
(cl-loop for dir
|
(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))
|
(list doom-user-dir))
|
||||||
if (doom-glob dir "autoload.el") collect (car it)
|
if (doom-glob dir "autoload.el") collect (car it)
|
||||||
if (doom-glob dir "autoload/*.el") append 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))
|
(generated-autoload-load-name (file-name-sans-extension file))
|
||||||
(target-buffer (current-buffer))
|
(target-buffer (current-buffer))
|
||||||
(module (doom-module-from-path file))
|
(module (doom-module-from-path file))
|
||||||
(module-enabled-p (and (or (memq (car module) '(:core :user))
|
(module-enabled-p (and (doom-module-p (car module) (cdr module))
|
||||||
(doom-module-p (car module) (cdr module)))
|
|
||||||
(doom-file-cookie-p file "if" t))))
|
(doom-file-cookie-p file "if" t))))
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(when module-enabled-p
|
(when module-enabled-p
|
||||||
|
|
|
@ -41,7 +41,7 @@ and your private config files, respectively. To recompile your packages, use
|
||||||
;; Only compile Doom's modules
|
;; Only compile Doom's modules
|
||||||
(doom-rpartial #'file-in-directory-p doom-emacs-dir)
|
(doom-rpartial #'file-in-directory-p doom-emacs-dir)
|
||||||
;; Omit `doom-user-dir', which is always first
|
;; Omit `doom-user-dir', which is always first
|
||||||
(cdr (doom-module-load-path)))))
|
(doom-module-load-path))))
|
||||||
recompile-p
|
recompile-p
|
||||||
verbose-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
|
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. The first returned path is always `doom-user-dir'."
|
those directories."
|
||||||
(declare (pure t) (side-effect-free t))
|
(declare (pure t) (side-effect-free t))
|
||||||
(append (list doom-user-dir)
|
(if module-dirs
|
||||||
(if module-dirs
|
(mapcar (lambda (m) (doom-module-locate-path (car m) (cdr m)))
|
||||||
(mapcar (lambda (m) (doom-module-locate-path (car m) (cdr m)))
|
(delete-dups
|
||||||
(delete-dups
|
(doom-files-in module-dirs
|
||||||
(doom-files-in (if (listp module-dirs)
|
:map #'doom-module-from-path
|
||||||
module-dirs
|
:type 'dirs
|
||||||
doom-modules-dirs)
|
:mindepth 1
|
||||||
:map #'doom-module-from-path
|
:depth 1)))
|
||||||
:type 'dirs
|
(delq
|
||||||
:mindepth 1
|
nil (cl-loop for (cat . mod) in (cddr (doom-module-list))
|
||||||
:depth 1)))
|
collect (doom-module-get cat mod :path)))))
|
||||||
(delq
|
|
||||||
nil (cl-loop for (cat . mod) in (doom-module-list)
|
|
||||||
collect (doom-module-get cat mod :path))))
|
|
||||||
nil))
|
|
||||||
|
|
||||||
(defun doom-module-mplist-map (fn mplist)
|
(defun doom-module-mplist-map (fn mplist)
|
||||||
"Apply FN to each module in 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 is `real', only return *real"
|
||||||
(if all-p
|
(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)))
|
(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!)))))
|
category module flag (file!)))))
|
||||||
t))
|
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)
|
(provide 'doom-modules)
|
||||||
;;; doom-modules.el ends here
|
;;; doom-modules.el ends here
|
||||||
|
|
|
@ -163,11 +163,7 @@ each package."
|
||||||
(ignore-errors (intern (cadr module)))
|
(ignore-errors (intern (cadr module)))
|
||||||
current-prefix-arg)))
|
current-prefix-arg)))
|
||||||
(mapc (lambda! ((cat . mod))
|
(mapc (lambda! ((cat . mod))
|
||||||
(if-let (packages-file
|
(if-let (packages-file (doom-module-locate-path cat mod "packages.el"))
|
||||||
(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"))))
|
|
||||||
(with-current-buffer
|
(with-current-buffer
|
||||||
(or (get-file-buffer packages-file)
|
(or (get-file-buffer packages-file)
|
||||||
(find-file-noselect packages-file))
|
(find-file-noselect packages-file))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue