Function: tuareg--electric-indent-predicate

tuareg--electric-indent-predicate is a natively compiled function defined in tuareg.el.

Signature

(tuareg--electric-indent-predicate CHAR)

Documentation

Check whether we should auto-indent.

For use on electric-indent-functions.

Source Code

;; Defined in /nix/store/6mbh851dhnag8f92qfrlh9ckldzwf6c6-emacs-packages-deps/share/emacs/site-lisp/elpa/tuareg-20260626.936/tuareg.el
(defun tuareg--electric-indent-predicate (char)
  "Check whether we should auto-indent.
For use on `electric-indent-functions'."
  (save-excursion
    (tuareg-backward-char);; Go before the inserted char.
    (let ((syntax (char-syntax char)))
      (if (tuareg-in-indentation-p)
          (or (eq char ?|) (eq syntax ?\)))
        (or (pcase char
              (`?\) (char-equal ?* (preceding-char)))
              (`?\} (and (char-equal ?> (preceding-char))
                         (progn (tuareg-backward-char)
                                (tuareg-in-indentation-p))))
              (`?\] (and (char-equal ?| (preceding-char))
                         (progn (tuareg-backward-char)
                                (tuareg-in-indentation-p)))))
            (and tuareg-electric-indent
                 (not (eq syntax ?w))
                 (let ((end (point)))
                   (skip-syntax-backward "w_")
                   (member (buffer-substring (point) end)
                           tuareg-electric-indent-keywords))
                 (tuareg-in-indentation-p)))))))