emacs-devel
[Top][All Lists]
Advanced

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

Re: treesit indentation "blinking"


From: Eli Zaretskii
Subject: Re: treesit indentation "blinking"
Date: Thu, 30 Mar 2023 13:07:47 +0300

> From: João Távora <joaotavora@gmail.com>
> Cc: dgutov@yandex.ru,  dancol@dancol.org,  casouri@gmail.com,
>   emacs-devel@gnu.org,  theo@thornhill.no
> Date: Thu, 30 Mar 2023 10:06:19 +0100
> 
> Eli, I'm just trying to help. I don't use c++-ts-mode yet.  It's still
> very immature IMO.  Someone in this thread mentioned electric-pair-mode,
> a mode I authored, and its (positive) effects on bouncing indentation.
> 
> Apparently noone had looked into electric-indent-chars for the cause, or
> provide a recipe.  I did and proposed a trivial solution for anreal
> problem that I wasn't the first or even the second to witness.

FWIW, I don't see any problem that needs fixing, not yet.

> If you don't like my patch, it's fine.  Use the results of my
> experiments as you see fit.  But just don't want to figure out a
> defcustom name, a default value, etc and contribute to an Emacs with
> more defcustoms for areas where I personally believe defcustom aren't
> the answer.  I won't stop anyone from adding one.

I suggested a defcustom because I blindly believed your description
and your analysis.  Now that I have tried reproducing the issues you
describe, and cannot see the problems you describe, I no longer think
there's a problem that justifies removal of electric-indent-chars
customization by c++-ts-mode, with or without the defcustom.

> Is this "unfriendly"?  Geez.

What _is_ unfriendly is to refuse to install a change that you
yourself consider required, when asked to do that conditionally, so
users who still want the electricity, even though it "blinks", could
still have it.  I think the request is reasonable, especially since
you don't use this mode, and so can easily overlook some useful
behavior that your proposed change could disable or break.

> > First, I don't agree with your conclusion that the local setting of
> > electric-indent-chars in c-ts-base-mode causes divergent behavior wrt
> > its CC mode equivalents.  In particular, the example you brought up in
> >
> >   https://lists.gnu.org/archive/html/emacs-devel/2023-03/msg00939.html
> >
> > behaves the same in c++-mode, at least in "emacs -Q": "std:" (with a
> > single colon) causes reindentation as if this were a label, and adding
> > another colon indents back to column 2.  So at least in this example
> > the behavior I see is the same in both modes.
> 
> I didn't realize that, because I use c++-mode with its electric features
> off.

If you turn electric features off, then electric-indent-chars will
have no effect whatsoever, and all this discussion is moot.

> I think within 5 minutes of editing, someone used to c++-mode -- even
> with its default electricity -- will start to feel unconfortable with
> c++-ts-mode.

We shall see, okay?  You could be right or you could be wrong.  The
purpose of releasing these modes in Emacs 29 is to collect user
feedback, so we know in which direction(s) to develop them further.
Your opinions are noted, but let's give others chance to voice theirs,
okay?

> I saw bouncing in lots of other places, bouncing that I
> know I just don't see with c++-mode.  If I ever pick it up again, I'll
> let the ts people know.

Please report any problems you see when you see them, so that we could
fix those that are still there.

> > Also, at least some of the examples for a different behavior between
> > c++-mode and c++-ts-mode explicitly turned OFF electric-indent-mode.
> > For example, see
> >
> >   https://debbugs.gnu.org/cgi/bugreport.cgi?bug=62412#14
> >
> > When electric-indent-mode is turned OFF, setting electric-indent-chars
> > cannot possibly make any difference, right?
> >
> > (Btw, I cannot reproduce what the first example there says: if I turn
> > OFF electric-indent-mode, RET doesn't correctly indent the next line;
> > instead, the next line is not indented at all.  So I wonder what is
> > being missed here.)
> 
> What's being missed is that perhaps you're mixing electric-pair-mode
> with electric-indent-mode? In these tests I never turned off e-i-m,
> because it's on by default in Emacs.

The above message as part of bug#62412 clearly says "Let's assume you
turn off electric-indent-mode."  I interpreted that as meaning that
electric-indent-mode is to be turned off for the rest of the examples
to do what you mean them to do.

> I already gave this alternative MRE of bouncing behaviour.
> 
>    emacs -Q `mktemp`.cpp -f c++-ts-mode  
> 
>    i n t SPC m a i n ( ) { RET for ( ; ; ) SPC b l a ( ) ;  
> 
> Can you reproduce this bouncing?

No, I cannot.  All I see is that the semi-colon after "foo()" indents
the line, just once, so that it has the correct indentation
(previously it had no indentation at all).

> Now try the same with c++-mode. Do you confirm that it doesn't
> bounce?

The only difference I see is that c++-mode indents the line with "for"
right from the start, after I type RET.  Which is better indeed, but
what c++-ts-mode does is not a catastrophe, either.

> Also in c++-ts-mode, add a closing `}`.  See the "mismatched
> parenthesis"?

No, I don't.

Are you using Emacs 29 or Emacs 30?  I'm using the former.

Also, which version of the tree-sitter C++ grammar library do you have
installed?

> Now I'm going to give another example.  In the same file, go back to
> c++-ts-mode.  Say you spotted a mistake and dont want an infloop after
> all.  Go and delete the two ';;' in the for expressions, leaving, say
> just the parenthesis.  Start typing another set of expressions.

Please state exactly what to type, otherwise we will again be talking
past each other.

> See the bouncing back and forth?  I've even made a gif of this.

I see it in your GIF, but not on my system.



reply via email to

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