mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-15 10:30:25 -08:00
Add command to filter package menu by name or description
* lisp/emacs-lisp/package.el (package-menu-filter-by-description): (package-menu-filter-by-name-or-description): New commands to filter the package menu. (Bug#44699) (package-menu-mode-map): Bind the above new commands. (package-menu-mode-menu): Add new commands to the menu. * doc/emacs/package.texi (Package Menu): Document new commands.
This commit is contained in:
parent
3626c9ae83
commit
0a7ec10ac6
3 changed files with 62 additions and 1 deletions
|
|
@ -187,6 +187,14 @@ Filter package list by archive (@code{package-menu-filter-by-archive}).
|
||||||
This prompts for a package archive (e.g., @samp{gnu}), then shows only
|
This prompts for a package archive (e.g., @samp{gnu}), then shows only
|
||||||
packages from that archive.
|
packages from that archive.
|
||||||
|
|
||||||
|
@item / d
|
||||||
|
@kindex / d @r{(Package Menu)}
|
||||||
|
@findex package-menu-filter-by-description
|
||||||
|
Filter package list by description
|
||||||
|
(@code{package-menu-filter-by-description}). This prompts for a
|
||||||
|
regular expression, then shows only packages with descriptions
|
||||||
|
matching that regexp.
|
||||||
|
|
||||||
@item / k
|
@item / k
|
||||||
@kindex / k @r{(Package Menu)}
|
@kindex / k @r{(Package Menu)}
|
||||||
@findex package-menu-filter-by-keyword
|
@findex package-menu-filter-by-keyword
|
||||||
|
|
@ -194,6 +202,14 @@ Filter package list by keyword (@code{package-menu-filter-by-keyword}).
|
||||||
This prompts for a keyword (e.g., @samp{games}), then shows only
|
This prompts for a keyword (e.g., @samp{games}), then shows only
|
||||||
packages with that keyword.
|
packages with that keyword.
|
||||||
|
|
||||||
|
@item / N
|
||||||
|
@kindex / N @r{(Package Menu)}
|
||||||
|
@findex package-menu-filter-by-name-or-description
|
||||||
|
Filter package list by name or description
|
||||||
|
(@code{package-menu-filter-by-name-or-description}). This prompts for
|
||||||
|
a regular expression, then shows only packages with a name or
|
||||||
|
description matching that regexp.
|
||||||
|
|
||||||
@item / n
|
@item / n
|
||||||
@kindex / n @r{(Package Menu)}
|
@kindex / n @r{(Package Menu)}
|
||||||
@findex package-menu-filter-by-name
|
@findex package-menu-filter-by-name
|
||||||
|
|
|
||||||
4
etc/NEWS
4
etc/NEWS
|
|
@ -831,12 +831,14 @@ equivalent to '(map (:sym sym))'.
|
||||||
|
|
||||||
+++
|
+++
|
||||||
*** New commands to filter the package list.
|
*** New commands to filter the package list.
|
||||||
The filter command key bindings are as follows:
|
The filter commands are bound to the following keys:
|
||||||
|
|
||||||
key binding
|
key binding
|
||||||
--- -------
|
--- -------
|
||||||
/ a package-menu-filter-by-archive
|
/ a package-menu-filter-by-archive
|
||||||
|
/ d package-menu-filter-by-description
|
||||||
/ k package-menu-filter-by-keyword
|
/ k package-menu-filter-by-keyword
|
||||||
|
/ N package-menu-filter-by-name-or-description
|
||||||
/ n package-menu-filter-by-name
|
/ n package-menu-filter-by-name
|
||||||
/ s package-menu-filter-by-status
|
/ s package-menu-filter-by-status
|
||||||
/ v package-menu-filter-by-version
|
/ v package-menu-filter-by-version
|
||||||
|
|
|
||||||
|
|
@ -2704,7 +2704,9 @@ either a full name or nil, and EMAIL is a valid email address."
|
||||||
(define-key map "(" #'package-menu-toggle-hiding)
|
(define-key map "(" #'package-menu-toggle-hiding)
|
||||||
(define-key map (kbd "/ /") 'package-menu-clear-filter)
|
(define-key map (kbd "/ /") 'package-menu-clear-filter)
|
||||||
(define-key map (kbd "/ a") 'package-menu-filter-by-archive)
|
(define-key map (kbd "/ a") 'package-menu-filter-by-archive)
|
||||||
|
(define-key map (kbd "/ d") 'package-menu-filter-by-description)
|
||||||
(define-key map (kbd "/ k") 'package-menu-filter-by-keyword)
|
(define-key map (kbd "/ k") 'package-menu-filter-by-keyword)
|
||||||
|
(define-key map (kbd "/ N") 'package-menu-filter-by-name-or-description)
|
||||||
(define-key map (kbd "/ n") 'package-menu-filter-by-name)
|
(define-key map (kbd "/ n") 'package-menu-filter-by-name)
|
||||||
(define-key map (kbd "/ s") 'package-menu-filter-by-status)
|
(define-key map (kbd "/ s") 'package-menu-filter-by-status)
|
||||||
(define-key map (kbd "/ v") 'package-menu-filter-by-version)
|
(define-key map (kbd "/ v") 'package-menu-filter-by-version)
|
||||||
|
|
@ -2736,8 +2738,11 @@ either a full name or nil, and EMAIL is a valid email address."
|
||||||
"--"
|
"--"
|
||||||
("Filter Packages"
|
("Filter Packages"
|
||||||
["Filter by Archive" package-menu-filter-by-archive :help "Filter packages by archive"]
|
["Filter by Archive" package-menu-filter-by-archive :help "Filter packages by archive"]
|
||||||
|
["Filter by Description" package-menu-filter-by-description :help "Filter packages by description"]
|
||||||
["Filter by Keyword" package-menu-filter-by-keyword :help "Filter packages by keyword"]
|
["Filter by Keyword" package-menu-filter-by-keyword :help "Filter packages by keyword"]
|
||||||
["Filter by Name" package-menu-filter-by-name :help "Filter packages by name"]
|
["Filter by Name" package-menu-filter-by-name :help "Filter packages by name"]
|
||||||
|
["Filter by Name or Description" package-menu-filter-by-name-or-description
|
||||||
|
:help "Filter packages by name or description"]
|
||||||
["Filter by Status" package-menu-filter-by-status :help "Filter packages by status"]
|
["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 by Version" package-menu-filter-by-version :help "Filter packages by version"]
|
||||||
["Filter Marked" package-menu-filter-marked :help "Filter packages marked for upgrade"]
|
["Filter Marked" package-menu-filter-marked :help "Filter packages marked for upgrade"]
|
||||||
|
|
@ -3765,6 +3770,23 @@ packages."
|
||||||
(string-join archive ",")
|
(string-join archive ",")
|
||||||
archive)))))
|
archive)))))
|
||||||
|
|
||||||
|
(defun package-menu-filter-by-description (description)
|
||||||
|
"Filter the \"*Packages*\" buffer by DESCRIPTION regexp.
|
||||||
|
Display only packages with a description that matches regexp
|
||||||
|
DESCRIPTION.
|
||||||
|
|
||||||
|
When called interactively, prompt for DESCRIPTION.
|
||||||
|
|
||||||
|
If DESCRIPTION is nil or the empty string, show all packages."
|
||||||
|
(interactive (list (read-regexp "Filter by description (regexp)")))
|
||||||
|
(package--ensure-package-menu-mode)
|
||||||
|
(if (or (not description) (string-empty-p description))
|
||||||
|
(package-menu--generate t t)
|
||||||
|
(package-menu--filter-by (lambda (pkg-desc)
|
||||||
|
(string-match description
|
||||||
|
(package-desc-summary pkg-desc)))
|
||||||
|
(format "desc:%s" description))))
|
||||||
|
|
||||||
(defun package-menu-filter-by-keyword (keyword)
|
(defun package-menu-filter-by-keyword (keyword)
|
||||||
"Filter the \"*Packages*\" buffer by KEYWORD.
|
"Filter the \"*Packages*\" buffer by KEYWORD.
|
||||||
Display only packages with specified KEYWORD.
|
Display only packages with specified KEYWORD.
|
||||||
|
|
@ -3790,6 +3812,27 @@ packages."
|
||||||
(define-obsolete-function-alias
|
(define-obsolete-function-alias
|
||||||
'package-menu-filter #'package-menu-filter-by-keyword "27.1")
|
'package-menu-filter #'package-menu-filter-by-keyword "27.1")
|
||||||
|
|
||||||
|
(defun package-menu-filter-by-name-or-description (name-or-description)
|
||||||
|
"Filter the \"*Packages*\" buffer by NAME-OR-DESCRIPTION regexp.
|
||||||
|
Display only packages with a name-or-description that matches regexp
|
||||||
|
NAME-OR-DESCRIPTION.
|
||||||
|
|
||||||
|
When called interactively, prompt for NAME-OR-DESCRIPTION.
|
||||||
|
|
||||||
|
If NAME-OR-DESCRIPTION is nil or the empty string, show all
|
||||||
|
packages."
|
||||||
|
(interactive (list (read-regexp "Filter by name or description (regexp)")))
|
||||||
|
(package--ensure-package-menu-mode)
|
||||||
|
(if (or (not name-or-description) (string-empty-p name-or-description))
|
||||||
|
(package-menu--generate t t)
|
||||||
|
(package-menu--filter-by (lambda (pkg-desc)
|
||||||
|
(or (string-match name-or-description
|
||||||
|
(package-desc-summary pkg-desc))
|
||||||
|
(string-match name-or-description
|
||||||
|
(symbol-name
|
||||||
|
(package-desc-name pkg-desc)))))
|
||||||
|
(format "name-or-desc:%s" name-or-description))))
|
||||||
|
|
||||||
(defun package-menu-filter-by-name (name)
|
(defun package-menu-filter-by-name (name)
|
||||||
"Filter the \"*Packages*\" buffer by NAME regexp.
|
"Filter the \"*Packages*\" buffer by NAME regexp.
|
||||||
Display only packages with name that matches regexp NAME.
|
Display only packages with name that matches regexp NAME.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue