Subject: bug#25042: closed (Re: bug#25042: 26.0.50; ibuffer-filter-by-predicate: A wrong filter keeps enabled)

From: [email-masked] (GNU bug Tracking System)
Date: Wed, 07 Dec 2016 13:09:02 +0000

Your bug report

#25042: 26.0.50; ibuffer-filter-by-predicate: A wrong filter keeps enabled

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].

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

Subject: Re: bug#25042: 26.0.50; ibuffer-filter-by-predicate: A wrong filter keeps enabled
From: Tino Calancha <[email-masked]>
To: [email-masked]
Date: Wed, 07 Dec 2016 22:08:43 +0900
List-Id: <debbugs-submit.debbugs.gnu.org>

Tino Calancha <[email-masked]> writes:

> emacs -Q
> M-x: ibuffer RET
> /e (match-string "sc" (buffer-name))
> ;; Mistyped `match-string' instead of `string-match'.
> M-: ibuffer-filtering-qualifiers RET
> => ((predicate match-string "sc" (buffer-name)))
>
> The filter is wrong but it keeps enabled; calling
> `ibuffer-update' would signal an error:
> Wrong type argument: integerp, "sc"
Pushed fix to master branch as commit e41e89d.

Subject: 26.0.50; ibuffer-filter-by-predicate: A wrong filter keeps enabled
From: Tino Calancha <[email-masked]>
To: [email-masked]
Cc: [email-masked]
Date: Sun, 27 Nov 2016 22:34:58 +0900
List-Id: <debbugs-submit.debbugs.gnu.org>

emacs -Q
M-x: ibuffer RET
/e (match-string "sc" (buffer-name))
;; Mistyped `match-string' instead of `string-match'.
M-: ibuffer-filtering-qualifiers RET
=> ((predicate match-string "sc" (buffer-name)))

The filter is wrong but it keeps enabled; calling
`ibuffer-update' would signal an error:
Wrong type argument: integerp, "sc"

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>From 3188bd56128aa36035a4ebca391182cf7faba713 Mon Sep 17 00:00:00 2001
From: Tino Calancha <[email-masked]>
Date: Sun, 27 Nov 2016 22:32:34 +0900
Subject: [PATCH] define-ibuffer-filter: Discard wrong filters

* lisp/ibuf-macs.el (define-ibuffer-filter): Do not store
in 'ibuffer-filtering-qualifiers' a wrong filter (Bug#25042).
* test/lisp/ibuffer-tests.el (ibuffer-test-Bug25042): Add test.
---
 lisp/ibuf-macs.el          | 9 +++++++--
 test/lisp/ibuffer-tests.el | 7 +++++++
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/lisp/ibuf-macs.el b/lisp/ibuf-macs.el
index 27e7af9..3c95f4c 100644
--- a/lisp/ibuf-macs.el
+++ b/lisp/ibuf-macs.el
@@ -302,8 +302,13 @@ ibuffer-save-marks
 			  qualifier))
 	 (ibuffer-update nil t))
        (push (list ',name ,description
-		   #'(lambda (buf qualifier)
-		       ,@body))
+		   (lambda (buf qualifier)
+                     (condition-case nil
+                         ,@body
+                       (error (ibuffer-pop-filter)
+                              (when (eq ',name 'predicate)
+                                (error "Wrong filter predicate: %S"
+                                       qualifier))))))
 	     ibuffer-filtering-alist)
        :autoload-end)))
 
diff --git a/test/lisp/ibuffer-tests.el b/test/lisp/ibuffer-tests.el
index 3a4def3..8a9ded9 100644
--- a/test/lisp/ibuffer-tests.el
+++ b/test/lisp/ibuffer-tests.el
@@ -66,5 +66,12 @@
       (mapc (lambda (buf) (when (buffer-live-p buf)
                             (kill-buffer buf))) (list buf1 buf2)))))
 
+(ert-deftest ibuffer-test-Bug25042 ()
+  "Test for http://debbugs.gnu.org/25042 ."
+  (ibuffer)
+  (ignore-errors ; Mistyped `match-string' instead of `string-match'.
+    (ibuffer-filter-by-predicate '(match-string "foo" (buffer-name))))
+  (should-not ibuffer-filtering-qualifiers))
+
 (provide 'ibuffer-tests)
 ;; ibuffer-tests.el ends here
-- 
2.10.2

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
In GNU Emacs 26.0.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.22.3)
 of 2016-11-27
Repository revision: 416adda38521c6246f77877c57843264fa4ae711