Subject: bug#28826: closed (Re: bug#28826: 27.0.50; Ibuffer filters should be idempotent)

From: [email-masked] (GNU bug Tracking System)
Date: Fri, 20 Oct 2017 13:16:02 +0000

Your bug report

#28826: 27.0.50; Ibuffer filters should be idempotent

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
28826: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=28826
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#28826: 27.0.50; Ibuffer filters should be idempotent
From: Tino Calancha <[email-masked]>
To: [email-masked]
Date: Fri, 20 Oct 2017 22:14:59 +0900
List-Id: <debbugs-submit.debbugs.gnu.org>

Tino Calancha <[email-masked]> writes:

> 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]
>
Fixed in master branch as commit "Make ibuffer filters idempotent"

(ee6fe8378a28444cb4913abca4af742f736e9b45)

Subject: 27.0.50; Ibuffer filters should be idempotent
From: Tino Calancha <[email-masked]>
To: [email-masked]
Date: Sat, 14 Oct 2017 11:56:39 +0900
List-Id: <debbugs-submit.debbugs.gnu.org>

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 <[email-masked]>
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