From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Lynn Winebarger Newsgroups: gmane.emacs.devel Subject: Re: treesit indentation "blinking" Date: Wed, 29 Mar 2023 18:56:01 -0400 Message-ID: References: <87h6ucik61.fsf@dancol.org> <0F406D08-56D4-4B21-B94D-A47681606911@gmail.com> <1870bcadd28.2829.cc5b3318d7e9908e2c46732289705cb0@dancol.org> <1870cce6690.2829.cc5b3318d7e9908e2c46732289705cb0@dancol.org> <35A837A9-59B4-4F1F-A5FA-8483C8024D76@gmail.com> <187104f6b48.2829.cc5b3318d7e9908e2c46732289705cb0@dancol.org> <21d018e5-a730-12e3-f97c-fffa4f646ccf@yandex.ru> <83v8ioc2ou.fsf@gnu.org> <87sfdsx0r2.fsf@gmail.com> <87lejgsf0m.fsf@gmail.com> <83pm8s70o3.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000f5dd3205f811e1dc" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31377"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , Dmitry Gutov , dancol@dancol.org, Yuan Fu , emacs-devel , Theodor Thornhill To: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Mar 30 00:57:04 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1phej2-0007mT-Gk for ged-emacs-devel@m.gmane-mx.org; Thu, 30 Mar 2023 00:57:04 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pheiI-00065l-Tf; Wed, 29 Mar 2023 18:56:18 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pheiH-00065P-0D for emacs-devel@gnu.org; Wed, 29 Mar 2023 18:56:17 -0400 Original-Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pheiF-00040u-14; Wed, 29 Mar 2023 18:56:16 -0400 Original-Received: by mail-pl1-x632.google.com with SMTP id le6so16365418plb.12; Wed, 29 Mar 2023 15:56:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680130573; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=d9yVJJYW1iBQ6e2NOLC0HYfq13rqIh/Ewwop1foJ4rw=; b=VFKqXvmgZ+3dtxzXDDLwMhmbCMUUT82xpBWz8DLH3kG1Sv90WzHRI0Erok6Bxd9s9u DCmCA+gH3O68XvbMiNoFJONb5J/GwWM3nYkvjBA8QlGJEM7YfP1y+AqFiHYRYVL/M+Jo u0QO6sQtBewio0Ppx6MP0Lgywfo5Y0BP629a61lopU7KqVMpRu5NV81zGolal7eZUkG+ 69kPls5uHewxdMHcmphxgskOY8OQsF/SqQBlbnLHMj14UFxsPA4WWXFkVhu4IC5pF4U6 2/VNeedjOfWQQLtmk0mYVldVZnhXQ99Y0MyNnFEkji+FPeRV72W8P1HIFQqOq9NRFRXB pafg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680130573; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=d9yVJJYW1iBQ6e2NOLC0HYfq13rqIh/Ewwop1foJ4rw=; b=fmziZO9GQkdqlh0yJKJxJl5FOYgSr3aXT3k9pfIQnwxBuWRzCuKtf1L7s5X5b61Qd9 5VYU9JdUpFmlREr1nG7daUGVV6MwE3fzP53rx6B6WsVLG3sEMr6EjRp14wZ5p3maLZRi PuTMzE7Rk8EIkKS4FuzRnhds4ti3fvg85xsbQujSQoiB5jHa/ydudgsxfUxOUDbLsFmv ldsUCjwbBDBO+jTsvzu9BYqnm8VLYgTcUYlPGCDh9bIgU2gmKeVdg0E2ts/6JQmsu9zG HUt8iwTgaE/6F0NAwivzfcmSSOr9txcyh1x2O5oENeWsU8NeQQMbMKumiHZz4+s1U7xV jO1A== X-Gm-Message-State: AAQBX9f0HkrEkqjXPtmgGar+qJOV+p9Y/CcrJ9E+xozqja5sjoxlxB3m 8/SjPFnGg9CCTpFb1AIRdgL/XK+NxsGxLIxog+u0rSUO X-Google-Smtp-Source: AKy350aTT6CocOGl7jw3KRG8uryDCODHTDChjSG75at575zIQ9vIVd0e1VUO5e4xpR57Pf+29EjIoW93ijgPqYeJmvA= X-Received: by 2002:a17:903:32c3:b0:1a1:b3bb:cd5e with SMTP id i3-20020a17090332c300b001a1b3bbcd5emr7588899plr.9.1680130572670; Wed, 29 Mar 2023 15:56:12 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=owinebar@gmail.com; helo=mail-pl1-x632.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, FREEMAIL_REPLY=1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:304829 Archived-At: --000000000000f5dd3205f811e1dc Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Mar 29, 2023, 6:29 PM Jo=C3=A3o T=C3=A1vora = wrote: > On Wed, Mar 29, 2023 at 3:26=E2=80=AFAM Eli Zaretskii wrot= e: > > > > > From: Jo=C3=A3o T=C3=A1vora > > > Cc: Dmitry Gutov , 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 lea= st > > > 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.e= l > > > 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. > I would think the advantage of using tree-sitter is triggering formatting based on lexemes and grammar symbols rather than raw characters. So instead of ';' a formatting action might be triggered by the parser deducing a lexeme/symbol STATEMENT-SEPARATOR, as opposed to a ';' separating clauses in a for statement. Lynn --000000000000f5dd3205f811e1dc Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Wed, Mar 29, 2023, 6:29 PM Jo=C3=A3o T=C3=A1vora <joaotavora@gmail.com> wrote:
On Wed, Mar 29, 2023 at 3:26=E2=80=AFAM = Eli Zaretskii <eliz@gnu.org> wrote:
>
> > From: Jo=C3=A3o T=C3=A1vora <joaotavora@gmail.com> > > Cc: Dmitry Gutov <dgutov@yandex.ru>,=C2=A0 dancol@dancol= .org,=C2=A0 casouri@gmail.com,
> >=C2=A0 =C2=A0emacs-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.=C2=A0 So if there are n= o
> > objections, I propose to apply this patch.
> >
> > diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mo= de.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
> >=C2=A0 =C2=A0 ;; Comment
> >=C2=A0 =C2=A0 (c-ts-common-comment-setup)
> >
> > -=C2=A0 ;; Electric
> > -=C2=A0 (setq-local electric-indent-chars
> > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (append "{= }():;,#" electric-indent-chars))
> > -
> >=C2=A0 =C2=A0 ;; Imenu.
> >=C2=A0 =C2=A0 (setq-local treesit-simple-imenu-settings
> >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (let ((pre= d #'c-ts-mode--defun-valid-p))
> >
> > In master?=C2=A0 In emacs-29?
>
> I suggest to do this in emacs-29, but conditionally, with a
> defcustom.=C2=A0 This will allow users to try both ways and maybe we w= ill
> 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 point= s
> 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).=C2=A0 I.e. they auto-indent on newline and don't bounce around when symbols such as ':',= 9;)' or
';' are typed.=C2=A0 As far as I can tell, auto-indenting on charac= ters
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.

I would think the advantage of using tree-sitter is triggering= formatting based on lexemes and grammar symbols rather than raw characters= .=C2=A0 So instead of ';' a formatting action might be triggered by= the parser deducing a lexeme/symbol STATEMENT-SEPARATOR, as opposed to a &= #39;;' separating clauses in a for statement.
Lynn

--000000000000f5dd3205f811e1dc--