[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#47124: 28.0.50; [PATCH] Init archive and add noconfirm to 'package-i
From: |
Stefan Kangas |
Subject: |
bug#47124: 28.0.50; [PATCH] Init archive and add noconfirm to 'package-install-selected-packages' |
Date: |
Sat, 13 Mar 2021 13:01:14 -0600 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Gabriel <gabriel376@hotmail.com> writes:
> This patch adds the following to 'package-install-selected-packages':
> - a call to 'package--archives-initialize', to initialize the archive
> contents, similar to how 'package-install' works;
> - a new optional argument NOCONFIRM, to don't ask for confirmation when
> installing new packages.
LGTM, with one minor nit:
> ;;;###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)
> ;; We don't need to populate `package-selected-packages' before
> ;; using here, because the outcome is the same either way (nothing
> ;; gets installed).
> + (package--archives-initialize)
I would put this new line above the comment, as the comment relates to
this next line:
> (if (not package-selected-packages)
> (message "`package-selected-packages' is empty, nothing to install")
> (let* ((not-installed (seq-remove #'package-installed-p
> package-selected-packages))
> @@ -2220,10 +2223,11 @@ package-install-selected-packages
> (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'"