bug#80837: treesit-forward-comment off-by-one issue: overshoots by one character

Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <[email protected]> Wed, 05 Aug 2026 10:27:19 -0400
Newsgroups gmane.emacs.bugs
Message-ID <[email protected]>
>>> Also, I'm not sure we need the whole `treesit--likely-line-comment-p`:
>>> can we just test if `comment-end` is nil instead?
>> 
>> Testing for an empty `comment-end` should work at least
>> for c-ts-more and lua-ts-mode where the comment thing is set.
>
> I don’t think testing comment-end by itself makes sense. Comment-end being
> nil doesn’t tell us anything about a comment.

It tells us that the default comment marker used for this mode is
that of a "line comment".  It doesn't tell us that *this comment* uses
the same kind of comment starter, admittedly, but it's likely to give
the right answer is many cases.

We're talking about a quickfix that's not intended to fix the problem
100% but only to reduce the occurrence of the problem with a minimum
impact on the code.


=== Stefan