From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.devel Subject: Re: Plug treesit.el into other emacs constructs Date: Wed, 14 Dec 2022 00:14:12 -0800 Message-ID: <4E3940CA-67A6-45B7-8785-4E60FDECCDFB@gmail.com> References: <87wn6whete.fsf@thornhill.no> <87r0x3gnv5.fsf@thornhill.no> <04BB786A-3ED1-4918-8583-17AA01A1E453@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) 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="11199"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Theodor Thornhill , emacs-devel@gnu.org, eliz@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Dec 14 09:33:50 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 1p5ND2-0002h8-K4 for ged-emacs-devel@m.gmane-mx.org; Wed, 14 Dec 2022 09:33:48 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5MuD-00079i-RR; Wed, 14 Dec 2022 03:14:22 -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 1p5MuA-00075j-6M for emacs-devel@gnu.org; Wed, 14 Dec 2022 03:14:18 -0500 Original-Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p5Mu8-0000Cm-HK; Wed, 14 Dec 2022 03:14:17 -0500 Original-Received: by mail-pl1-x62f.google.com with SMTP id 4so2573849plj.3; Wed, 14 Dec 2022 00:14:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=IyZLkabz3QhCFg8Ku/ay3zxuSbSZW1XIydZIfPJYn8Q=; b=dJDvwuxcWT4uvNPjw5k9hP9FVpxDDk0DCPDv8YteWC6disqple5Ia4B6g2/pVZO2X5 lrRz5S4FnIubuEDwfy3PD2eTninhFao1ffIFcsPgH2E5n9HWKVke3+KcddN5r8TlGz5t 3YlSFz/z6Oyhjyju64UOTh72rctdb8jfOrTZuo5JKbDy+lmgJTKApG5N8tSRRXH25uAn KosCIsOlL7TZlaBi/D9PbgR4aQN2h2NUkbg/LEPjczIf+e0QRQWTDPKH7LR1kOyrQmZF vir02IviDqIV/CRuyc6QJoF+PWmFJ6kuHkuJrFc4zkl1M0BGQRA9ukC7ffIZiXXeLGly Ma3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IyZLkabz3QhCFg8Ku/ay3zxuSbSZW1XIydZIfPJYn8Q=; b=uFGWkNjv6I8KyRJ11CYLuYoSjUH3PWV+1tzXLjDda0kBcfFo3s82ODaRdYpVosilkN +Dgb7SSO5Q8gl1x9JxGndgaTVVw/7sRc+wKDYnlNmmFUNA5bGYMrSWFTUCjMr7tEFTpt 6iZCayG8YGR+aXO+xAAygAEp49LExAROXHttwRzLe+Fhn3wThLLWXYV62H51GmYiYutU XyEBE42WHXBDmfcK6C1X92zbJBw+kAEn9pZPziKZrLztinEKoSY7a3vMlk47lpAm6u8T F/TjO9/VlHL9jRwkxvQr9OuFwrzagh41TSGrOqTEpMSiGJFxktkbNTn2wz5TGMs011Gn gNdg== X-Gm-Message-State: ANoB5pkuG+Cc8PdzVHeICLO3SRXSUrueLgn12KoSR0zV+BjOi3Vc7nvj k3irgTo/poxoC9dztPV0IbA= X-Google-Smtp-Source: AA0mqf4r1DwlCtPN0lJ3ZJcma3JAti19NxAZsPmN6xC9fZv4gYgsXrkj1G6gc6RXoW+b53QnT59iNw== X-Received: by 2002:a17:902:d510:b0:185:441e:90ae with SMTP id b16-20020a170902d51000b00185441e90aemr33779739plg.20.1671005654309; Wed, 14 Dec 2022 00:14:14 -0800 (PST) Original-Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id k5-20020a170902c40500b001766a3b2a26sm1228678plk.105.2022.12.14.00.14.13 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Dec 2022 00:14:13 -0800 (PST) In-Reply-To: X-Mailer: Apple Mail (2.3696.120.41.1.1) Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=casouri@gmail.com; helo=mail-pl1-x62f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.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, RCVD_IN_DNSWL_NONE=-0.0001, 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:301372 Archived-At: > On Dec 13, 2022, at 3:19 PM, Stefan Monnier = wrote: >=20 >>>> I mean, what construct is each one expected to jump over? >>> In my book "sexp" movement should jump over subtrees of the AST. >> It=E2=80=99s pretty hard to judge which subtree to move over at a = given point in an >> AST. For example, when point is at | in the following text: >>=20 >> (|X.y(z), alpha) >>=20 >> Should point move over X, or X.y, or X.y(z)? All three subtrees has = their >> beg=3D(point). >=20 > Exactly. It's even a bit worse: I'd also argue that an additional = valid > choice is to move over the whole "X.y(z), alpha". >=20 > The semantics I opted for in SMIE is to choose the smallest/deepest > subtree. That's what best matches the previous behavior of > `forward-sexp`. If the users want to move over larger units they have > to place their point elsewhere (e.g. if it's just before ".", then > moving over "y" wouldn't make sense because "y" is attached to "y(z)" > and not to ".", only "y(z)" is attached to "."). I would argue that the purpose of forward-sexp is to move over items in = a list. Always going for the smallest subtree doesn=E2=80=99t seem to = align with it. Take that example above, going across the smallest = subtree means moving over X, then moving over =E2=80=9C.=E2=80=9D, that = doesn=E2=80=99t feel like what forward-sexp should do to me. I think I'm = misunderstanding what you mean. >=20 >> Just a thought, but maybe we can let major modes define what=E2=80=99s = an =E2=80=9Cabstract >> list=E2=80=9D, and sexp-forward would move across the immediate = children of abstract >> lists. Eg, abstract lists in C would contain block, argument list, >> statement, etc. And in the example above forward-sexp would move = across >> X.y(z) because it=E2=80=99s an immediate children of the enclosing = abstract list, >> the argument list. >=20 > Using the semantics I advocate, the user needs to place his point just > to the left of `;` in order for `forward-sexp` to jump over the next > instruction (or to the right of the `;` in order to jump over the > previous instruction with `backward-sexp`). You mean in the following code int a =3D 0[1]; int b =3D 1;[2] Forward-sexp would move [1] to [2]? But if we move over the smallest = subtree, I=E2=80=99d imagine it only move across the semicolon after = [1]. Even if it moves from [1] to [2], needing to adjust point feels = very inconvenient to me, at least I wouldn=E2=80=99t want to use = something like that. I want to type a single binding and move to where I = want, and type that binding multiple times to move multiple steps. Both = doesn=E2=80=99t seem to be possible with what you described. Yuan