aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtur Malabarba2015-04-20 07:35:07 +0100
committerArtur Malabarba2015-04-20 20:47:18 +0100
commitb7a015f5e02281cc8500154ebe4339a18587b415 (patch)
tree6054ef37feb9f24e98bb78da01cf0297518b2b59
parentfad6b8a093c14bcf3f699878de501a1a7467cf4c (diff)
downloademacs-b7a015f5e02281cc8500154ebe4339a18587b415.tar.gz
emacs-b7a015f5e02281cc8500154ebe4339a18587b415.zip
* 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.
-rw-r--r--lisp/emacs-lisp/package.el25
1 files changed, 19 insertions, 6 deletions
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index 4590582575f..c69e15bc005 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -1343,6 +1343,11 @@ it to the file."
1343(defvar package--downloads-in-progress nil 1343(defvar package--downloads-in-progress nil
1344 "List of in-progress asynchronous downloads.") 1344 "List of in-progress asynchronous downloads.")
1345 1345
1346(defvar package--all-keywords nil
1347 "List of known keywords.
1348Generated by `package-all-keywords'. Reset to nil whenever the
1349package archives are retrieved.")
1350
1346(declare-function epg-check-configuration "epg-config" 1351(declare-function epg-check-configuration "epg-config"
1347 (config &optional minimum-version)) 1352 (config &optional minimum-version))
1348(declare-function epg-configuration "epg-config" ()) 1353(declare-function epg-configuration "epg-config" ())
@@ -1458,9 +1463,9 @@ and make them available for download.
1458Optional argument ASYNC specifies whether to perform the 1463Optional argument ASYNC specifies whether to perform the
1459downloads in the background." 1464downloads in the background."
1460 (interactive) 1465 (interactive)
1461 ;; FIXME: Do it asynchronously.
1462 (unless (file-exists-p package-user-dir) 1466 (unless (file-exists-p package-user-dir)
1463 (make-directory package-user-dir t)) 1467 (make-directory package-user-dir t))
1468 (setq package--all-keywords nil)
1464 (let ((default-keyring (expand-file-name "package-keyring.gpg" 1469 (let ((default-keyring (expand-file-name "package-keyring.gpg"
1465 data-directory)) 1470 data-directory))
1466 (package--silence async)) 1471 (package--silence async))
@@ -2492,11 +2497,11 @@ KEYWORDS should be nil or a list of keywords."
2492 2497
2493(defun package-all-keywords () 2498(defun package-all-keywords ()
2494 "Collect all package keywords" 2499 "Collect all package keywords"
2495 (let (keywords) 2500 (unless package--all-keywords
2496 (package--mapc (lambda (desc) 2501 (package--mapc (lambda (desc)
2497 (let* ((desc-keywords (and desc (package-desc--keywords desc)))) 2502 (let* ((desc-keywords (and desc (package-desc--keywords desc))))
2498 (setq keywords (append keywords desc-keywords))))) 2503 (setq package--all-keywords (append desc-keywords package--all-keywords))))))
2499 keywords)) 2504 package--all-keywords)
2500 2505
2501(defun package--mapc (function &optional packages) 2506(defun package--mapc (function &optional packages)
2502 "Call FUNCTION for all known PACKAGES. 2507 "Call FUNCTION for all known PACKAGES.
@@ -3005,9 +3010,17 @@ shown."
3005(defun package-menu-filter (keyword) 3010(defun package-menu-filter (keyword)
3006 "Filter the *Packages* buffer. 3011 "Filter the *Packages* buffer.
3007Show only those items that relate to the specified KEYWORD. 3012Show only those items that relate to the specified KEYWORD.
3013KEYWORD can be a string or a list of strings. If it is a list, a
3014package will be displayed if it matches any of the keywords.
3015Interactively, it is a list of strings separated by commas.
3016
3008To restore the full package list, type `q'." 3017To restore the full package list, type `q'."
3009 (interactive (list (completing-read "Keyword: " (package-all-keywords)))) 3018 (interactive
3010 (package-show-package-list t (list keyword))) 3019 (list (completing-read-multiple
3020 "Keywords (comma separated): " (package-all-keywords))))
3021 (package-show-package-list t (if (stringp keyword)
3022 (list keyword)
3023 keyword)))
3011 3024
3012(defun package-list-packages-no-fetch () 3025(defun package-list-packages-no-fetch ()
3013 "Display a list of packages. 3026 "Display a list of packages.