From 8c96c720fa5ee67b902778199ee35991779300dc Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Mon, 19 Oct 2020 20:30:52 +0200 Subject: [PATCH] Add command package-menu-filter-upgradable * lisp/emacs-lisp/package.el (package-menu-filter-upgradable): New command. (Bug#41436) (package-menu-mode-map): Bind the new command. * doc/emacs/package.texi (Package Menu): Document the new command. --- doc/emacs/package.texi | 6 ++++++ etc/NEWS | 1 + lisp/emacs-lisp/package.el | 10 ++++++++++ 3 files changed, 17 insertions(+) diff --git a/doc/emacs/package.texi b/doc/emacs/package.texi index 453d9eb4010..56e8ee1363a 100644 --- a/doc/emacs/package.texi +++ b/doc/emacs/package.texi @@ -222,6 +222,12 @@ lower, equal or higher version than the one specified. Filter package list by non-empty mark (@code{package-menu-filter-marked}). This shows only the packages that have been marked to be installed or deleted. +@item / u +@kindex / u @r{(Package Menu)} +@findex package-menu-filter-upgradable +Filter package list to show only packages for which there are +available upgrades (@code{package-menu-filter-upgradable}). + @item / / @kindex / / @r{(Package Menu)} @findex package-menu-filter-clear diff --git a/etc/NEWS b/etc/NEWS index 390cccbff30..c571fa95d18 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -736,6 +736,7 @@ key binding / s package-menu-filter-by-status / v package-menu-filter-by-version / m package-menu-filter-marked +/ u package-menu-filter-upgradable / / package-menu-filter-clear --- diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index 7b192d640b2..23692aab32a 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -2708,6 +2708,7 @@ either a full name or nil, and EMAIL is a valid email address." (define-key map (kbd "/ s") 'package-menu-filter-by-status) (define-key map (kbd "/ v") 'package-menu-filter-by-version) (define-key map (kbd "/ m") 'package-menu-filter-marked) + (define-key map (kbd "/ u") 'package-menu-filter-upgradable) map) "Local keymap for `package-menu-mode' buffers.") @@ -3904,6 +3905,15 @@ Unlike other filters, this leaves the marks intact." (tabulated-list-put-tag (char-to-string mark) t))) (user-error "No packages found"))))) +(defun package-menu-filter-upgradable () + "Filter \"*Packages*\" buffer to show only upgradable packages." + (interactive) + (let ((pkgs (mapcar #'car (package-menu--find-upgrades)))) + (package-menu--filter-by + (lambda (pkg) + (memql (package-desc-name pkg) pkgs)) + "upgradable"))) + (defun package-menu-clear-filter () "Clear any filter currently applied to the \"*Packages*\" buffer." (interactive) -- 2.39.2