* bug#37416: [PATCH] Improve package-menu-filter by sorting
@ 2019-09-16 0:53 Stefan Kangas
2019-09-20 17:56 ` Lars Ingebrigtsen
0 siblings, 1 reply; 3+ messages in thread
From: Stefan Kangas @ 2019-09-16 0:53 UTC (permalink / raw)
To: 37416
[-- Attachment #1: Type: text/plain, Size: 244 bytes --]
When I say M-x list-packages and then f, I get to filter the package
list by keyword. However, the list of completions is filled with
duplicates, and also not sorted. The attached patch fixes that.
Any comments?
Best regards,
Stefan Kangas
[-- Attachment #2: 0001-Improve-package-menu-filter-by-sorting.patch --]
[-- Type: text/x-patch, Size: 2160 bytes --]
From a919e2bae7ce2303fea620656120a2f1996fe382 Mon Sep 17 00:00:00 2001
From: Stefan Kangas <stefankangas@gmail.com>
Date: Mon, 16 Sep 2019 02:41:40 +0200
Subject: [PATCH] Improve package-menu-filter by sorting
* lisp/emacs-lisp/package.el (package-menu-filter): Sort keywords
alphabetically for completion.
(package-all-keywords): Remove duplicate keywords.
---
lisp/emacs-lisp/package.el | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index 18b5c962f6..f67b55dc61 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -2938,11 +2938,19 @@ package-menu--refresh
(mapcar #'package-menu--print-info-simple info-list))))
(defun package-all-keywords ()
- "Collect all package keywords."
- (let ((key-list))
+ "Return a list of all known package keywords.
+This takes into account all packages from all archives, even if
+they have not been installed."
+ ;; This would be easier with e.g. `seq-uniq', but it's a bit slow to
+ ;; first create the list and then filter it. This seen hash version
+ ;; gives better performance on my machine by a factor of 6.
+ (let ((key-list)
+ (seen (make-hash-table :test 'equal)))
(package--mapc (lambda (desc)
- (setq key-list (append (package-desc--keywords desc)
- key-list))))
+ (dolist (key (package-desc--keywords desc))
+ (when (not (gethash key seen))
+ (puthash key t seen)
+ (push key key-list)))))
key-list))
(defun package--mapc (function &optional packages)
@@ -3642,7 +3650,8 @@ package-menu-filter
To restore the full package list, type `q'."
(interactive
(list (completing-read-multiple
- "Keywords (comma separated): " (package-all-keywords))))
+ "Keywords (comma separated): "
+ (sort (package-all-keywords) 'string-lessp))))
(package-show-package-list t (if (stringp keyword)
(list keyword)
keyword)))
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* bug#37416: [PATCH] Improve package-menu-filter by sorting
2019-09-16 0:53 bug#37416: [PATCH] Improve package-menu-filter by sorting Stefan Kangas
@ 2019-09-20 17:56 ` Lars Ingebrigtsen
2019-09-20 18:24 ` Stefan Kangas
0 siblings, 1 reply; 3+ messages in thread
From: Lars Ingebrigtsen @ 2019-09-20 17:56 UTC (permalink / raw)
To: Stefan Kangas; +Cc: 37416
Stefan Kangas <stefan@marxist.se> writes:
> When I say M-x list-packages and then f, I get to filter the package
> list by keyword. However, the list of completions is filled with
> duplicates, and also not sorted. The attached patch fixes that.
When I try `f' in that buffer, I get the completions sorted, and I can't
see any duplicates.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#37416: [PATCH] Improve package-menu-filter by sorting
2019-09-20 17:56 ` Lars Ingebrigtsen
@ 2019-09-20 18:24 ` Stefan Kangas
0 siblings, 0 replies; 3+ messages in thread
From: Stefan Kangas @ 2019-09-20 18:24 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: 37416
tags 37416 unreproducible
close 37416
thanks
Lars Ingebrigtsen <larsi@gnus.org> writes:
> When I try `f' in that buffer, I get the completions sorted, and I can't
> see any duplicates.
You are correct, this turned out to be a bug in a package I'm using.
Will file a bug report with that package. Thanks for taking a look,
and sorry about the noise.
Best regards,
Stefan Kangas
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-09-20 18:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-09-16 0:53 bug#37416: [PATCH] Improve package-menu-filter by sorting Stefan Kangas
2019-09-20 17:56 ` Lars Ingebrigtsen
2019-09-20 18:24 ` Stefan Kangas
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.