Function: --keep

--keep is a macro defined in dash.el.

Signature

(--keep FORM LIST)

Documentation

Eval FORM for each item in LIST and return the non-nil results.

Like --filter, but returns the non-nil results of FORM instead of the corresponding elements of LIST. Each element of LIST in turn is bound to it and its index within LIST to it-index before evaluating FORM. This is the anaphoric counterpart to -keep.

Source Code

;; Defined in ~/.emacs.d/elpa/dash-20260221.1346/dash.el
(defmacro --keep (form list)
  "Eval FORM for each item in LIST and return the non-nil results.
Like `--filter', but returns the non-nil results of FORM instead
of the corresponding elements of LIST.  Each element of LIST in
turn is bound to `it' and its index within LIST to `it-index'
before evaluating FORM.
This is the anaphoric counterpart to `-keep'."
  (declare (debug (form form)))
  (let ((r (make-symbol "result"))
        (m (make-symbol "mapped")))
    `(let (,r)
       (--each ,list (let ((,m ,form)) (when ,m (push ,m ,r))))
       (nreverse ,r))))