Redesign doom-get-package
Now more useful for filtering packages by certain properties.
This commit is contained in:
parent
01d1a814f9
commit
ee154911ae
1 changed files with 31 additions and 17 deletions
|
@ -125,27 +125,42 @@ was installed with."
|
||||||
(cdr (plist-get (cdr doom-recipe) :recipe))))))))
|
(cdr (plist-get (cdr doom-recipe) :recipe))))))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun doom-get-packages (&optional installed-only-p)
|
(cl-defun doom-get-packages (&key installed backend private disabled all sort)
|
||||||
"Retrieves a list of explicitly installed packages (i.e. non-dependencies).
|
"Retrieves a list of primary packages (i.e. non-dependencies). Each element is
|
||||||
Each element is a cons cell, whose car is the package symbol and whose cdr is
|
a cons cell, whose car is the package symbol and whose cdr is the quelpa recipe
|
||||||
the quelpa recipe (if any).
|
(if any).
|
||||||
|
|
||||||
BACKEND can be 'quelpa or 'elpa, and will instruct this function to return only
|
BACKEND can be 'quelpa or 'elpa, and will instruct this function to return only
|
||||||
the packages relevant to that backend.
|
the packages relevant to that backend.
|
||||||
|
|
||||||
Warning: this function is expensive; it re-evaluates all of doom's config files.
|
If INSTALLED is non-nil, only return installed packages.
|
||||||
Be careful not to use it in a loop.
|
|
||||||
|
|
||||||
If INSTALLED-ONLY-P, only return packages that are installed."
|
If PRIVATE, only return private packages.
|
||||||
(doom-initialize-packages t)
|
|
||||||
(cl-loop with packages = (append doom-core-packages (mapcar #'car doom-packages))
|
If DISABLED, only return disabled packages.
|
||||||
for sym in (cl-delete-duplicates packages)
|
|
||||||
if (and (or (not installed-only-p)
|
If ALL, include disabled packages.
|
||||||
|
|
||||||
|
Warning: this function is expensive, as it re-evaluates your all packages.el
|
||||||
|
files."
|
||||||
|
(doom-initialize-packages (if (or installed backend) t 'internal))
|
||||||
|
(cl-loop with packages = (append (mapcar #'list doom-core-packages)
|
||||||
|
doom-packages)
|
||||||
|
for (sym . plist)
|
||||||
|
in (if sort
|
||||||
|
(cl-sort packages #'string-lessp :key #'car)
|
||||||
|
packages)
|
||||||
|
if (and (or all
|
||||||
|
(not (plist-get plist :disabled)))
|
||||||
|
(or (not disabled)
|
||||||
|
(plist-get plist :disabled))
|
||||||
|
(or (not installed)
|
||||||
(package-installed-p sym))
|
(package-installed-p sym))
|
||||||
(or (assq sym doom-packages)
|
(or (not backend)
|
||||||
(and (assq sym package-alist)
|
(eq (doom-package-backend sym t) backend))
|
||||||
(list sym))))
|
(or (not private)
|
||||||
collect it))
|
(plist-get plist :private)))
|
||||||
|
collect (cons sym plist)))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun doom-get-depending-on (name)
|
(defun doom-get-depending-on (name)
|
||||||
|
@ -222,9 +237,8 @@ Used by `doom//packages-update'."
|
||||||
depended on.
|
depended on.
|
||||||
|
|
||||||
Used by `doom//packages-autoremove'."
|
Used by `doom//packages-autoremove'."
|
||||||
(doom-initialize-packages t)
|
|
||||||
(let ((package-selected-packages
|
(let ((package-selected-packages
|
||||||
(append (mapcar #'car doom-packages) doom-core-packages)))
|
(mapcar #'car (doom-get-packages :installed t))))
|
||||||
(append (package--removable-packages)
|
(append (package--removable-packages)
|
||||||
(cl-loop for pkg in package-selected-packages
|
(cl-loop for pkg in package-selected-packages
|
||||||
if (and (doom-package-different-backend-p pkg)
|
if (and (doom-package-different-backend-p pkg)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue