GNU bug report logs - #61893
29.0.60; Indentation in c-ts-mode broken again

Previous Next

Package: emacs;

Reported by: Eli Zaretskii <eliz <at> gnu.org>

Date: Wed, 1 Mar 2023 14:38:01 UTC

Severity: normal

Found in version 29.0.60

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Theodor Thornhill <theo <at> thornhill.no>
To: Yuan Fu <casouri <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 61893 <at> debbugs.gnu.org, Daniel Martín <mardani29 <at> yahoo.es>
Subject: bug#61893: 29.0.60; Indentation in c-ts-mode broken again
Date: Mon, 06 Mar 2023 07:03:33 +0100
Yuan Fu <casouri <at> gmail.com> writes:

>> On Mar 5, 2023, at 12:22 AM, Eli Zaretskii <eliz <at> gnu.org> wrote:
>> 
>>> From: Yuan Fu <casouri <at> gmail.com>
>>> Date: Sat, 4 Mar 2023 15:03:46 -0800
>>> Cc: Eli Zaretskii <eliz <at> gnu.org>,
>>> Daniel Martín <mardani29 <at> yahoo.es>,
>>> 61893 <at> debbugs.gnu.org
>>> 
>>>>>>> The elif directive’s and subsequent directives aren’t indented
>>>>>>> properly. Looking at the parsed tree, the elif directives are nested in
>>>>>>> the if directive, and the nesting can be arbitrarily deep. We probably
>>>>>>> need a custom function rather than great-grand-parent to find the anchor,
>>>>>>> like a function that keeps going up the tree until the node isn’t a
>>>>>>> preproc directive anymore.
>>>>>>> 
>>>>>>> Yuan
>>>>>> 
>>>>>> Yeah, you're right. I'll see what I can do, but bandwidth is a little low at the moment, so if you have some extra time, don't hesitate to improve it :)
>>>>> 
>>>>> Absolutely, I’ll work on it. 
>>>>> 
>>>>> Yuan
>>>> 
>>>> Thanks :)
>>> 
>>> Done!
>> 
>> Thanks.
>> 
>> Some problems still remain.
>
> Thanks, there are so many edge cases :-)
>
>> 
>> Line 1761 of dispnew.c: type "C-e RET" -- point goes to column 7
>> instead of the expected column 2.
>
> Fixed.
>> 
>> Line 3381 of dispnew.c: type "C-e RET" -- point goes to the correct
>> column, but line 3381 is reindented incorrectly.
>
> This is due to it aligning to the previous sibling, aka the comment. Do we want to skip comments for the “align to the prev sibling” rule?
>
>> 
>> Line 6611 of dispnew.e: type "C-e RET" -- point goes to column 0
>> instead of the expected column 2.  If you type "C-e RET" on the next
>> line 6612, point goes to column 0 and the line is reindented
>> incorrectly.
>
> Fixed.
>> 
>> Line 13925 of xdisp.c: type "C-e RET" -- point goes to column 33(!)
>> and line 13925 is reindented incorrectly.
>
> Fixed.
>> 
>> Lines 34529 and 34530 of xdisp.c: "C-e RET" produces incorrect column
>> of point and reindents line 34530.
>
> The preproc directive messed the parse tree, and tree-sitter can’t tell that it’s an else statement, so it can’t be easily fixed sadly.
>
> Yuan

Now this isn't indenting how I expect:

int foo
{
|      // <-- Now point is indented to column 0
}

It seems like `c-ts-mode--anchor-prev-sibling` isn't handling this?

Theo




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

Previous Next


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