[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 0fdd37c7fb 2/2: Make `/ a' in *Package* filter by name
From: |
Lars Ingebrigtsen |
Subject: |
master 0fdd37c7fb 2/2: Make `/ a' in *Package* filter by name |
Date: |
Mon, 13 Jun 2022 08:20:37 -0400 (EDT) |
branch: master
commit 0fdd37c7fbbd0880e569d41bb5ecb9a40f099b00
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Make `/ a' in *Package* filter by name
* lisp/emacs-lisp/package.el (package-menu-filter-by-archive):
Filter by package name instead of by regexp, so that if the user
types "gnu", they won't get "nongnu", too (bug#55919).
---
etc/NEWS | 3 +++
lisp/emacs-lisp/package.el | 18 ++++++++----------
2 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/etc/NEWS b/etc/NEWS
index 6f00a51a70..5df7713aea 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -151,6 +151,9 @@ of 'user-emacs-directory'.
* Incompatible changes in Emacs 29.1
+---
+** '/ a' in *Packages* now limits by package name(s) instead of regexp.
+
+++
** Setting the goal columns now also affects '<prior>' and '<next>'.
Previously, 'C-x C-n' only affected 'next-line' and 'previous-line',
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index 48551f59b4..9aaeb052d0 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -3963,16 +3963,14 @@ packages."
(mapcar #'car package-archives)))
package-menu-mode)
(package--ensure-package-menu-mode)
- (let ((re (if (listp archive)
- (regexp-opt archive)
- archive)))
- (package-menu--filter-by (lambda (pkg-desc)
- (let ((pkg-archive (package-desc-archive pkg-desc)))
- (and pkg-archive
- (string-match-p re pkg-archive))))
- (concat "archive:" (if (listp archive)
- (string-join archive ",")
- archive)))))
+ (let ((archives (ensure-list archive)))
+ (package-menu--filter-by
+ (lambda (pkg-desc)
+ (let ((pkg-archive (package-desc-archive pkg-desc)))
+ (or (null archives)
+ (and pkg-archive
+ (member pkg-archive archives)))))
+ (concat "archive:" (string-join archives ",")))))
(defun package-menu-filter-by-description (description)
"Filter the \"*Packages*\" buffer by DESCRIPTION regexp.