Function: tuareg--pattern-vars-matcher

tuareg--pattern-vars-matcher is a natively compiled function defined in tuareg.el.

Signature

(tuareg--pattern-vars-matcher LIMIT)

Documentation

Match a variable name after the point.

If it succeeds, it moves the point after the variable name and set match-data. See e.g., font-lock-keywords.

Source Code

;; Defined in /nix/store/6mbh851dhnag8f92qfrlh9ckldzwf6c6-emacs-packages-deps/share/emacs/site-lisp/elpa/tuareg-20260626.936/tuareg.el
(defun tuareg--pattern-vars-matcher (_limit)
  "Match a variable name after the point.
If it succeeds, it moves the point after the variable name and set
`match-data'.  See e.g., `font-lock-keywords'."
  (when (and (<= (point) tuareg--pattern-matcher-limit)
             (re-search-forward tuareg--lid-re tuareg--pattern-matcher-limit t))
    (skip-chars-forward " \t\n")
    (if (>= (point) tuareg--pattern-matcher-limit)
        t
      (cond
       ((char-equal ?= (char-after))
        ;; Remove possible fontification of "=" (e.g. as an operator)
        (put-text-property (point) (1+ (point)) 'face nil)
        ;; Decide whether it is ?(v =...) or {x = v; x = v}
        (goto-char (match-beginning 0))
        (skip-chars-backward " \t\n")
        (if (char-equal (char-before) ?\() ; (var = expr)
            (progn (up-list) ; keep match, skip expr
                   t)
          ;; This is a label record, variable after
          (goto-char (match-end 0))
          (re-search-forward tuareg--lid-re tuareg--pattern-matcher-limit t)))
       ((char-equal ?: (char-after))
        (let ((beg-ty (1+ (point))))
          (goto-char (match-beginning 0))
          (skip-chars-backward " \t\n")
          (if (char-equal (char-before) ?\() ; (var : t)
              (progn
                (up-list) ; keep match, skip type
                (put-text-property beg-ty (1- (point)) 'face
                                   'font-lock-type-face)
                t)
            (goto-char (match-end 0)))))
       (t t)))))