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 10:43:47 +0300

> From: João Távora <joaotavora@gmail.com>
> Date: Wed, 29 Mar 2023 22:30:29 +0000
> Cc: dgutov@yandex.ru, dancol@dancol.org, casouri@gmail.com, 
>       emacs-devel@gnu.org, theo@thornhill.no
> 
> > > diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el
> > > index 59eb9fc23e6..88360716381 100644
> > > --- a/lisp/progmodes/c-ts-mode.el
> > > +++ b/lisp/progmodes/c-ts-mode.el
> > > @@ -956,10 +956,6 @@ c-ts-base-mode
> > >    ;; Comment
> > >    (c-ts-common-comment-setup)
> > >
> > > -  ;; Electric
> > > -  (setq-local electric-indent-chars
> > > -              (append "{}():;,#" electric-indent-chars))
> > > -
> > >    ;; Imenu.
> > >    (setq-local treesit-simple-imenu-settings
> > >                (let ((pred #'c-ts-mode--defun-valid-p))
> > >
> > > In master?  In emacs-29?
> >
> > I suggest to do this in emacs-29, but conditionally, with a
> > defcustom.  This will allow users to try both ways and maybe we will
> > have some feedback regarding what is the best way.
> 
> I'm not fond of creating a defcustom to work around what I consider
> as a simple bug and to configure something which the user can already
> configure with a two-line mode hook addition.

I think this conclusion is at least inaccurate, if not incorrect.
IOW, this is not "a simple bug", it could be an issue with different
personal preferences or something else.  See below for details.

> So I won't do that change myself.

That's a strange stance.  Discussion of solutions to issues can
legitimately conclude that some solution could be subject to personal
preferences, some of which you don't share.  Refusing to install a
change you yourself suggested with such minor adjustments, just
because it doesn't fit your personal preferences in editing C/C++
code, sounds at least unfriendly.

> And then my personal opinion is that it is an annoying
> feature to have on by default as it whole lines about.
> Having electric-indent-chars set to '(?\n), like c++-mode
> has, is fine.

Let's back up a notch and revisit the evidence, okay?

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.

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.)

More generally, the claim that CC mode doesn't alter
electric-indent-chars doesn't really explain the differences in
behavior, because while the claim is factually true, CC mode gives
some characters electric behavior that is independent of
electric-indent-chars, see the node "Electric Keys" in the CC Mode
manual.  What happens here is that keys like '#', '*', '<', '(', '{',
':', and others are bound to CC mode specific commands like
c-electric-pound and c-electric-brace, which reindent the code if
electric-indent-mode is turned on in the buffer.

Bottom line: I think both this thread and the discussion in bug#62412
have a lot of misunderstandings and examples at least I cannot
reproduce, and therefore the conclusions reached there, including your
suggestion to remove addition to electric-indent-chars, might very
well be based on those misunderstandings and/or unreproducible
results.  Therefore, to make progress in this issue, we should revisit
the examples, decide whether we are discussing behavior with or
without electric-indent-mode, and then take this from there, after
making sure we are on the same page.

For now, I see no reason to remove the line in c-ts-base-mode which
adds to electric-indent-chars, with or without a defcustom to control
that.



reply via email to

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