[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master b7a015f 2/2: * lisp/emacs-lisp/package.el: Filter b
From: |
Artur Malabarba |
Subject: |
[Emacs-diffs] master b7a015f 2/2: * lisp/emacs-lisp/package.el: Filter by multiple keywords and cache keywords |
Date: |
Mon, 20 Apr 2015 19:49:34 +0000 |
branch: master
commit b7a015f5e02281cc8500154ebe4339a18587b415
Author: Artur Malabarba <address@hidden>
Commit: Artur Malabarba <address@hidden>
* lisp/emacs-lisp/package.el: Filter by multiple keywords and cache keywords
(package-menu-filter): Accept a list of keywords.
(package--all-keywords): New variable to cache known keywords.
(package-all-keywords): Populate it if necessary.
(package-refresh-contents): Reset it.
---
lisp/emacs-lisp/package.el | 25 +++++++++++++++++++------
1 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index 4590582..c69e15b 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -1343,6 +1343,11 @@ it to the file."
(defvar package--downloads-in-progress nil
"List of in-progress asynchronous downloads.")
+(defvar package--all-keywords nil
+ "List of known keywords.
+Generated by `package-all-keywords'. Reset to nil whenever the
+package archives are retrieved.")
+
(declare-function epg-check-configuration "epg-config"
(config &optional minimum-version))
(declare-function epg-configuration "epg-config" ())
@@ -1458,9 +1463,9 @@ and make them available for download.
Optional argument ASYNC specifies whether to perform the
downloads in the background."
(interactive)
- ;; FIXME: Do it asynchronously.
(unless (file-exists-p package-user-dir)
(make-directory package-user-dir t))
+ (setq package--all-keywords nil)
(let ((default-keyring (expand-file-name "package-keyring.gpg"
data-directory))
(package--silence async))
@@ -2492,11 +2497,11 @@ KEYWORDS should be nil or a list of keywords."
(defun package-all-keywords ()
"Collect all package keywords"
- (let (keywords)
+ (unless package--all-keywords
(package--mapc (lambda (desc)
(let* ((desc-keywords (and desc (package-desc--keywords
desc))))
- (setq keywords (append keywords desc-keywords)))))
- keywords))
+ (setq package--all-keywords (append desc-keywords
package--all-keywords))))))
+ package--all-keywords)
(defun package--mapc (function &optional packages)
"Call FUNCTION for all known PACKAGES.
@@ -3005,9 +3010,17 @@ shown."
(defun package-menu-filter (keyword)
"Filter the *Packages* buffer.
Show only those items that relate to the specified KEYWORD.
+KEYWORD can be a string or a list of strings. If it is a list, a
+package will be displayed if it matches any of the keywords.
+Interactively, it is a list of strings separated by commas.
+
To restore the full package list, type `q'."
- (interactive (list (completing-read "Keyword: " (package-all-keywords))))
- (package-show-package-list t (list keyword)))
+ (interactive
+ (list (completing-read-multiple
+ "Keywords (comma separated): " (package-all-keywords))))
+ (package-show-package-list t (if (stringp keyword)
+ (list keyword)
+ keyword)))
(defun package-list-packages-no-fetch ()
"Display a list of packages.