emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Plug treesit.el into other emacs constructs


From: Yuan Fu
Subject: Re: Plug treesit.el into other emacs constructs
Date: Wed, 14 Dec 2022 15:31:20 -0800


> On Dec 14, 2022, at 6:01 AM, 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.

I see, so maybe sexp means the general, flexible AST entity. And thinking of 
it, my idea is just forward-list :-) And we definitely should include 
forward-list into the list of navigation commands we want to support, among the 
ones that are already brought up.

> 
> The semantics I chose for SMIE is what I found to be closest to
> past practice.

That’ great! You’ve done all the experiments and thinking, and all I need to do 
is to understand it ;-)

>> But if we move over the smallest
>> subtree, I’d imagine it only move across the semicolon after [1].
> 
> 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 “smallest subtree” you basically mean “smallest non-leaf node”? Is 
the following logic what you have in mind?

forward-sexp:
Among all nodes that starts right after point:
1. if we can find a smallest non-leaf node
   -> skip over it
2. if we can only find leaf node
   -> go to the end of the immediate (smallest) parent node
      that covers point, and skip over its next sibling (by recursively 
applying either 1 or 2)

Yuan


reply via email to

[Prev in Thread] Current Thread [Next in Thread]