Function: treesit--some

treesit--some is a macro defined in treesit.el.gz.

Signature

(treesit--some (SYM VAL) &rest BODY)

Documentation

Evaluate BODY with SYM bounded to each value in VAL.

Return the first non-nil evaluation of BODY.

Source Code

;; Defined in /usr/src/emacs/lisp/treesit.el.gz
(defmacro treesit--some (sym-val &rest body)
  "Evaluate BODY with SYM bounded to each value in VAL.

Return the first non-nil evaluation of BODY.

\(fn (SYM VAL) &rest BODY)"
  (declare (indent 1) (debug ((symbolp form) body)))
  (let ((result-sym (gensym))
        (val-sym (gensym))
        (sym (car sym-val))
        (val (cadr sym-val)))
    `(let ((,val-sym ,val)
           (,sym nil)
           (,result-sym nil))
       (while (and (null ,result-sym)
                   (setq ,sym (pop ,val-sym)))
         (setq ,result-sym
               ,@body))
       ,result-sym)))