[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 42001f843b: New command 'package-update-all'
From: |
Lars Ingebrigtsen |
Subject: |
master 42001f843b: New command 'package-update-all' |
Date: |
Wed, 11 May 2022 21:59:46 -0400 (EDT) |
branch: master
commit 42001f843bb7ca687bf5096543a5d478dab38b87
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
New command 'package-update-all'
* lisp/emacs-lisp/package.el (package-update-all): New function
(bug#19146).
(package--updateable-packages): Factored out...
(package-update): ... from here.
---
doc/emacs/package.texi | 4 +++-
etc/NEWS | 4 ++++
lisp/emacs-lisp/package.el | 58 ++++++++++++++++++++++++++++++----------------
3 files changed, 45 insertions(+), 21 deletions(-)
diff --git a/doc/emacs/package.texi b/doc/emacs/package.texi
index fc2a093ec4..eb4f5b0eda 100644
--- a/doc/emacs/package.texi
+++ b/doc/emacs/package.texi
@@ -329,12 +329,14 @@ version of the package, a newer version is also installed.
@findex package-install
@findex package-update
+@findex package-update-all
Packages are most conveniently installed using the package menu
(@pxref{Package Menu}), but you can also use the command @kbd{M-x
package-install}. This prompts for the name of a package with the
@samp{available} status, then downloads and installs it. Similarly,
if you want to update a package, you can use the @kbd{M-x
-package-update} command.
+package-update} command, and if you just want to update all the
+packages, you can use the @kbd{M-x package-update-all} command.
@cindex package requirements
A package may @dfn{require} certain other packages to be installed,
diff --git a/etc/NEWS b/etc/NEWS
index d9777eecd6..672260ca82 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -829,6 +829,10 @@ this includes "binary" buffers like 'archive-mode' and
'image-mode'.
** Package
++++
+*** New command 'package-update-all'.
+This command allows updating all packages without any queries.
+
+++
*** New command 'package-update'.
This command allows you to upgrade packages without using 'M-x
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index c1e14a4acb..72b22a6556 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -2140,26 +2140,44 @@ to install it but still mark it as selected."
(defun package-update (name)
"Update package NAME if a newer version exists."
(interactive
- (progn
- ;; Initialize the package system to get the list of package
- ;; symbols for completion.
- (package--archives-initialize)
- (list (completing-read
- "Update package: "
- (mapcar
- #'car
- (seq-filter
- (lambda (elt)
- (let ((available
- (assq (car elt) package-archive-contents)))
- (and available
- (version-list-<
- (package-desc-priority-version (cadr elt))
- (package-desc-priority-version (cadr available))))))
- package-alist))
- nil t))))
- (package-delete (cadr (assq (intern name) package-alist)) 'force)
- (package-install (intern name) 'dont-select))
+ (list (completing-read
+ "Update package: " (package--updateable-packages) nil t)))
+ (let ((package (if (symbolp name)
+ name
+ (intern name))))
+ (package-delete (cadr (assq package package-alist)) 'force)
+ (package-install package 'dont-select)))
+
+(defun package--updateable-packages ()
+ ;; Initialize the package system to get the list of package
+ ;; symbols for completion.
+ (package--archives-initialize)
+ (mapcar
+ #'car
+ (seq-filter
+ (lambda (elt)
+ (let ((available
+ (assq (car elt) package-archive-contents)))
+ (and available
+ (version-list-<
+ (package-desc-priority-version (cadr elt))
+ (package-desc-priority-version (cadr available))))))
+ package-alist)))
+
+(defun package-update-all (&optional inhibit-queries)
+ "Upgrade all packages."
+ (interactive "P")
+ (let ((updateable (package--updateable-packages)))
+ (if (not updateable)
+ (message "No packages to update")
+ (when (and (not inhibit-queries)
+ (not (yes-or-no-p
+ (if (length= updateable 1)
+ "One package to update. Do it? "
+ (format "%s packages to update. Do it?"
+ (length updateable))))))
+ (user-error "Updating aborted"))
+ (mapc #'package-update updateable))))
(defun package-strip-rcs-id (str)
"Strip RCS version ID from the version string STR.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 42001f843b: New command 'package-update-all',
Lars Ingebrigtsen <=