Function: evil-filter-list

evil-filter-list is a byte-compiled function defined in evil-common.el.

Signature

(evil-filter-list PREDICATE LIST &optional POINTER)

Documentation

Delete by side-effect all items satisfying PREDICATE in LIST.

Stop when reaching POINTER. If the first item satisfies PREDICATE, there is no way to remove it by side-effect; therefore, write
(setq foo (evil-filter-list #'predicate foo)) to be sure of
changing the value of foo.

Source Code

;; Defined in ~/.emacs.d/elpa/evil-20251108.138/evil-common.el
;; custom version of `delete-if'
(defun evil-filter-list (predicate list &optional pointer)
  "Delete by side-effect all items satisfying PREDICATE in LIST.
Stop when reaching POINTER.  If the first item satisfies PREDICATE,
there is no way to remove it by side-effect; therefore, write
\(setq foo (evil-filter-list #\\='predicate foo)) to be sure of
changing the value of `foo'."
  (let ((tail list) elt head)
    (while (and tail (not (eq tail pointer)))
      (setq elt (car tail))
      (cond
       ((funcall predicate elt)
        (setq tail (cdr tail))
        (if head
            (setcdr head tail)
          (setq list tail)))
       (t
        (setq head tail
              tail (cdr tail)))))
    list))