From: Tino Calancha Date: Wed, 7 Dec 2016 13:02:54 +0000 (+0900) Subject: define-ibuffer-filter: Discard wrong filters X-Git-Tag: emacs-26.0.90~1184 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=e41e89d128764c5a2205665ab70b3449c3014abf;p=emacs.git 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. --- 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