Subject: Re: bug#75442: 31.0.50; c-ts-mode indentation problem
From: Yuan Fu <[email-masked]>
To: Stefan Kangas <[email-masked]>
Cc: Theodor Thornhill <[email-masked]>,Uygar KÖSEER <[email-masked]>, [email-masked]
Date: Sun, 12 Jan 2025 22:25:31 -0800
List-Id: <debbugs-submit.debbugs.gnu.org>

> On Jan 10, 2025, at 5:20 PM, Stefan Kangas <[email-masked]> wrote:
> 
> Uygar KÖSEER <[email-masked]> writes:
> 
>> Hi,
>> 
>> I started to use c-ts-mode (tree-sitter) and I think there is a little
>> indentation problem when typedef declaration is used.
>> 
>> Wrong indentation case:
>> 
>> typedef struct Point
>>        {
>>            int x;
>>            int y;
>>        } Point;
>> 
>> I think this happens because it aligns it with the struct keyword.
>> 
>> Working case:
>> typedef struct Point Point;
>> struct Point
>> {
>>    int x;
>>    int y;
>> } Point;
>> 
>> This case works without problem because the struct keyword is at the
>> beginning of the line.
>> 
>> Both of the cases are matched with this part in c-ts-mode.el:
>> ((parent-is ,(rx (or "function_definition"
>>                                "struct_specifier"
>>                                "enum_specifier"
>>                                "function_declarator"
>>                                "template_declaration")))
>>            parent 0)
>> 
>> I also tried to change this behaviour by adding new rules to my
>> c-ts-mode configuration but it always matches with the default
>> configuration first. I do not know if there is any way to change this
>> behaviour without re-defining all the default configuration.
> 
> Theodor, any comments here?

This is caused by some recent changes I made. I pushed a fix to master.

Yuan