Function: tuareg--interactive-error-range

tuareg--interactive-error-range is a natively compiled function defined in tuareg.el.

Signature

(tuareg--interactive-error-range BASE-POS TEXT-BUFFER)

Documentation

Decode range in tuareg-interactive-error-range-regexp match.

BASE-POS is the start, in TEXT-BUFFER, of the text to which the matched error refers. Return (BEG-POS . END-POS).

Source Code

;; Defined in /nix/store/6mbh851dhnag8f92qfrlh9ckldzwf6c6-emacs-packages-deps/share/emacs/site-lisp/elpa/tuareg-20260626.936/tuareg.el
(defun tuareg--interactive-error-range (base-pos text-buffer)
  "Decode range in `tuareg-interactive-error-range-regexp' match.
BASE-POS is the start, in TEXT-BUFFER, of the text to
which the matched error refers. Return (BEG-POS . END-POS)."
  (let* ((match-num (lambda (group)
                      (and (match-beginning group)
                           (string-to-number (match-string group)))))
         (beg-line (funcall match-num 1))
         (end-line (funcall match-num 2))
         (beg-char (funcall match-num 3))
         (end-char (funcall match-num 4)))
    (with-current-buffer text-buffer
      (save-excursion
        (goto-char base-pos)
        (when (and beg-line (> beg-line 1))
          (forward-line (1- beg-line)))
        (forward-char beg-char)
        (let ((beg-pos (point)))
          (if end-line
              (progn
                (forward-line (- end-line beg-line))
                (forward-char end-char))
            (forward-char (- end-char beg-char)))
          (let ((end-pos (point)))
            (cons beg-pos end-pos)))))))