Function: tuareg--indent-line-inside-comment

tuareg--indent-line-inside-comment is a natively compiled function defined in tuareg.el.

Signature

(tuareg--indent-line-inside-comment)

Documentation

Indent the current line if it is inside a comment.

Source Code

;; Defined in /nix/store/6mbh851dhnag8f92qfrlh9ckldzwf6c6-emacs-packages-deps/share/emacs/site-lisp/elpa/tuareg-20260626.936/tuareg.el
(defun tuareg--indent-line-inside-comment ()
  "Indent the current line if it is inside a comment."
  (let ((ppss (syntax-ppss)))
    (and (nth 4 ppss)
         (let ((indent-col
                (save-excursion
                  (let* ((com-start (nth 8 ppss))
                         (in-doc-comment
                          (save-excursion
                            (goto-char com-start)
                            (looking-at-p (rx "(**" (not (in "*"))))))
                         tag-starts-line)
                    ;; Use the indentation of the previous nonempty line.
                    ;; If we are in a doc comment and that line
                    ;; starts with an @tag, and the current line
                    ;; doesn't, then indent to after the @tag.
                    (goto-char (max com-start (line-beginning-position)))
                    (setq tag-starts-line
                          (and in-doc-comment
                               (looking-at-p
                                (rx (* (in " \t"))
                                    "@" (+ lower) symbol-end))))
                    (skip-chars-backward " \t\n" com-start)
                    (goto-char (max com-start (line-beginning-position)))
                    (when (looking-at (rx "(*" (* "*")))
                      (goto-char (match-end 0)))
                    (skip-chars-forward " \t")
                    (when (and in-doc-comment
                               (not tag-starts-line)
                               (looking-at-p (rx "@" (+ lower) " ")))
                      (forward-char 2)))
                  (current-column))))
           (indent-line-to indent-col)
           t))))