From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: More Tree Sitter Questions / Problems. Date: Wed, 14 Dec 2022 16:15:41 -0500 Message-ID: References: <365D3BA2-298F-4B99-9707-FE8BC658701F@easesoftware.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14552"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: emacs-devel To: Perry Smith Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Dec 14 22:16:09 2022 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 1p5Z6m-0003XI-9d for ged-emacs-devel@m.gmane-mx.org; Wed, 14 Dec 2022 22:16:08 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5Z6U-0006w4-RJ; Wed, 14 Dec 2022 16:15:51 -0500 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 1p5Z6S-0006tz-Ow for emacs-devel@gnu.org; Wed, 14 Dec 2022 16:15:49 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p5Z6Q-00060E-OD for emacs-devel@gnu.org; Wed, 14 Dec 2022 16:15:48 -0500 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id B0D3680776; Wed, 14 Dec 2022 16:15:44 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id AAD05803E0; Wed, 14 Dec 2022 16:15:42 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1671052542; bh=Bc5n/4fnEFvvuPSdR+s5Gym5VxYlp6lk1fqG2KffAAo=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=JuC0m4PescuqtDejwddib6Pfl4uwxhYDNVKjwb1DpxrNG3tzhKIdrq974EWulpNdX yWQYQyfnfaFeffO1+/IzkKk4bu0UCOPMko/Cdfbr4tdcQ+vaJ7COzuFSzcIPLHXS2s D+ez5GBdtMQvg6irKMxPBLXgPcr5dYXoBhZ0C/OvuacSp2AJWocQTaYFlCSyikSiHJ OgUVEHZYY0aeBQDuUaZyfSog2VtaCgUnLtKuZoGXBAZpjgg2UKoOxYORMH894/Pw7e +q1DFb5e32vZX5+0eG+JqOg+opa+WWZ+8hHzxFCGd5m+HomKk4pktI3V144lhnjdcf 5Jbj9Tp5AWDaw== Original-Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 6686A120167; Wed, 14 Dec 2022 16:15:42 -0500 (EST) In-Reply-To: <365D3BA2-298F-4B99-9707-FE8BC658701F@easesoftware.com> (Perry Smith's message of "Wed, 14 Dec 2022 14:43:09 -0600") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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:301415 Archived-At: > foodog =3D 12 + 4 * > 18 * 99 + 8 [ Trying to provide some SMIE perspective: ] In the context of sh-mode, I've had requests to provide that kind of "AST-oblivious" indentation. The result is controlled by `sh-indent-after-continuation`. > variable =3D 12 + 4 * > 18 * 99 + 8 That's my favorite, yes. [ Tho GNU style would recommend breaking the line just before the `*` rather than just after it. ] > I also wrote ancestor-is and ancestor so now I get: > > eddie =3D (a + b * > c * d + 12) I think this one sucks. Do we really need it? Can we have eddie =3D (a + b * c * d + 12) instead? > bobby =3D a + b * > c * d + 12 > > I fear as I test and play with this more I=E2=80=99m going to need more r= ules > to catch all the cases where a line starts with a term of an > arithmetic expression. I'm not sure how you're looking at it, but for me, I've found it important to try and understand what those indentation choices "mean". I can see two interpretations of foodog =3D 12 + 4 * 18 * 99 + 8 one is that this is one logical line spread over several physical lines and the syntactic structure should be ignored, so it leads to: foodog =3D (12 + 4 * 18 * 99 + 8) That's the interpretation I used in `sh-indent-after-continuation` and which I found to be easier to understand (and hence define in code). Another way to look at it is via what I call "virtual indentation" in SMIE: while "12 + 4 *" in the above code is indented 9 columns deeper than "foodog", we could decide that what follows a "=3D" assignment is alwa= ys "virtually indented" only 4 columns deeper than the var. So we get foodog =3D 12 + 4 + 18 * 99 + 8 because the "18" is aligned with (the virtual indentation of) "12". Then we also get foodog =3D (12 + 4 + 18 * 99 + 8) because "18" is still aligned "12" but while "(" is virtually indented to +4, the virtual indentation of "12" is not special (it's the same as its real indentation). But if want to obey the syntactic structure we still won't get foodog =3D 12 + 4 * 18 * 99 + 8 because "18" shouldn't be aligned with "12" in this case. Stefan