GNU bug report logs - #62238
30.0.50; Unusual interpretation of "S-expressions" in c-ts-mode

Previous Next

Package: emacs;

Reported by: Philip Kaludercic <philipk <at> posteo.net>

Date: Fri, 17 Mar 2023 09:53:01 UTC

Severity: normal

Found in version 30.0.50

Full log


View this message in rfc822 format

From: Theodor Thornhill <theo <at> thornhill.no>
To: Daniel Martín <mardani29 <at> yahoo.es>, Yuan Fu <casouri <at> gmail.com>
Cc: 62238 <at> debbugs.gnu.org, Philip Kaludercic <philipk <at> posteo.net>
Subject: bug#62238: 30.0.50; Unusual interpretation of "S-expressions" in c-ts-mode
Date: Sat, 18 Mar 2023 14:32:51 +0100

On 18 March 2023 13:11:15 CET, "Daniel Martín" <mardani29 <at> yahoo.es> wrote:
>Daniel Martín <mardani29 <at> yahoo.es> writes:
>
>> Yuan Fu <casouri <at> gmail.com> 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.

I tend to agree. I think it works pretty well with java for instance, but I'm struggling with the compound_statement node in the c grammar.

If too much of an annoyance, I'm ok with not defining this for c, but maybe someone that writes more c than me can have a go at defining nodes that makes sense?

Theo




This bug report was last modified 2 years and 80 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.