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: Plug treesit.el into other emacs constructs Date: Wed, 14 Dec 2022 23:37:15 -0500 Message-ID: References: <87wn6whete.fsf@thornhill.no> <87r0x3gnv5.fsf@thornhill.no> <04BB786A-3ED1-4918-8583-17AA01A1E453@gmail.com> <4E3940CA-67A6-45B7-8785-4E60FDECCDFB@gmail.com> <0CA63C32-432C-42C5-BBAD-C6E1A7CE1806@gmail.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="34231"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Theodor Thornhill , emacs-devel , eliz@gnu.org To: Yuan Fu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Dec 15 05:38:04 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 1p5g0Q-0008hV-Rv for ged-emacs-devel@m.gmane-mx.org; Thu, 15 Dec 2022 05:38:03 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5fzo-0007s7-KB; Wed, 14 Dec 2022 23:37:24 -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 1p5fzm-0007rZ-FW for emacs-devel@gnu.org; Wed, 14 Dec 2022 23:37:22 -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 1p5fzk-0000bO-L6; Wed, 14 Dec 2022 23:37:22 -0500 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id E6ADE8078F; Wed, 14 Dec 2022 23:37:17 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 4A2DB80723; Wed, 14 Dec 2022 23:37:16 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1671079036; bh=LLSxg5+NseSFga4t+qSScxMtLoX3Eq9VT/MVN8hjjNw=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=TOOO95bl6795SS50i9Qybb9GDLg1SGvKfrT/MXBmX9pS0U8gOccKHO484m10E/PI+ FUcueKCuPrEr/OyXPxG/sBErK0nYVuoluZs9ANPNZyMOX3BtNr7u9uVQmoW78ikGB6 EDnMTF5VpA5GOzJzH31mRBxpCNzP3us0gsl+G+KZOIBUrDhmTYgCJCtG/kpWiEnLXJ a9q0lYNTK41+ijyZfh+8oCVgIAiWeINSeH6Nv3hBvg85r1kHh7SQbjojruAkA81AOc KuZmwO7sMZxstIEcUH8kgZVkWlw8zzgtkLB/eP69hL3WDluPpsnIMT/QzuFtIrFh9Y +x3IuZvvAjfZQ== Original-Received: from pastel (unknown [45.72.193.52]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 14E6C1201DD; Wed, 14 Dec 2022 23:37:16 -0500 (EST) In-Reply-To: <0CA63C32-432C-42C5-BBAD-C6E1A7CE1806@gmail.com> (Yuan Fu's message of "Wed, 14 Dec 2022 15:31:20 -0800") 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:301431 Archived-At: >> In my view ";" is not a substree. It's the node of a substree. >> We can't actually move over a proper subtree in that case because there >> is no substree whose left boundary starts right before the ";", so the >> closest is to move over the ";" *plus* its right child. > > Ah, so by =E2=80=9Csmallest subtree=E2=80=9D you basically mean =E2=80=9C= smallest non-leaf node=E2=80=9D? Hmm... I don't think so, tho I guess it depends on what is your notion of "node" and "leaf". In my book, "a =3D x + 1; b =3D y" is a tree of the form: ; / \ / \ =3D =3D /| |\ / | | \ a + b y / \ / \ x 1 So there is no ";" subtree at all (there is a subtree with ";" in its root but it contains all of "a =3D x + 1; b =3D y"). OTOH there is an "x" subtree and it would be the "smallest subtree" if we're immediately to the left of this "x" and we're doing a `forward-sexp`. So my "smallest subtree" can definitely be a "leaf node" since I consider "x" to be a leaf node. [ And the ";" node at the top can have N children, by the way. ] If point is to the left of the semi-colon, it can be considered to be: A) right after "1" B) right after "x + 1" C) right after "a =3D x + 1" But in order to be able to "move forward" you need to move up to the ";" node, so only C makes sense, and the smallest meaningful subtree over which we can move is the "b =3D y" subtree, since in order to move only over "b" we'd have to go down inside the "=3D" node, so we'd be moving over a subtree that's not connected to our starting node. Stefan