Function: neocaml--forward-comment
neocaml--forward-comment is a natively compiled function defined in
neocaml.el.
Signature
(neocaml--forward-comment &optional COUNT)
Documentation
Corrected forward-comment-function for OCaml block comments.
Emacs 31's treesit-forward-comment has an off-by-one bug: it
does (1+ (treesit-node-end ...)) but treesit-node-end already
returns an exclusive position, so point overshoots by one
character. This breaks uncomment-region for multi-line
regions. This function is identical to treesit-forward-comment
with the overshoot removed.
Only installed on Emacs 31+. COUNT is the same as in
forward-comment; uses funcall to avoid a package-lint
warning about treesit-thing-at requiring Emacs 30.1 while the
package supports 29.1.
Source Code
;; Defined in /nix/store/ahssdx4rwzyxhyhavpn0bkznk13xrggi-emacs-packages-deps/share/emacs/site-lisp/elpa/neocaml-20260907.2015/neocaml.el
(defun neocaml--forward-comment (&optional count)
"Corrected `forward-comment-function' for OCaml block comments.
Emacs 31's `treesit-forward-comment' has an off-by-one bug: it
does (1+ (treesit-node-end ...)) but `treesit-node-end' already
returns an exclusive position, so point overshoots by one
character. This breaks `uncomment-region' for multi-line
regions. This function is identical to `treesit-forward-comment'
with the overshoot removed.
Only installed on Emacs 31+. COUNT is the same as in
`forward-comment'; uses `funcall' to avoid a package-lint
warning about `treesit-thing-at' requiring Emacs 30.1 while the
package supports 29.1."
(let ((res t) thing
(thing-at (intern "treesit-thing-at")))
(while (> count 0)
(skip-chars-forward " \t\n")
(setq thing (funcall thing-at (point) 'comment))
(if (and thing (eq (point) (treesit-node-start thing)))
(progn
(goto-char (treesit-node-end thing))
(setq count (1- count)))
(setq count 0 res nil)))
(while (< count 0)
(skip-chars-backward " \t\n")
(setq thing (funcall thing-at (max (1- (point)) (point-min)) 'comment))
(if (and thing (eq (point) (treesit-node-end thing)))
(progn
(goto-char (treesit-node-start thing))
(setq count (1+ count)))
(setq count 0 res nil)))
res))