bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#62412: 29.0.60; strange c++ indentation behavior with tree sitter


From: Herman
Subject: bug#62412: 29.0.60; strange c++ indentation behavior with tree sitter
Date: Sat, 25 Mar 2023 11:26:04 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.1

That's the difference. c++-ts-mode appends "{}():;,#" to electric-indent-chars, while c++-mode doesn't do this.

Nevertheless, I think that the calculated intendation should be a correct number. Even if the user turns off electric-indent-mode, but dedices to call re-indenting manually for a half-written for loop, emacs should re-intent the line properly. At least, this specific example works OK with c++-mode.

(note that I understand that this problem is not trivial, tree sitter/emacs may get confused if the buffer cannot be properly parsed)

On 3/25/23 09:53, João Távora wrote:
On Fri, Mar 24, 2023 at 10:02 PM Theodor Thornhill via Bug reports for
GNU Emacs, the Swiss army knife of text editors
<bug-gnu-emacs@gnu.org> wrote:
e about the original purpose for this rule, CC’ing Theo.
Yuan
I'll look more deeply into the cause of this, but the rule is covering some 
preproc directives iirc.

Unfortunately tree-sitter behaves better when auto pairs is used. I would 
advise people to use electric-pairs-mode (if that's the correct name, on mobile 
now) to avoid these sorts of issues.
electric-pair-mode, it's not on by default.

But, for some reason, electric-indent-mode _is_ on by default,
at least in c++-ts-mode.

So this has nothing to do with tree-sitter IMO, it's just
electric-pair-mode doing its thing.

Why is it on by default?  A fair number of users don't like
this electricity, or prefer to have it toned down.  At least
this has been the  argument for not turning on electric-pair-mode
by default, which is a much less jarring mode IMO, and one which
would solve these problems.

João






reply via email to

[Prev in Thread] Current Thread [Next in Thread]