]> git.eshelyaron.com Git - emacs.git/commitdiff
define-ibuffer-filter: Discard wrong filters
authorTino Calancha <tino.calancha@gmail.com>
Wed, 7 Dec 2016 13:02:54 +0000 (22:02 +0900)
committerTino Calancha <tino.calancha@gmail.com>
Wed, 7 Dec 2016 13:02:54 +0000 (22:02 +0900)
* 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
test/lisp/ibuffer-tests.el

index 27e7af9559c2a07f2f2a22c81448334aa0e25a54..3c95f4c44ce23a45445046054835cbb54f44663a 100644 (file)
@@ -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)))
 
index 9fdaaf0e097fda029c02e619dc518da05f204afb..92ed101e6bff29252e08b4703a2bc23260488dc5 100644 (file)
         (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