all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Theodor Thornhill <theo@thornhill.no>
To: Stefan Monnier <monnier@iro.umontreal.ca>, Yuan Fu <casouri@gmail.com>
Cc: emacs-devel@gnu.org, eliz@gnu.org
Subject: Re: Plug treesit.el into other emacs constructs
Date: Wed, 14 Dec 2022 17:24:52 +0100	[thread overview]
Message-ID: <EAAEC1C8-303C-4D9E-A6DE-A1C96101E0FB@thornhill.no> (raw)
In-Reply-To: <jwv359i85ii.fsf-monnier+emacs@gnu.org>



On 14 December 2022 15:01:55 CET, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>> I would argue that the purpose of forward-sexp is to move over items in
>> a list.
>
>There are different ways to look at it.  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.
>
>The semantics I chose for SMIE is what I found to be closest to
>past practice.
>
>> Always going for the smallest subtree doesn’t seem to align with it.
>> Take that example above, going across the smallest subtree means
>> moving over X, then moving over “.”,
>
>No: when you're left of ".", as in "(X|.y(z), alpha)", the SMIE
>semantics of `forward-sexp` moves over ".y(z)", i.e. to
>"(X.y(z)|, alpha)"
>
>> that doesn’t feel like what forward-sexp should do to me.
>
>Indeed, moving just over "." would be very far from my understanding of
>what `forward-sexp` intends to do.
>
>> You mean in the following code
>>
>> int a = 0[1];
>> int b = 1;[2]
>>
>> Forward-sexp would move [1] to [2]?
>
>No, SMIE's `forward-sexp` moves from
>
>    int a = 0|;
>    int b = 1;
>
>to
>
>    int a = 0;
>    int b = 1|;
>
>[ You can try it by installing Tuareg and moving around in an OCaml
>  file, for example.  ]
>
>and when moving backward it moves from
>
>    int a = 0;
>    int b = 1;|
>
>to
>
>    int a = 0;|
>    int b = 1;
>
>> But if we move over the smallest
>> subtree, I’d imagine it only move across the semicolon after [1].
>

Doesn't this look like forward-sentence?


>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.
>
>> Even if it moves from [1] to [2], needing to adjust point feels very
>> inconvenient to me, at least I wouldn’t want to use something
>> like that.
>
>Moving point is the way to tell SMIE's `forward-sexp` which level of the tree
>we want to navigate.  I don't believe Emacs can reliably guess the right
>level, and I don't believe choosing an arbitrary level for the users
>serves them best either.  I can imagine other ways to specify the
>intended tree level, tho: maybe we could have a kind of prefix command
>for that.  E.g. a new command that would work a bit like `C-M-u` (or its
>younger sibling `expand-region`) but would only affect the next sexp
>command instead.
>
>> I want to type a single binding and move to where I want, and
>> type that binding multiple times to move multiple steps.
>
>I don't think a single binding can always jump to where you want.
>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.
>
>
>        Stefan
>



  reply	other threads:[~2022-12-14 16:24 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-12 14:33 Plug treesit.el into other emacs constructs Theodor Thornhill
2022-12-12 14:45 ` Eli Zaretskii
2022-12-13 18:17   ` Theodor Thornhill
2022-12-12 15:46 ` Stefan Monnier
2022-12-13 18:27   ` Theodor Thornhill
2022-12-13 19:37     ` Stefan Monnier
2022-12-13 19:53       ` Yuan Fu
2022-12-13 20:06         ` Perry Smith
2022-12-13 23:19         ` Stefan Monnier
2022-12-14  8:14           ` Yuan Fu
2022-12-14  8:42             ` Theodor Thornhill
2022-12-14 14:01             ` Stefan Monnier
2022-12-14 16:24               ` Theodor Thornhill [this message]
2022-12-14 17:46                 ` Stefan Monnier
2022-12-14 18:07                   ` Theodor Thornhill
2022-12-14 19:25                     ` Stefan Monnier
2022-12-14 19:35                       ` Stefan Monnier
2022-12-14 20:04                       ` Theodor Thornhill
2022-12-14 20:50                         ` Stefan Monnier
2022-12-14 21:15                           ` Theodor Thornhill
2022-12-14 21:34                             ` Stefan Monnier
2022-12-15 19:37                               ` Theodor Thornhill
2022-12-15 19:56                                 ` Stefan Monnier
2022-12-15 20:03                                   ` Theodor Thornhill
2022-12-15 20:33                                     ` Theodor Thornhill
2022-12-15 20:57                                       ` Theodor Thornhill
2022-12-24  7:00                                         ` Eli Zaretskii
2022-12-24  8:44                                           ` Yuan Fu
2022-12-24 14:01                                         ` Stefan Monnier
2022-12-24 14:15                                           ` Theodor Thornhill
2022-12-26 19:11                                             ` Theodor Thornhill
2022-12-26 22:46                                               ` Stefan Monnier
2022-12-26 22:51                                                 ` Stefan Monnier
2022-12-27 22:15                                                   ` Theodor Thornhill via Emacs development discussions.
2022-12-28  0:12                                                     ` Stefan Monnier
2022-12-28  9:26                                                       ` Theodor Thornhill via Emacs development discussions.
2022-12-28 18:01                                                         ` Stefan Monnier
2022-12-28 18:27                                                           ` Theodor Thornhill
2022-12-26 22:56                                                 ` Theodor Thornhill
2022-12-27 15:46                                   ` Lynn Winebarger
2022-12-14 23:31               ` Yuan Fu
2022-12-15  0:05                 ` Yuan Fu
2022-12-15  7:09                   ` Eli Zaretskii
2022-12-15  7:14                     ` Theodor Thornhill
2022-12-15  4:37                 ` Stefan Monnier
2022-12-15  5:59                 ` Theodor Thornhill
2022-12-15 21:23                   ` Yuan Fu
2022-12-15 21:28                     ` Theodor Thornhill
2022-12-13 20:02       ` Theodor Thornhill
2022-12-13 23:10         ` Stefan Monnier
2022-12-14 23:32   ` Stephen Leake
2022-12-16 10:02     ` Kévin Le Gouguec
2022-12-16 11:54       ` [SPAM UNSURE] " Stephen Leake
2022-12-17 15:30         ` Kévin Le Gouguec

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=EAAEC1C8-303C-4D9E-A6DE-A1C96101E0FB@thornhill.no \
    --to=theo@thornhill.no \
    --cc=casouri@gmail.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.