Function: --remove-first

--remove-first is a macro defined in dash.el.

Signature

(--remove-first FORM LIST)

Documentation

Remove the first item from LIST for which FORM evals to non-nil.

Each element of LIST in turn is bound to it and its index within LIST to it-index before evaluating FORM. This is a non-destructive operation, but only the front of LIST leading up to the removed item is a copy; the rest is LIST's original tail. If no item is removed, then the result is a complete copy. This is the anaphoric counterpart to -remove-first.

Aliases

--reject-first

Source Code

;; Defined in ~/.emacs.d/elpa/dash-20260221.1346/dash.el
(defmacro --remove-first (form list)
  "Remove the first item from LIST for which FORM evals to non-nil.
Each element of LIST in turn is bound to `it' and its index
within LIST to `it-index' before evaluating FORM.  This is a
non-destructive operation, but only the front of LIST leading up
to the removed item is a copy; the rest is LIST's original tail.
If no item is removed, then the result is a complete copy.
This is the anaphoric counterpart to `-remove-first'."
  (declare (debug (form form)))
  (let ((front (make-symbol "front"))
        (tail (make-symbol "tail")))
    `(let ((,tail ,list) ,front)
       (--each-while ,tail (not ,form)
         (push (pop ,tail) ,front))
       (if ,tail
           (nconc (nreverse ,front) (cdr ,tail))
         (nreverse ,front)))))