diff options
author | Gabriel do Nascimento Ribeiro <gabriel.nascimento@nubank.com.br> | 2021-03-13 16:12:47 -0300 |
---|---|---|
committer | Stefan Kangas <stefan@marxist.se> | 2021-03-15 03:09:02 +0100 |
commit | 2d12df39267b4fca13a9739e6354985e807e1dd9 (patch) | |
tree | 3de823d43be4c22d0ad17767553413f47cc77c46 | |
parent | ca7cb9830bde49e76c59a2414a87a3f6eb3b0679 (diff) | |
download | emacs-2d12df39267b4fca13a9739e6354985e807e1dd9.tar.gz |
Init archive and add noconfirm to 'package-install-selected-packages'
* lisp/emacs-lisp/package.el (package-install-selected-packages):
Add call to 'package--archives-initialize' and add optional argument
NOCONFIRM to skip user confirmation when installing packages. (Bug#47124)
-rw-r--r-- | lisp/emacs-lisp/package.el | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index 0973963af22..2ecd92cee9d 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -2206,10 +2206,13 @@ directory." (package-install-from-buffer))) ;;;###autoload -(defun package-install-selected-packages () +(defun package-install-selected-packages (&optional noconfirm) "Ensure packages in `package-selected-packages' are installed. -If some packages are not installed propose to install them." +If some packages are not installed, propose to install them. +If optional argument NOCONFIRM is non-nil, don't ask for +confirmation to install packages." (interactive) + (package--archives-initialize) ;; We don't need to populate `package-selected-packages' before ;; using here, because the outcome is the same either way (nothing ;; gets installed). @@ -2220,10 +2223,11 @@ If some packages are not installed propose to install them." (difference (- (length not-installed) (length available)))) (cond (available - (when (y-or-n-p - (format "Packages to install: %d (%s), proceed? " - (length available) - (mapconcat #'symbol-name available " "))) + (when (or noconfirm + (y-or-n-p + (format "Packages to install: %d (%s), proceed? " + (length available) + (mapconcat #'symbol-name available " ")))) (mapc (lambda (p) (package-install p 'dont-select)) available))) ((> difference 0) (message "Packages that are not available: %d (the rest is already installed), maybe you need to `M-x package-refresh-contents'" |