Commit b7a015f5 authored by Artur Malabarba's avatar Artur Malabarba

* 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.
parent fad6b8a0
......@@ -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.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment