From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Theodor Thornhill Newsgroups: gmane.emacs.devel Subject: Re: Plug treesit.el into other emacs constructs Date: Wed, 14 Dec 2022 17:24:52 +0100 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> 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="27716"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org, eliz@gnu.org To: Stefan Monnier , Yuan Fu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Dec 14 17:25:57 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 1p5UZw-0006tc-74 for ged-emacs-devel@m.gmane-mx.org; Wed, 14 Dec 2022 17:25:56 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5UZA-0005Zn-9Z; Wed, 14 Dec 2022 11:25:08 -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 1p5UZ8-0005ZZ-AR for emacs-devel@gnu.org; Wed, 14 Dec 2022 11:25:06 -0500 Original-Received: from out2.migadu.com ([188.165.223.204]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p5UZ5-0005VD-2W; Wed, 14 Dec 2022 11:25:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1671035098; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=c+EHQX/Ubmjj4VtZKixCROQ+x6b4g4YsfxbTfWd/4l8=; b=RaJ3yEVh9+LBHU9gHrhiZFMAggPalkpCnB5y5Ogeo/FFs7gjIkxp7+3Y9WlAAAr7F96l/Y xre9my+blzjcRRAYxahr+CwqSLrywhbJnIt+Cp2d3+ia1jgTEyBbovOQDFR3vIybHcRADY brVGdhQL82+Ezedge+XfhLZsLcvR5VgU2gzIhfq9CLdcq4XnkZtwu+GHP6i4NHNezIxEE9 xcGA+Qb7/W5KNwKkqjiBrWr5F43sR+h7ID0dTTWLv3i0GUZUcRUiLgI9/AKdFhDMGP2oeo ebGCRwSubEo1jD9BeVADGXS89JuP/2zswOxAgNuEtR0PLg+8QFVQHmmk37JnLQ== X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. In-Reply-To: X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=188.165.223.204; envelope-from=theo@thornhill.no; helo=out2.migadu.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, SPF_HELO_PASS=-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:301398 Archived-At: On 14 December 2022 15:01:55 CET, Stefan Monnier wrote: >> I would argue that the purpose of forward-sexp is to move over items in >> a list=2E > >There are different ways to look at it=2E In the Lisp context where it >emerged, we only have "identifiers" and "parenthesized thingies", so >that doesn't give much guidance about what to do in-between=2E > >The semantics I chose for SMIE is what I found to be closest to >past practice=2E > >> Always going for the smallest subtree doesn=E2=80=99t seem to align wit= h it=2E >> Take that example above, going across the smallest subtree means >> moving over X, then moving over =E2=80=9C=2E=E2=80=9D, > >No: when you're left of "=2E", as in "(X|=2Ey(z), alpha)", the SMIE >semantics of `forward-sexp` moves over "=2Ey(z)", i=2Ee=2E to >"(X=2Ey(z)|, alpha)" > >> that doesn=E2=80=99t feel like what forward-sexp should do to me=2E > >Indeed, moving just over "=2E" would be very far from my understanding of >what `forward-sexp` intends to do=2E > >> You mean in the following code >> >> int a =3D 0[1]; >> int b =3D 1;[2] >> >> Forward-sexp would move [1] to [2]? > >No, SMIE's `forward-sexp` moves from > > int a =3D 0|; > int b =3D 1; > >to > > int a =3D 0; > int b =3D 1|; > >[ You can try it by installing Tuareg and moving around in an OCaml > file, for example=2E ] > >and when moving backward it moves from > > int a =3D 0; > int b =3D 1;| > >to > > int a =3D 0;| > int b =3D 1; > >> But if we move over the smallest >> subtree, I=E2=80=99d imagine it only move across the semicolon after [1= ]=2E > Doesn't this look like forward-sentence? >In my view ";" is not a substree=2E It's the node of a substree=2E >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=2E > >> 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=2E > >Moving point is the way to tell SMIE's `forward-sexp` which level of the = tree >we want to navigate=2E I don't believe Emacs can reliably guess the righ= t >level, and I don't believe choosing an arbitrary level for the users >serves them best either=2E I can imagine other ways to specify the >intended tree level, tho: maybe we could have a kind of prefix command >for that=2E E=2Eg=2E a new command that would work a bit like `C-M-u` (o= r its >younger sibling `expand-region`) but would only affect the next sexp >command instead=2E > >> I want to type a single binding and move to where I want, and >> type that binding multiple times to move multiple steps=2E > >I don't think a single binding can always jump to where you want=2E >That would require magic :-) > >But yes, SMIE's `forward-sexp` does work well when repeated to jump over >N instructions, it was indeed an important design goal=2E > > > Stefan >