Function: treesit--intersect-ranges

treesit--intersect-ranges is a byte-compiled function defined in treesit.el.gz.

Signature

(treesit--intersect-ranges RANGES-1 RANGES-2)

Documentation

Return the intersection of RANGES-1 and RANGES-2.

Source Code

;; Defined in /usr/src/emacs/lisp/treesit.el.gz
(defun treesit--intersect-ranges (ranges-1 ranges-2)
  "Return the intersection of RANGES-1 and RANGES-2."
  (let ((r1 (pop ranges-1))
        (r2 (pop ranges-2))
        result)
    (while (and r1 r2)
      (let ((start (max (car r1) (car r2)))
            (end (min (cdr r1) (cdr r2))))
        (when (< start end)
          (push (cons start end) result))
        (if (< (cdr r1) (cdr r2))
            (setq r1 (pop ranges-1))
          (setq r2 (pop ranges-2)))))
    (nreverse result)))