GNU bug report logs -
#68899
Treesitter's forward-sexp-function
Previous Next
Reported by: João Távora <joaotavora <at> gmail.com>
Date: Fri, 2 Feb 2024 21:49:01 UTC
Severity: normal
Fixed in version 30.1
Done: Yuan Fu <casouri <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
Message #20 received at 68899 <at> debbugs.gnu.org (full text, mbox):
> On Feb 4, 2024, at 4:40 AM, João Távora <joaotavora <at> gmail.com> wrote:
>
> On Sun, Feb 4, 2024 at 5:35 AM Yuan Fu <casouri <at> gmail.com> wrote:
>
>> Thanks for looking into this, Joao. IME a very useful characteristic of forward-sexp is that it stays in the same “level” and doesn’t go up automatically when there’s no siblings (when there’s a closing delimiter). Eg, in an Elisp buffer, forward-sexp stops at the closing parenthesis, in C, it should stop at the closing bracket.
>
> I agree. There are other useful characteristics, but this is one of them.
> It allows be to mark regions of text up to points that I'm not even seeing.
>
>> Also you don’t want to check for prev when moving forward, and vice
>> versa, ie, we don’t want to check (null next) and (null prev) together.
>
> I get it. I used those existing results as a proxy to know if we're
> in the middle
> of a leaf. I _think_ it's sound (maybe I'm wrong).
>
>> So, how do you like this patch:
>
> It works fine, but as far as I can tell does exactly the same as mine, and
> looks to be slightly more difficult to read and uses a further treesit
> query to check if this is a leaf node. But it's absolutley fine really.
>
> One way my patch can be described in plain english is
> "if we're not at an inter-thing boundary, we navigate to such boundary"
> And then the meaning of checking prev _and_ next becomes obvious
> and it isn't necessary to perform the additional check that we're in a
> leaf node.
>
> So go ahead and push whichever patch you prefer, and thanks.
>
> João
Initially I was worried about the case below:
void main (void) {
<point>
}<will move to here>
But I get you now; if we define “leaf thing” as not having any nested child thing, and we allow ourselves to move to the end of leaf thing, then in this case we indeed should move out of the closing bracket. I like your definition of “leaf thing” better since it’s more general than “leaf node”, and I like the simpler code too.
So applied your patch with some comments added, thanks!
Yuan
This bug report was last modified 1 year and 102 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.