Allow doom-package-list to scrape *all* packages
Even ones that are conditional. This does mean its plist is unevaluated, however.
This commit is contained in:
parent
f02e7faefb
commit
c3a9828fa3
1 changed files with 54 additions and 42 deletions
|
@ -205,54 +205,66 @@ files."
|
||||||
(not (doom-package-installed-p pkg))))
|
(not (doom-package-installed-p pkg))))
|
||||||
collect (cons pkg (cdr (assq pkg doom-packages))))))
|
collect (cons pkg (cdr (assq pkg doom-packages))))))
|
||||||
|
|
||||||
|
(defun doom--read-module-packages-file (file &optional raw noerror)
|
||||||
|
(with-temp-buffer ; prevent buffer-local settings from propagating
|
||||||
|
(condition-case e
|
||||||
|
(if (not raw)
|
||||||
|
(load file noerror t t)
|
||||||
|
(when (file-readable-p file)
|
||||||
|
(insert-file-contents file)
|
||||||
|
(while (re-search-forward "(package! " nil t)
|
||||||
|
(save-excursion
|
||||||
|
(goto-char (match-beginning 0))
|
||||||
|
(cl-destructuring-bind (name . plist) (cdr (sexp-at-point))
|
||||||
|
(push (cons name
|
||||||
|
(plist-put plist :modules
|
||||||
|
(cond ((file-in-directory-p file doom-private-dir)
|
||||||
|
(list :private))
|
||||||
|
((file-in-directory-p file doom-core-dir)
|
||||||
|
(list :core))
|
||||||
|
((doom-module-from-path file)))))
|
||||||
|
doom-packages))))))
|
||||||
|
((debug error)
|
||||||
|
(signal 'doom-package-error
|
||||||
|
(list (or (doom-module-from-path file)
|
||||||
|
'(:private . packages))
|
||||||
|
e))))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun doom-package-list (&optional all-p)
|
(defun doom-package-list (&optional all-p)
|
||||||
"Retrieve a list of explicitly declared packages from enabled modules.
|
"Retrieve a list of explicitly declared packages from enabled modules.
|
||||||
|
|
||||||
This excludes core packages listed in `doom-core-packages'.
|
This excludes core packages listed in `doom-core-packages'.
|
||||||
|
|
||||||
If ALL-P, gather packages across all modules, including disabled ones."
|
If ALL-P, gather packages unconditionally across all modules, including disabled
|
||||||
(with-temp-buffer ; prevent buffer-local settings from propagating
|
ones."
|
||||||
(let ((noninteractive t)
|
(let ((noninteractive t)
|
||||||
(doom--stage 'packages)
|
(doom--stage 'packages)
|
||||||
(doom-modules (doom-modules))
|
(doom-modules (doom-modules))
|
||||||
doom-packages
|
doom-packages
|
||||||
doom-disabled-packages
|
doom-disabled-packages
|
||||||
package-pinned-packages)
|
package-pinned-packages)
|
||||||
(cl-letf ((load-fn
|
(doom--read-module-packages-file (expand-file-name "packages.el" doom-core-dir) all-p)
|
||||||
(lambda (file &optional noerror)
|
(let ((private-packages (expand-file-name "packages.el" doom-private-dir)))
|
||||||
(condition-case e
|
(unless all-p
|
||||||
(if all-p
|
;; We load the private packages file twice to ensure disabled packages
|
||||||
(setq doom-packages
|
;; are seen ASAP, and a second time to ensure privately overridden
|
||||||
(append (let (doom-packages)
|
;; packages are properly overwritten.
|
||||||
(load file noerror t t)
|
(doom--read-module-packages-file private-packages nil t))
|
||||||
doom-packages)
|
(if all-p
|
||||||
doom-packages))
|
(mapc #'doom--read-module-packages-file
|
||||||
(load file noerror t t))
|
(doom-files-in doom-modules-dir
|
||||||
((debug error)
|
:depth 2
|
||||||
(signal 'doom-package-error
|
:full t
|
||||||
(list (or (doom-module-from-path file)
|
:match "/packages\\.el$"))
|
||||||
'(:private . packages))
|
(cl-loop for key being the hash-keys of doom-modules
|
||||||
e)))))))
|
for path = (doom-module-path (car key) (cdr key) "packages.el")
|
||||||
(funcall load-fn (expand-file-name "packages.el" doom-core-dir))
|
for doom--current-module = key
|
||||||
(let ((private-packages (expand-file-name "packages.el" doom-private-dir)))
|
do (doom--read-module-packages-file path nil t)))
|
||||||
;; We load the private packages file twice to ensure disabled packages
|
(doom--read-module-packages-file private-packages all-p t))
|
||||||
;; are seen ASAP, and a second time to ensure privately overridden
|
(append (cl-loop for package in doom-core-packages
|
||||||
;; packages are properly overwritten.
|
collect (list package :modules '((:core internal))))
|
||||||
(funcall load-fn private-packages t)
|
(nreverse doom-packages))))
|
||||||
(if all-p
|
|
||||||
(mapc load-fn (doom-files-in doom-modules-dir
|
|
||||||
:depth 2
|
|
||||||
:full t
|
|
||||||
:match "/packages\\.el$"))
|
|
||||||
(cl-loop for key being the hash-keys of doom-modules
|
|
||||||
for path = (doom-module-path (car key) (cdr key) "packages.el")
|
|
||||||
for doom--current-module = key
|
|
||||||
do (funcall load-fn path t)))
|
|
||||||
(funcall load-fn private-packages t))
|
|
||||||
(append (cl-loop for package in doom-core-packages
|
|
||||||
collect (list package :modules '((:core internal))))
|
|
||||||
(nreverse doom-packages))))))
|
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun doom-get-package-alist ()
|
(defun doom-get-package-alist ()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue