all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: "João Távora" <joaotavora@gmail.com>
Cc: dgutov@yandex.ru, dancol@dancol.org, casouri@gmail.com,
	emacs-devel@gnu.org, theo@thornhill.no, geza.herman@gmail.com
Subject: Re: treesit indentation "blinking"
Date: Thu, 30 Mar 2023 17:00:42 +0300	[thread overview]
Message-ID: <83wn2y49v9.fsf@gnu.org> (raw)
In-Reply-To: <87mt3uwlc0.fsf@gmail.com> (message from João Távora on Thu, 30 Mar 2023 12:05:35 +0100)

> 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, geza.herman@gmail.com
> Date: Thu, 30 Mar 2023 12:05:35 +0100
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> > 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.
> 
> You don't need me to install changes, do you?

Yes, I do.  If I had to install all the changes myself, Emacs could
never be moving forward as fast is it does today, and wouldn't be what
we see now.

This is a community project; without active collaboration of all the
contributors it wouldn't be such a success.  It should go without
saying that when someone proposes a change and the discussion then
concludes the change needs small adaptations, the person who proposed
the change will then go ahead and install those small adaptations.
Without such minimal collaboration, we as a project will get nowhere.

> >> 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.
> 
> No.  I use c++ mode with its bindings like c-electric-paren deactivated.
> I still use electric-indent-mode with its very reasonable default value
> for of (?\n)

I suspect that this is the root cause why you find c++-ts-mode so
jarring: since you disable all the electric behavior in C++ mode
except the one bound to newline, you are not used to electric
reindentation, except when you type RET.  But that is not the default.
I do use the default settings of all the CC Mode electric characters
(with very few minor customizations), and so I do see the electric
reindentation in c++-mode all the time, and am used to it.  If most
users don't disable the default electric behavior in CC Mode, they
will not see c++-ts-mode behavior as "jarring".

The difference between c++-mode and c++-ts-mode is that the latter
doesn't (yet) let you customize each electric character separately.
This could be a subject of future extensions, but for now, as Dmitry
points out, it is easy to override the value of electric-indent-chars
in a mode hook, and leave only the newline in it -- this should give
you a better approximation to what you are used to in c++-mode, I
think.

> So far I don't think anyone here has said they _like_ the bouncing.

It depends on how much it does that.  What I saw until now is not
different from what I see in CC mode with the default electric
behavior, in which case I'm okay with that.

> But maybe someone does..  I wasn't even the first to report this.
> Daniel did in this list and Geza Herman did in #61412.

Maybe Daniel also disables the electric behavior of CC mode?  In any
case, customizing electric-indent-chars could solve Daniel's problems
as well.

> >>    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).
> 
> We have different ideas of bouncing.

No, I don't think so.  We just perceive it differently.  Also, I think
your description said that each semi-colon inside "for" causes
reindentation, and I don't see that

> >> 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.
> 
> Never said it's a "catastrophe".  Just annoying/jarring/suprising
> behaviour that you don't get with vanilla c++-mode or modes based on
> cc-mode.  I think that electric-indent-chars was designed with those
> modes in mind.

Didn't we just establish that you modify the vanilla behavior of
c++-mode by disabling the electric behavior of all the characters
except the newline?  If so, users who don't disable will not see the
electric reindentation as jarring.

> I'm using the latest master (560c27a3) and starting it with 
> 
> src/emacs -Q `mktemp`.cpp -f c++-ts-mode
> 
> > Also, which version of the tree-sitter C++ grammar library do you have
> > installed?
> 
> I don't know how to answer that.  I used M-x
> treesit-install-language-grammar RET "cpp" and accepted the default in
> all prompts.  I presume it installs the latest version of the Git repo.
> I've just reinstalled today.

Then I don't know why we don't see the same behavior.  Beats me.

> You can _see_ in the GIF what I type.  I've just using normal keys for
> self-insert.  Then C-p, and some C-f to position my cursor before the
> ';;', then C-d to delete the two ';;'. And then add them back again with
> two ';;'.  After the first ';' the line goes back, then the second one,
> and the line goes forward ';'.

Similar things happen with CC mode.  Perhaps not in this particular
situation, but in others.

> Also see the original recipe of bug#62142, which is quite easy to
> follow, for more bouncing.  Can't you reproduce this either?

I'm confused by the description there, and we just discovered that you
said there to disable electric-indent-mode when you really meant
electric-pair-mode.  So maybe post a revised example there (or here),
this time without any mistakes, and let's take it from there.



  reply	other threads:[~2023-03-30 14:00 UTC|newest]

Thread overview: 73+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-22 20:49 treesit indentation "blinking" Daniel Colascione
2023-03-23  0:00 ` Yuan Fu
2023-03-23  0:07   ` Daniel Colascione
2023-03-23  1:02     ` Yuan Fu
2023-03-23  4:51       ` Daniel Colascione
2023-03-23 20:04         ` Yuan Fu
2023-03-23 21:10           ` Daniel Colascione
2023-03-23 21:24             ` Dmitry Gutov
2023-03-25  9:05               ` João Távora
2023-03-25 12:42                 ` Dmitry Gutov
2023-03-25 14:42                   ` Eli Zaretskii
2023-03-25 16:18                     ` João Távora
2023-03-28 22:11                       ` João Távora
2023-03-28 23:57                         ` Daniel Colascione
2023-03-29  2:26                         ` Eli Zaretskii
2023-03-29 22:30                           ` João Távora
2023-03-29 22:37                             ` Herman, Géza
2023-03-29 23:25                               ` João Távora
2023-03-30  7:47                                 ` Herman, Géza
2023-03-29 22:56                             ` Lynn Winebarger
2023-03-30  7:43                             ` Eli Zaretskii
2023-03-30  8:58                               ` Dmitry Gutov
2023-03-30  9:15                                 ` João Távora
2023-03-30  9:06                               ` João Távora
2023-03-30  9:20                                 ` Dmitry Gutov
2023-03-30  9:28                                   ` João Távora
2023-03-30  9:36                                     ` Dmitry Gutov
2023-03-30 10:00                                       ` João Távora
2023-03-30 16:29                                         ` Dmitry Gutov
2023-03-30 17:14                                           ` João Távora
2023-03-30 10:07                                 ` Eli Zaretskii
2023-03-30 10:26                                   ` Herman, Géza
2023-03-30 13:39                                     ` Eli Zaretskii
2023-03-30 15:03                                       ` Herman, Géza
2023-03-30 14:58                                     ` Eli Zaretskii
2023-04-01 19:39                                       ` Yuan Fu
2023-04-02  1:49                                         ` Yuan Fu
2023-04-02  5:31                                           ` Eli Zaretskii
2023-04-02 14:26                                           ` Alan Mackenzie
2023-04-02 15:48                                             ` João Távora
2023-04-02 17:04                                               ` Alan Mackenzie
2023-04-02 17:23                                                 ` João Távora
2023-04-02 17:51                                                   ` Eli Zaretskii
2023-04-02 18:04                                                     ` João Távora
2023-04-02 18:14                                                       ` Eli Zaretskii
2023-04-02 21:38                                                         ` João Távora
2023-04-02 21:21                                                   ` Dmitry Gutov
2023-04-02 21:40                                                     ` João Távora
2023-04-03  9:59                                                     ` Alan Mackenzie
2023-04-03 10:28                                                       ` João Távora
2023-04-03 12:07                                                       ` Dmitry Gutov
2023-04-03 12:56                                                         ` Alan Mackenzie
2023-04-03 20:58                                                           ` Dmitry Gutov
2023-04-03 21:59                                                         ` Daniel Colascione
2023-04-03 22:10                                                           ` Dmitry Gutov
2023-04-04  8:31                                                           ` João Távora
2023-04-07 14:20                                                           ` Daniel Martín
2023-04-08  1:32                                                             ` Dmitry Gutov
2023-04-08  2:42                                                               ` Yuan Fu
2023-04-08 18:59                                                               ` Daniel Martín
2023-04-03 21:47                                             ` parser error recovery algorithm vs " Stephen Leake
2023-04-04 12:01                                               ` John Yates
2023-04-04 13:40                                                 ` Dmitry Gutov
2023-04-04 16:00                                                   ` Stephen Leake
2023-04-04 13:50                                                 ` Stephen Leake
2023-04-04 14:05                                                   ` Dmitry Gutov
2023-03-30 11:05                                   ` João Távora
2023-03-30 14:00                                     ` Eli Zaretskii [this message]
2023-03-30 14:43                                       ` João Távora
2023-03-30 14:52                                         ` Eli Zaretskii
2023-03-30 15:42                                           ` João Távora
2023-03-25 16:14                   ` João Távora
2023-03-24 11:39             ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83wn2y49v9.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=casouri@gmail.com \
    --cc=dancol@dancol.org \
    --cc=dgutov@yandex.ru \
    --cc=emacs-devel@gnu.org \
    --cc=geza.herman@gmail.com \
    --cc=joaotavora@gmail.com \
    --cc=theo@thornhill.no \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.