Function: majutsu-diff--color-words--span-stream-offset

majutsu-diff--color-words--span-stream-offset is a natively compiled function defined in majutsu-diff.el.

Signature

(majutsu-diff--color-words--span-stream-offset POS SPANS)

Documentation

Return POS offset in SPANS stream.

Counts only SPANS before POS. If POS is inside a span, include the partial offset. Return nil when SPANS is nil.

Source Code

;; Defined in /nix/store/jagqw3nms546pad0gxi5f3wsckk6pji7-emacs-packages-deps/share/emacs/site-lisp/majutsu-diff.el
(defun majutsu-diff--color-words--span-stream-offset (pos spans)
  "Return POS offset in SPANS stream.
Counts only SPANS before POS.  If POS is inside a span, include the
partial offset.  Return nil when SPANS is nil."
  (when spans
    (let ((offset 0))
      (cl-block nil
        (dolist (span spans)
          (let ((s (car span))
                (e (cdr span)))
            (cond
             ((<= pos s)
              (cl-return offset))
             ((< pos e)
              (setq offset (+ offset (- pos s)))
              (cl-return offset))
             (t
              (setq offset (+ offset (- e s)))))))
        offset))))