Function: --splice
--splice is a macro defined in dash.el.
Signature
(--splice PRED FORM LIST)
Documentation
Splice lists generated by FORM in place of items satisfying PRED in LIST.
Evaluate PRED for each element of LIST in turn bound to it.
Whenever the result of PRED is nil, leave that it is-is.
Otherwise, evaluate FORM with the same it binding still in
place. The result should be a (possibly empty) list of items to
splice in place of it in LIST.
This can be useful as an alternative to the ,@ construct in a
``' structure, in case you need to splice several lists at
marked positions (for example with keywords).
This is the anaphoric counterpart to -splice.
Source Code
;; Defined in ~/.emacs.d/elpa/dash-20260221.1346/dash.el
(defmacro --splice (pred form list)
"Splice lists generated by FORM in place of items satisfying PRED in LIST.
Evaluate PRED for each element of LIST in turn bound to `it'.
Whenever the result of PRED is nil, leave that `it' is-is.
Otherwise, evaluate FORM with the same `it' binding still in
place. The result should be a (possibly empty) list of items to
splice in place of `it' in LIST.
This can be useful as an alternative to the `,@' construct in a
`\\=`' structure, in case you need to splice several lists at
marked positions (for example with keywords).
This is the anaphoric counterpart to `-splice'."
(declare (debug (form form form)))
(let ((r (make-symbol "result")))
`(let (,r)
(--each ,list
(if ,pred
(--each ,form (push it ,r))
(push it ,r)))
(nreverse ,r))))