From e41e89d128764c5a2205665ab70b3449c3014abf Mon Sep 17 00:00:00 2001 From: Tino Calancha Date: Wed, 7 Dec 2016 22:02:54 +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 | 12 ++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/lisp/ibuf-macs.el b/lisp/ibuf-macs.el index 27e7af9559c..3c95f4c44ce 100644 --- a/lisp/ibuf-macs.el +++ b/lisp/ibuf-macs.el @@ -302,8 +302,13 @@ bound to the current value of the filter. 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 9fdaaf0e097..92ed101e6bf 100644 --- a/test/lisp/ibuffer-tests.el +++ b/test/lisp/ibuffer-tests.el @@ -126,5 +126,17 @@ (and (buffer-live-p it) (kill-buffer it)))))) +(ert-deftest ibuffer-test-Bug25042 () + "Test for http://debbugs.gnu.org/25042 ." + (ibuffer) + (let ((filters ibuffer-filtering-qualifiers)) + (unwind-protect + (progn + (ignore-errors ; Mistyped `match-string' instead of `string-match'. + (setq ibuffer-filtering-qualifiers nil) + (ibuffer-filter-by-predicate '(match-string "foo" (buffer-name)))) + (should-not ibuffer-filtering-qualifiers)) + (setq ibuffer-filtering-qualifiers filters)))) + (provide 'ibuffer-tests) ;; ibuffer-tests.el ends here -- 2.39.2