From 7b1e97f0e62e0be5c89708c4aef38c0d462d2291 Mon Sep 17 00:00:00 2001 From: Tino Calancha Date: Wed, 7 Dec 2016 20:47:34 +0900 Subject: [PATCH] ibuffer-decompose-filter: Avoid side effects on error * lisp/ibuf-ext.el (ibuffer-decompose-filter): Update 'ibuffer-filtering-qualifiers' only if there is no error (Bug#24997). * test/lisp/ibuffer-tests.el (ibuffer-test-Bug24997): Update test result as pass. --- lisp/ibuf-ext.el | 36 +++++++++++++++++------------------- test/lisp/ibuffer-tests.el | 1 - 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/lisp/ibuf-ext.el b/lisp/ibuf-ext.el index d1bf5769d8c..cc2942c9119 100644 --- a/lisp/ibuf-ext.el +++ b/lisp/ibuf-ext.el @@ -929,26 +929,24 @@ This means that the topmost filter on the filtering stack, which must be a complex filter like (OR [name: foo] [mode: bar-mode]), will be turned into two separate filters [name: foo] and [mode: bar-mode]." (interactive) - (when (null ibuffer-filtering-qualifiers) + (unless ibuffer-filtering-qualifiers (error "No filters in effect")) - (let ((lim (pop ibuffer-filtering-qualifiers))) - (pcase (car lim) - (`or - (setq ibuffer-filtering-qualifiers (append - (cdr lim) - ibuffer-filtering-qualifiers))) - (`saved - (let ((data (assoc (cdr lim) ibuffer-saved-filters))) - (unless data - (ibuffer-filter-disable) - (error "Unknown saved filter %s" (cdr lim))) - (setq ibuffer-filtering-qualifiers - (append (cdr data) ibuffer-filtering-qualifiers)))) - (`not - (push (cdr lim) - ibuffer-filtering-qualifiers)) - (_ - (error "Filter type %s is not compound" (car lim))))) + (let* ((filters ibuffer-filtering-qualifiers) + (head (cdar filters)) + (tail (cdr filters)) + (value + (pcase (caar filters) + (`or (nconc head tail)) + (`saved + (let ((data (assoc head ibuffer-saved-filters))) + (unless data + (ibuffer-filter-disable) + (error "Unknown saved filter %s" head)) + (append (cadr data) tail))) + (`not (cons head tail)) + (_ + (error "Filter type %s is not compound" (caar filters)))))) + (setq ibuffer-filtering-qualifiers value)) (ibuffer-update nil t)) ;;;###autoload diff --git a/test/lisp/ibuffer-tests.el b/test/lisp/ibuffer-tests.el index da8c7024463..799f3fbbdc7 100644 --- a/test/lisp/ibuffer-tests.el +++ b/test/lisp/ibuffer-tests.el @@ -34,7 +34,6 @@ (ert-deftest ibuffer-test-Bug24997 () "Test for http://debbugs.gnu.org/24997 ." - :expected-result :failed (ibuffer) (let ((orig ibuffer-filtering-qualifiers)) (unwind-protect -- 2.39.2