GNU bug report logs - #62412
29.0.60; strange c++ indentation behavior with tree sitter

Previous Next

Package: emacs;

Reported by: "Herman, Geza" <geza.herman <at> gmail.com>

Date: Thu, 23 Mar 2023 20:44:02 UTC

Severity: normal

Found in version 29.0.60

Done: Stefan Kangas <stefankangas <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Herman, Géza <geza.herman <at> gmail.com>
To: João Távora <joaotavora <at> gmail.com>
Cc: Yuan Fu <casouri <at> gmail.com>, Theodor Thornhill <theo <at> thornhill.no>, 62412 <at> debbugs.gnu.org
Subject: bug#62412: 29.0.60; strange c++ indentation behavior with tree sitter
Date: Sat, 25 Mar 2023 18:47:11 +0100

On 3/25/23 17:23, João Távora wrote:
>
>> I agree. In my opinion, c++-mode's heuristics are good.
> That's probably only because we're _used_ to c++-mode.  If we had been
> using c++-ts-mode for years, we would be equally suprised.
Yes, that can be true.

>
>> Tree-sitter support is new, it's expected that it won't work
>> perfectly. Also, it doesn't have to handle any invalid program. But,
>> while writing a program, it should handle indentation sensibly. I
>> don't think that it's a good approach that everybody who uses electric
>> indent should get used to the fact that whenever they writing a for
>> loop, the line will jump around. It's a bad experience.
> But writing a for loop from scratch is only one of the editing
> activities you do in a C++ file.  Other activities involve editing
> existing code.  In those situations, c++-ts-mode's heuristics could
> "win".  Unless you're willing to posit that writing code from scratch is
> more frequent than editing existing code, there's no right answer here.
What is the c++-ts heuristics here so it removes the indentation? I 
don't really understand why it does that. Is there a similarly looking 
situation where removing the indentation is the sensible behavior?


>> Anyways, feel free to close this issue if you think otherwise. I just
>> disabled ';'-caused auto indenting, so I don't see this unpleasant
>> behavior any more.
> Yes, i'm inclined to think that c++-ts-mode shouldn't add any chars to
> electric-indent-chars.  It's just not useful.
>
As far as I know, c++-mode has ';'-caused auto indenting, it just works 
with a different mechanism. So if the aim is that the two c++ modes 
should work similarly out of the box, then it'd make sense to keep 
electric-indent-chars as is.




This bug report was last modified 1 year and 331 days ago.

Previous Next


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