diff options
author | Pieter van Oostrum <pieter@vanoostrum.org> | 2020-03-05 20:20:04 +0100 |
---|---|---|
committer | Stefan Kangas <stefankangas@gmail.com> | 2020-05-09 18:19:35 +0200 |
commit | 196bc13b7bc5a29fa4d27e83d7cf0db4d99aa8b7 (patch) | |
tree | 7ef40724ff11cf06a6c63c6be063a615ee274da8 /lisp | |
parent | e59f697cd589e2b68bccb752787ad4a8c9da375d (diff) | |
download | emacs-196bc13b7bc5a29fa4d27e83d7cf0db4d99aa8b7.tar.gz |
Add new filter command to Package Menu (Bug#39903)
* lisp/emacs-lisp/package.el
(package-menu-filter-marked): New filter command.
* test/lisp/emacs-lisp/package-tests.el
(package-test-list-filter-marked): New test.
(package-menu-mode-menu):
(package-menu-mode-map): Update menu to include new filter command.
* doc/emacs/package.texi (Package Menu): Document the new command.
* etc/NEWS: Announce the new command.
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/emacs-lisp/package.el | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index 4312ab9ca9a..ecf833b5473 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -2692,6 +2692,7 @@ either a full name or nil, and EMAIL is a valid email address." (define-key map (kbd "/ n") 'package-menu-filter-by-name) (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) map) "Local keymap for `package-menu-mode' buffers.") @@ -2722,6 +2723,7 @@ either a full name or nil, and EMAIL is a valid email address." ["Filter by Name" package-menu-filter-by-name :help "Filter packages by name"] ["Filter by Status" package-menu-filter-by-status :help "Filter packages by status"] ["Filter by Version" package-menu-filter-by-version :help "Filter packages by version"] + ["Filter Marked" package-menu-filter-marked :help "Filter packages marked for upgrade"] ["Clear Filter" package-menu-clear-filter :help "Clear package list filter"]) ["Hide by Regexp" package-menu-hide-package :help "Hide all packages matching a regexp"] @@ -3855,6 +3857,35 @@ If VERSION is nil or the empty string, show all packages." (funcall fun (package-desc-version pkg-desc) ver))) (format "versions:%s%s" predicate version))))) +(defun package-menu-filter-marked () + "Filter \"*Packages*\" buffer by non-empty upgrade mark. +Unlike other filters, this leaves the marks intact." + (interactive) + (package--ensure-package-menu-mode) + (widen) + (let (found-entries mark pkg-id entry marks) + (save-excursion + (goto-char (point-min)) + (while (not (eobp)) + (setq mark (char-after)) + (unless (eq mark ?\s) + (setq pkg-id (tabulated-list-get-id)) + (setq entry (package-menu--print-info-simple pkg-id)) + (push entry found-entries) + ;; remember the mark + (push (cons pkg-id mark) marks)) + (forward-line)) + (if found-entries + (progn + (setq tabulated-list-entries found-entries) + (package-menu--display t nil) + ;; redo the marks, but we must remember the marks!! + (goto-char (point-min)) + (while (not (eobp)) + (setq mark (cdr (assq (tabulated-list-get-id) marks))) + (tabulated-list-put-tag (char-to-string mark) t))) + (user-error "No packages found"))))) + (defun package-menu-clear-filter () "Clear any filter currently applied to the \"*Packages*\" buffer." (interactive) |