summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/package-vc.el
diff options
context:
space:
mode:
authorPhilip Kaludercic <philipk@posteo.net>2022-11-04 18:04:35 +0100
committerPhilip Kaludercic <philipk@posteo.net>2022-11-04 18:05:41 +0100
commitb5850ba3ae8758731d9420cf62c4fca6b765905c (patch)
tree7d679a4f0e932b755f35b27eb42666d8834596bc /lisp/emacs-lisp/package-vc.el
parent0efc611697466551368c5c2deb05f598f4ec0eeb (diff)
downloademacs-b5850ba3ae8758731d9420cf62c4fca6b765905c.tar.gz
emacs-b5850ba3ae8758731d9420cf62c4fca6b765905c.tar.bz2
emacs-b5850ba3ae8758731d9420cf62c4fca6b765905c.zip
Document 'package-vc-selected-packages'
* doc/emacs/package.texi: Expand documentation and give example. * etc/NEWS: Mention 'package-vc-selected-packages'. * lisp/emacs-lisp/package-vc.el (package-vc--select-packages): Remove function. (package-vc-ensure-packages): Add function based on 'package-vc--select-packages'. (package-vc-selected-packages): Call 'package-vc-ensure-packages' from custom setter.
Diffstat (limited to 'lisp/emacs-lisp/package-vc.el')
-rw-r--r--lisp/emacs-lisp/package-vc.el22
1 files changed, 12 insertions, 10 deletions
diff --git a/lisp/emacs-lisp/package-vc.el b/lisp/emacs-lisp/package-vc.el
index 3eac55ba544..b18b5b1e483 100644
--- a/lisp/emacs-lisp/package-vc.el
+++ b/lisp/emacs-lisp/package-vc.el
@@ -103,13 +103,13 @@ symbol is used. The value must be a member of
vc-handled-backends))
:version "29.1")
-(defun package-vc--select-packages (sym val)
- "Custom setter for `package-vc-selected-packages'.
-It will ensure that all the packages are installed as source
-packages. Finally SYM is set to VAL."
- (pcase-dolist (`(,(and (pred symbolp) name) . ,spec) val)
+(defun package-vc-ensure-packages ()
+ "Ensure source packages specified in `package-vc-selected-packages'."
+ (pcase-dolist (`(,(and (pred symbolp) name) . ,spec)
+ package-vc-selected-packages)
(let ((pkg-desc (cadr (assoc name package-alist #'string=))))
- (unless (and name (package-installed-p name) (package-vc-p pkg-desc))
+ (unless (and name (package-installed-p name)
+ (package-vc-p pkg-desc))
(cond
((null spec)
(package-vc-install name))
@@ -117,8 +117,7 @@ packages. Finally SYM is set to VAL."
(package-vc-install name nil spec))
((listp spec)
(package-vc--archives-initialize)
- (package-vc--unpack pkg-desc spec))))))
- (custom-set-default sym val))
+ (package-vc--unpack pkg-desc spec)))))))
;;;###autoload
(defcustom package-vc-selected-packages '()
@@ -134,7 +133,8 @@ is a symbol designating the package and SPEC is one of:
specification.
This user option differs from `package-selected-packages' in that
-it is meant to be specified manually."
+it is meant to be specified manually. You can also use the
+function `package-vc-selected-packages' to apply the changes."
:type '(alist :tag "List of ensured packages"
:key-type (symbol :tag "Package")
:value-type
@@ -145,7 +145,9 @@ it is meant to be specified manually."
(:lisp-dir string)
(:main-file string)
(:vc-backend symbol)))))
- :set #'package-vc--select-packages
+ :set (lambda (sym val)
+ (custom-set-default sym val)
+ (package-vc-ensure-packages))
:version "29.1")
(defvar package-vc--archive-spec-alist nil