1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2025-01-05 11:45:45 +00:00

Make ibuffer filters idempotent

* lisp/ibuf-ext.el (ibuffer-push-filter): Check if the
filter is already in effect (Bug#28826).
* lisp/ibuf-macs.el (define-ibuffer-filter):
Report to user if the filter was already enabled.
This commit is contained in:
Tino Calancha 2017-10-20 22:11:39 +09:00
parent 658853aebb
commit ee6fe8378a
2 changed files with 15 additions and 8 deletions

View File

@ -1033,8 +1033,11 @@ group definitions by setting `ibuffer-filter-groups' to nil."
(ibuffer-jump-to-buffer (buffer-name buf)))))
(defun ibuffer-push-filter (filter-specification)
"Add FILTER-SPECIFICATION to `ibuffer-filtering-qualifiers'."
(push filter-specification ibuffer-filtering-qualifiers))
"Add FILTER-SPECIFICATION to `ibuffer-filtering-qualifiers'.
If FILTER-SPECIFICATION is already in the list then return nil. Otherwise,
return the updated list."
(unless (member filter-specification ibuffer-filtering-qualifiers)
(push filter-specification ibuffer-filtering-qualifiers)))
;;;###autoload
(defun ibuffer-decompose-filter ()

View File

@ -301,12 +301,16 @@ bound to the current value of the filter.
(defun ,fn-name (qualifier)
,(or documentation "This filter is not documented.")
(interactive (list ,reader))
(ibuffer-push-filter (cons ',name qualifier))
(message "%s"
(format ,(concat (format "Filter by %s added: " description)
" %s")
qualifier))
(ibuffer-update nil t))
(if (null (ibuffer-push-filter (cons ',name qualifier)))
(message "%s"
(format ,(concat (format "Filter by %s already applied: " description)
" %s")
qualifier))
(message "%s"
(format ,(concat (format "Filter by %s added: " description)
" %s")
qualifier))
(ibuffer-update nil t)))
(push (list ',name ,description
(lambda (buf qualifier)
(condition-case nil