]> git.eshelyaron.com Git - emacs.git/commitdiff
Init archive and add noconfirm to 'package-install-selected-packages'
authorGabriel do Nascimento Ribeiro <gabriel.nascimento@nubank.com.br>
Sat, 13 Mar 2021 19:12:47 +0000 (16:12 -0300)
committerStefan Kangas <stefan@marxist.se>
Mon, 15 Mar 2021 02:09:02 +0000 (03:09 +0100)
* 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)

lisp/emacs-lisp/package.el

index 0973963af2244a0fda9fba01e4a806f368eebac6..2ecd92cee9d970f63708a5e8652f8800888ffd3f 100644 (file)
@@ -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'"