(require 'subr-x))
;;; Utility functions
-(defun ibuffer-delete-alist (key alist)
- "Delete all entries in ALIST that have a key equal to KEY."
- (let (entry)
- (while (setq entry (assoc key alist))
- (setq alist (delete entry alist)))
- alist))
+(defun ibuffer-remove-alist (key alist)
+ "Remove all entries in ALIST that have a key equal to KEY."
+ (while (ibuffer-awhen (assoc key alist)
+ (setq alist (remove it alist)) it))
+ alist)
;; borrowed from Gnus
(defun ibuffer-remove-duplicates (list)
(let ((buf (ibuffer-current-buffer)))
(if (assq 'mode ibuffer-filtering-qualifiers)
(setq ibuffer-filtering-qualifiers
- (ibuffer-delete-alist 'mode ibuffer-filtering-qualifiers))
+ (ibuffer-remove-alist 'mode ibuffer-filtering-qualifiers))
(ibuffer-push-filter (cons 'mode (buffer-local-value 'major-mode buf)))))
(ibuffer-update nil t))
(append ibuffer-filter-groups
(list (cons "Default" nil))))))
;; (dolist (hidden ibuffer-hidden-filter-groups)
- ;; (setq filter-group-alist (ibuffer-delete-alist
+ ;; (setq filter-group-alist (ibuffer-remove-alist
;; hidden filter-group-alist)))
(let ((vec (make-vector (length filter-group-alist) nil))
(i 0))
(interactive
(list (ibuffer-read-filter-group-name "Decompose filter group: " t)))
(let ((data (cdr (assoc group ibuffer-filter-groups))))
- (setq ibuffer-filter-groups (ibuffer-delete-alist
+ (setq ibuffer-filter-groups (ibuffer-remove-alist
group ibuffer-filter-groups)
ibuffer-filtering-qualifiers data))
(ibuffer-update nil t))
(ibuffer-aif (assoc name ibuffer-filter-groups)
(progn
(push (copy-tree it) ibuffer-filter-group-kill-ring)
- (setq ibuffer-filter-groups (ibuffer-delete-alist
+ (setq ibuffer-filter-groups (ibuffer-remove-alist
name ibuffer-filter-groups))
(setq ibuffer-hidden-filter-groups
(delete name ibuffer-hidden-filter-groups)))
(completing-read "Delete saved filter group: "
ibuffer-saved-filter-groups nil t))))
(setq ibuffer-saved-filter-groups
- (ibuffer-delete-alist name ibuffer-saved-filter-groups))
+ (ibuffer-remove-alist name ibuffer-saved-filter-groups))
(ibuffer-maybe-save-stuff)
(ibuffer-update nil t))
(completing-read "Delete saved filters: "
ibuffer-saved-filters nil t))))
(setq ibuffer-saved-filters
- (ibuffer-delete-alist name ibuffer-saved-filters))
+ (ibuffer-remove-alist name ibuffer-saved-filters))
(ibuffer-maybe-save-stuff)
(ibuffer-update nil t))
(should (equal (cdr (assoc "test2" ibuffer-saved-filters)) test2))
(should (equal (cdr (assoc "test3" ibuffer-saved-filters)) test3))))
+(ert-deftest ibuffer-test-Bug25058 ()
+ "Test for http://debbugs.gnu.org/25058 ."
+ (ibuffer)
+ (let ((orig-filters ibuffer-saved-filter-groups)
+ (tmp-filters '(("saved-filters"
+ ("Shell"
+ (used-mode . shell-mode))
+ ("Elisp"
+ (or
+ (used-mode . emacs-lisp-mode)
+ (used-mode . lisp-interaction-mode)))
+ ("Dired"
+ (used-mode . dired-mode))
+ ("Info"
+ (or
+ (used-mode . help-mode)
+ (used-mode . debugger-mode)
+ (used-mode . Custom-mode)
+ (used-mode . completion-list-mode)
+ (name . "\\`[*]Messages[*]\\'")))))))
+ (unwind-protect
+ (progn
+ (setq ibuffer-saved-filter-groups tmp-filters)
+ (ibuffer-switch-to-saved-filter-groups "saved-filters")
+ (ibuffer-decompose-filter-group "Elisp")
+ (ibuffer-filter-disable)
+ (ibuffer-switch-to-saved-filter-groups "saved-filters")
+ (should (assoc "Elisp" (cdar ibuffer-saved-filter-groups))))
+ (setq ibuffer-saved-filter-groups orig-filters)
+ (ibuffer-awhen (get-buffer "*Ibuffer*")
+ (and (buffer-live-p it) (kill-buffer it))))))
+
+
(provide 'ibuffer-tests)
;; ibuffer-tests.el ends here