unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#25042: 26.0.50; ibuffer-filter-by-predicate: A wrong filter keeps enabled
@ 2016-11-27 13:34 Tino Calancha
  2016-12-07 13:08 ` Tino Calancha
  0 siblings, 1 reply; 2+ messages in thread
From: Tino Calancha @ 2016-11-27 13:34 UTC (permalink / raw)
  To: 25042; +Cc: tino.calancha


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 <tino.calancha@gmail.com>
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





^ permalink raw reply related	[flat|nested] 2+ messages in thread

* bug#25042: 26.0.50; ibuffer-filter-by-predicate: A wrong filter keeps enabled
  2016-11-27 13:34 bug#25042: 26.0.50; ibuffer-filter-by-predicate: A wrong filter keeps enabled Tino Calancha
@ 2016-12-07 13:08 ` Tino Calancha
  0 siblings, 0 replies; 2+ messages in thread
From: Tino Calancha @ 2016-12-07 13:08 UTC (permalink / raw)
  To: 25042-done

Tino Calancha <tino.calancha@gmail.com> 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.





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-12-07 13:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-27 13:34 bug#25042: 26.0.50; ibuffer-filter-by-predicate: A wrong filter keeps enabled Tino Calancha
2016-12-07 13:08 ` Tino Calancha

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).