Function: tuareg--pattern-pre-form-let

tuareg--pattern-pre-form-let is a natively compiled function defined in tuareg.el.

Signature

(tuareg--pattern-pre-form-let)

Documentation

Return the position of "=" marking the end of "let".

Source Code

;; Defined in /nix/store/6mbh851dhnag8f92qfrlh9ckldzwf6c6-emacs-packages-deps/share/emacs/site-lisp/elpa/tuareg-20260626.936/tuareg.el
(defun tuareg--pattern-pre-form-let ()
  "Return the position of \"=\" marking the end of \"let\"."
  (if (or (tuareg--font-lock-in-string-or-comment)
          (looking-at "[ \t\n]*open\\_>")       ; "let open"
          (looking-at "[ \t\n]*exception\\_>")) ; "let exception"
      (progn ; bail out
        (setq tuareg--pattern-matcher-limit (point))
        (setq tuareg--pattern-matcher-type-limit (point)))

    (let* ((opoint (point))
           (limit (+ opoint 800))
           pos)
      (setq tuareg--pattern-matcher-limit nil)
      (while (and
              (<= (point) limit)
              (setq pos (re-search-forward "[=({:]" limit t))
              (progn
                (backward-char)
                (cond
                 ((memq (char-after) '(?\( ?\{))
                  ;; Skip balanced braces
                  (if (ignore-errors (forward-list))
                      t
                    (goto-char (1- pos))
                    nil)) ; If braces are not balanced, stop.
                 ((char-equal ?: (char-after))
                  ;; Make sure it is not a label
                  (skip-chars-backward "[:alpha:]0-9_'")
                  (if (not (memq (char-before) '(?~ ??)))
                      (setq tuareg--pattern-matcher-limit (1- pos)))
                  (goto-char pos)
                  t)
                 (t nil)))))
      (setq tuareg--pattern-matcher-type-limit (1+ (point))); include "="
      (unless tuareg--pattern-matcher-limit
        (setq tuareg--pattern-matcher-limit (point)))
      ;; Remove any possible highlighting on "="
      (unless (eobp)
        (put-text-property (point) (1+ (point)) 'face nil))
      ;; move the point back for the sub-matcher
      (goto-char opoint))
    (put-text-property (point) tuareg--pattern-matcher-limit
                       'font-lock-multiline t)
    tuareg--pattern-matcher-limit))