Subject: Re: bug#62238: 30.0.50; Unusual interpretation of "S-expressions" in c-ts-mode

From: Daniel Martín <[email-masked]>
Date: Sat, 18 Mar 2023 13:11:15 +0100

Daniel Martín <[email-masked]> writes:

> Yuan Fu <[email-masked]> writes:
>
>>
>> I tested this on my Emacs session and vanilla session, and both marked
>> to the closing bracket. I believe forward-sexp should just work by the
>> syntax table. Perhaps it’s your config or something?
>>
>
> You need to enable c-ts-mode first, which redirects
> forward-sexp-function to treesit-forward-sexp.

I see in treesit.el that we set forward-sexp-function to
treesit-forward-sexp when treesit-sexp-type-regexp is set by the major
mode.  For languages with simple grammars, like C, I think that the
current approach that uses the syntax table is simpler and less prone to
errors, because the Tree-sitter function is general and should work for
every language.  I'd suggest we don't define treesit-sexp-type-regexp in
c-ts-mode, at least for C.

For languages like TypeScript, whose grammar is more complex, perhaps
forward-sexp does not work very well and using Tree-sitter to implement
it gives better results with code that is simpler to understand.

Thanks.