Function: treesit-forward-comment
treesit-forward-comment is a byte-compiled function defined in
treesit.el.gz.
Signature
(treesit-forward-comment COUNT)
Documentation
Tree-sitter forward-comment-function implementation.
COUNT is the same as in forward-comment.
Probably introduced at or before Emacs version 31.1.
Source Code
;; Defined in /usr/src/emacs/lisp/treesit.el.gz
(defun treesit-forward-comment (count)
"Tree-sitter `forward-comment-function' implementation.
COUNT is the same as in `forward-comment'."
(let ((res t) thing)
(while (> count 0)
(skip-chars-forward " \t\n")
(setq thing (treesit-thing-at (point) 'comment))
(if (and thing (eq (point) (treesit-node-start thing)))
(progn
(goto-char (treesit-node-end thing))
;; For line comments, go to the next line. This is
;; important because a) for navigation convenience, and b)
;; many functions expect `forward-comment' to behave this
;; way (bug#80837).
(when (treesit--likely-line-comment-p thing)
(skip-chars-forward " \t")
(when (looking-at-p "\n")
(forward-char)))
(setq count (1- count)))
(setq count 0 res nil)))
(while (< count 0)
(skip-chars-backward " \t\n")
(setq thing (treesit-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))