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 whose version satisfies the condition defined by VERSION and PREDICATE.
When called interactively, prompt for one of the comparison operators
<, > or =, and for a version. Show only packages whose version
is lower (<), equal (=) or higher (>) than the specified VERSION.
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.
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 whose version satisfies the condition
defined by VERSION and PREDICATE.
When called interactively, prompt for one of the comparison operators
`<', `>' or `=', and for a version. Show only packages whose version
is lower (`<'), equal (`=') or higher (`>') than the specified VERSION.
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)))))