[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 0916fd3aaa: Add new command 'package-update'
From: |
Lars Ingebrigtsen |
Subject: |
master 0916fd3aaa: Add new command 'package-update' |
Date: |
Tue, 3 May 2022 12:00:47 -0400 (EDT) |
branch: master
commit 0916fd3aaacf62e641414fb2b474c86888116487
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Add new command 'package-update'
* doc/emacs/package.texi (Package Installation): Mention it.
* lisp/emacs-lisp/package.el (package-update): New command
(bug#18790).
---
doc/emacs/package.texi | 5 ++++-
etc/NEWS | 7 +++++++
lisp/emacs-lisp/package.el | 25 +++++++++++++++++++++++++
3 files changed, 36 insertions(+), 1 deletion(-)
diff --git a/doc/emacs/package.texi b/doc/emacs/package.texi
index caa65bf33b..bd3ae2aa6a 100644
--- a/doc/emacs/package.texi
+++ b/doc/emacs/package.texi
@@ -320,10 +320,13 @@ version of the package, a newer version is also installed.
@section Package Installation
@findex package-install
+@findex package-update
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.
+@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.
@cindex package requirements
A package may @dfn{require} certain other packages to be installed,
diff --git a/etc/NEWS b/etc/NEWS
index f897158afd..b6a4732633 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -707,6 +707,13 @@ script that was used in ancient South Asia. A new input
method,
* Changes in Specialized Modes and Packages in Emacs 29.1
+** Package
+
++++
+*** New command 'package-update'.
+This command allows you to upgrade packages without using 'M-x
+list-packages'.
+
** Miscellaneous
+++
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index 7f2c427c2e..58c1349e1c 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -2136,6 +2136,31 @@ to install it but still mark it as selected."
(message "Package `%s' installed." name))
(message "`%s' is already installed" name))))
+;;;###autoload
+(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))
+
(defun package-strip-rcs-id (str)
"Strip RCS version ID from the version string STR.
If the result looks like a dotted numeric version, return it.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 0916fd3aaa: Add new command 'package-update',
Lars Ingebrigtsen <=