emacs-devel
[Top][All Lists]
Advanced

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

Re: treesit indentation "blinking"


From: João Távora
Subject: Re: treesit indentation "blinking"
Date: Wed, 29 Mar 2023 22:30:29 +0000

On Wed, Mar 29, 2023 at 3:26 AM Eli Zaretskii <eliz@gnu.org> wrote:
>
> > From: João Távora <joaotavora@gmail.com>
> > Cc: Dmitry Gutov <dgutov@yandex.ru>,  dancol@dancol.org,  casouri@gmail.com,
> >   emacs-devel@gnu.org, theo@thornhill.no
> > Date: Tue, 28 Mar 2023 23:11:05 +0100
> >
> > Though a number of indenting problems would remain after that, at least
> > this one clear annoyance would be solved.  So if there are no
> > objections, I propose to apply this patch.
> >
> > 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. So I won't do that
change myself.

> I'm also interested to know what other editors do, as Daniel points
> out.

I don't use many other editors but I can tell you that online editors
like the ones found at hackerrank.com, which I strongly suspect are
based on LSP + treesitter behave as if electric-pair-mode was on
and electric-indent-chars is just '(?\n).  I.e. they auto-indent
on newline and don't bounce around when symbols such as ':',')' or
';' are typed.  As far as I can tell, auto-indenting on characters
other than newline is an Emacs invention that only works well if a
mode has near-perfect predictive powers of indentation, which
c++-ts-mode clearly doesn't have (yet).

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.

João



reply via email to

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