summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/package.el48
1 files changed, 44 insertions, 4 deletions
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index d6a3832016d..4dafe17aced 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -2554,10 +2554,11 @@ Installed obsolete packages are always displayed.")
(interactive)
(unless (derived-mode-p 'package-menu-mode)
(user-error "The current buffer is not a Package Menu"))
- (message "%s available-obsolete packages" (if package-menu--hide-obsolete
- "Hiding" "Displaying"))
(setq package-menu--hide-packages
(not package-menu--hide-packages))
+ (message "%s packages" (if package-menu--hide-packages
+ "Hiding obsolete or unwanted"
+ "Displaying all"))
(revert-buffer nil 'no-confirm))
(defun package--remove-hidden (pkg-list)
@@ -2600,13 +2601,23 @@ to their archives."
ins-version))
filtered-by-priority))))))))
+(defcustom package-hidden-regexps nil
+ "List of regexps matching the name of packages to hide.
+If the name of a package matches any of these regexps it is
+omited from the package menu. To toggle this, type \\[package-menu-toggle-hiding].
+
+Values can be interactively added to this list by typing
+\\[package-menu-hide-package] on a package"
+ :type '(repeat (regexp :tag "Hide packages with name matching")))
+
(defun package-menu--refresh (&optional packages keywords)
"Re-populate the `tabulated-list-entries'.
PACKAGES should be nil or t, which means to display all known packages.
KEYWORDS should be nil or a list of keywords."
;; Construct list of (PKG-DESC . STATUS).
(unless packages (setq packages t))
- (let (info-list)
+ (let ((hidden-names (mapconcat #'identity package-hidden-regexps "\\|"))
+ info-list)
;; Installed packages:
(dolist (elt package-alist)
(let ((name (car elt)))
@@ -2629,7 +2640,13 @@ KEYWORDS should be nil or a list of keywords."
;; Available and disabled packages:
(dolist (elt package-archive-contents)
(let ((name (car elt)))
- (when (or (eq packages t) (memq name packages))
+ ;; To be displayed it must be in PACKAGES;
+ (when (and (or (eq packages t) (memq name packages))
+ ;; and we must either not be hiding anything,
+ (or (not package-menu--hide-packages)
+ (not package-hidden-regexps)
+ ;; or just not hiding this specific package.
+ (not (string-match hidden-names (symbol-name name)))))
;; Hide available-obsolete or low-priority packages.
(dolist (pkg (package--remove-hidden (cdr elt)))
(when (package--has-keyword-p pkg keywords)
@@ -2770,6 +2787,29 @@ This fetches the contents of each archive specified in
(setq package-menu--new-package-list nil)
(package-refresh-contents package-menu-async))
+(defun package-menu-hide-package ()
+ "Hide a package under point.
+If optional arg BUTTON is non-nil, describe its associated package."
+ (interactive)
+ (declare (interactive-only "change `package-hidden-regexps' instead."))
+ (let* ((name (when (derived-mode-p 'package-menu-mode)
+ (concat "\\`" (regexp-quote (symbol-name (package-desc-name
+ (tabulated-list-get-id)))))))
+ (re (read-string "Hide packages matching regexp: " name)))
+ ;; Test if it is valid.
+ (string-match re "")
+ (push re package-hidden-regexps)
+ (customize-save-variable 'package-hidden-regexps package-hidden-regexps)
+ (package-menu--post-refresh)
+ (let ((hidden
+ (cl-remove-if-not (lambda (e) (string-match re (symbol-name (car e))))
+ package-archive-contents)))
+ (message (substitute-command-keys
+ (concat "Hiding %s packages, type `\\[package-menu-toggle-hiding]'"
+ " to toggle or `\\[customize-variable] RET package-hidden-regexps'"
+ " to customize it"))
+ (length hidden)))))
+
(defun package-menu-describe-package (&optional button)
"Describe the current package.
If optional arg BUTTON is non-nil, describe its associated package."