From: Tino Calancha <tino.calancha@gmail.com>
To: 28826@debbugs.gnu.org
Subject: bug#28826: 27.0.50; Ibuffer filters should be idempotent
Date: Sat, 14 Oct 2017 11:56:39 +0900 [thread overview]
Message-ID: <87mv4u4eu0.fsf@gmail.com> (raw)
emacs -Q
M-x ibuffer RET
/n s RET
/n s RET ; again
;; ibuffer-filtering-qualifiers contains twice the filter
;; You can read on top:
;; Ibuffer by recency [buffer name: s] [buffer name: s]
--8<-----------------------------cut here---------------start------------->8---
commit d65a5a22981dccc69a6e26cde1e567d109e884b3
Author: Tino Calancha <tino.calancha@gmail.com>
Date: Sat Oct 14 11:30:32 2017 +0900
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.
diff --git a/lisp/ibuf-ext.el b/lisp/ibuf-ext.el
index 686bc392b6..097a7b3b43 100644
--- a/lisp/ibuf-ext.el
+++ b/lisp/ibuf-ext.el
@@ -1034,7 +1034,8 @@ ibuffer-pop-filter
(defun ibuffer-push-filter (filter-specification)
"Add FILTER-SPECIFICATION to `ibuffer-filtering-qualifiers'."
- (push filter-specification ibuffer-filtering-qualifiers))
+ (unless (member filter-specification ibuffer-filtering-qualifiers)
+ (push filter-specification ibuffer-filtering-qualifiers)))
;;;###autoload
(defun ibuffer-decompose-filter ()
diff --git a/lisp/ibuf-macs.el b/lisp/ibuf-macs.el
index e0c91e20ed..c30067f2f5 100644
--- a/lisp/ibuf-macs.el
+++ b/lisp/ibuf-macs.el
@@ -301,12 +301,16 @@ ibuffer-save-marks
(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
--8<-----------------------------cut here---------------end--------------->8---
In GNU Emacs 27.0.50 (build 16, x86_64-pc-linux-gnu, GTK+ Version 3.22.11)
of 2017-10-14
Repository revision: 78479a3984047a8153b43571e6b5ebfb674223a4
next reply other threads:[~2017-10-14 2:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-14 2:56 Tino Calancha [this message]
2017-10-20 13:14 ` bug#28826: 27.0.50; Ibuffer filters should be idempotent Tino Calancha
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87mv4u4eu0.fsf@gmail.com \
--to=tino.calancha@gmail.com \
--cc=28826@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.