Function: package-menu-filter-by-version
package-menu-filter-by-version is an interactive and byte-compiled
function defined in package.el.gz.
Signature
(package-menu-filter-by-version VERSION PREDICATE)
Documentation
Filter the "*Packages*" buffer by VERSION and PREDICATE.
Display only packages with a matching version.
When called interactively, prompt for one of the qualifiers <,
> or =, and a package version. Show only packages that has a
lower (<), equal (=) or higher (>) version than the
specified one.
When called from Lisp, VERSION should be a version string and
PREDICATE should be the symbol =, < or >.
If VERSION is nil or the empty string, show all packages.
Probably introduced at or before Emacs version 28.1.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/package.el.gz
(defun package-menu-filter-by-version (version predicate)
"Filter the \"*Packages*\" buffer by VERSION and PREDICATE.
Display only packages with a matching version.
When called interactively, prompt for one of the qualifiers `<',
`>' or `=', and a package version. Show only packages that has a
lower (`<'), equal (`=') or higher (`>') version than the
specified one.
When called from Lisp, VERSION should be a version string and
PREDICATE should be the symbol `=', `<' or `>'.
If VERSION is nil or the empty string, show all packages."
(interactive (let ((choice (intern
(char-to-string
(read-char-choice
"Filter by version? [Type =, <, > or q] "
'(?< ?> ?= ?q))))))
(if (eq choice 'q)
'(quit nil)
(list (read-from-minibuffer
(concat "Filter by version ("
(pcase choice
('= "= equal to")
('< "< less than")
('> "> greater than"))
"): "))
choice)))
package-menu-mode)
(package--ensure-package-menu-mode)
(unless (equal predicate 'quit)
(if (or (not version) (string-empty-p version))
(package-menu--generate t t)
(package-menu--filter-by
(let ((fun (pcase predicate
('= #'version-list-=)
('< #'version-list-<)
('> (lambda (a b) (not (version-list-<= a b))))
(_ (error "Unknown predicate: %s" predicate))))
(ver (version-to-list version)))
(lambda (pkg-desc)
(funcall fun (package-desc-version pkg-desc) ver)))
(format "versions:%s%s" predicate version)))))