[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Plug treesit.el into other emacs constructs
From: |
Stefan Monnier |
Subject: |
Re: Plug treesit.el into other emacs constructs |
Date: |
Wed, 14 Dec 2022 23:37:15 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
>> 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”?
Hmm... I don't think so, tho I guess it depends on what is your notion
of "node" and "leaf". In my book, "a = x + 1; b = y" is a tree of the
form:
;
/ \
/ \
= =
/| |\
/ | | \
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 = x + 1; b = 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 = 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 = y" subtree, since in order to move
only over "b" we'd have to go down inside the "=" node, so we'd be
moving over a subtree that's not connected to our starting node.
Stefan
- Re: Plug treesit.el into other emacs constructs, (continued)
- Re: Plug treesit.el into other emacs constructs, Theodor Thornhill, 2022/12/26
- Re: Plug treesit.el into other emacs constructs, Lynn Winebarger, 2022/12/27
- Re: Plug treesit.el into other emacs constructs, Yuan Fu, 2022/12/14
- Re: Plug treesit.el into other emacs constructs, Yuan Fu, 2022/12/14
- Re: Plug treesit.el into other emacs constructs, Eli Zaretskii, 2022/12/15
- Re: Plug treesit.el into other emacs constructs, Theodor Thornhill, 2022/12/15
- Re: Plug treesit.el into other emacs constructs,
Stefan Monnier <=
- Re: Plug treesit.el into other emacs constructs, Theodor Thornhill, 2022/12/15
- Re: Plug treesit.el into other emacs constructs, Yuan Fu, 2022/12/15
- Re: Plug treesit.el into other emacs constructs, Theodor Thornhill, 2022/12/15
- Re: Plug treesit.el into other emacs constructs, Theodor Thornhill, 2022/12/13
- Re: Plug treesit.el into other emacs constructs, Stefan Monnier, 2022/12/13
Re: Plug treesit.el into other emacs constructs, Stephen Leake, 2022/12/14