From: Yuan Fu <casouri@gmail.com>
To: Danny Freeman <danny@dfreeman.email>
Cc: emacs-devel <emacs-devel@gnu.org>
Subject: Re: Treesit Regression In ec4d29c4494f32acf0ff7c5632a1d951d957f084
Date: Sun, 10 Sep 2023 00:12:16 -0700 [thread overview]
Message-ID: <945F818F-AA9B-402B-BCC7-53286EAD2C05@gmail.com> (raw)
In-Reply-To: <107166BF-6EC2-4D13-9BA4-A6C0DE1CA565@gmail.com>
> On Sep 9, 2023, at 10:26 PM, Yuan Fu <casouri@gmail.com> wrote:
>
>
>
>> On Sep 9, 2023, at 9:00 PM, Danny Freeman <danny@dfreeman.email> wrote:
>>
>>
>> Yuan Fu <casouri@gmail.com> writes:
>>>
>>> Hmmm, I can’t reproduce this. I’m getting
>>>
>>> Matched rule: ((parent-is "source") parent-bol 0)
>>> Matched rule: (clojure-ts--match-expression-in-body parent 2)
>>>
>>> The commit you pointed to does change treesit-node-parent, so it does match with parent-is matcher not working.
>>>
>>> Might be because I recently upgraded to a newer tree-sitter library. If you compile with the newest tree-sitter build (from their repo), do you still see this problem?
>>
>> Before I was just using whatever tree-sitter version my distro packages.
>> Apparently v0.20.8 (built from the git tag of the same name)
>>
>> I tried compiling with this version
>> https://github.com/tree-sitter/tree-sitter/commit/524bf7e2c664d4a5dbd0c20d4d10f1e58f99e8ce
>>
>> which at the time of writing is the latest, and still experience the
>> same problem. I also made sure to re-compile my grammars.
>>
>> I may have done something wrong though when building. I'm
>> going to try to build using a more traditional process rather than with
>> nix and see if that helps.
>>
>> Thank you,
>> --
>> Danny Freeman
>
> I take that back. It is indeed caused by that commit. I just had a wrong Emacs build when testing. In that commit, ts_tree_cursor_goto_first_child_for_byte seem to be the problem.
>
> Yuan
What I found is that, for some reason, ts_tree_cursor_goto_first_child_for_byte doesn’t always work as expected in clojure [1]. In your example, if I evaluate (treesit-node-parent (treesit-node-at (point))) with point at the beginning of “defn”, “foo”, “[]”, and “1”, only “defn” correctly evaluates to the parent node. I tried this in other modes like c-ts-mode, but things seems to work fine in all the few cases I tried.
So now the question is, is there anything tree-sitter-clojure does differently? Not saying it does, but that seems like a starting point.
[1] Instead of returning the first child node of NODE that extends beyond POS, ts_tree_cursor_goto_first_child_for_byte (NODE, POS) returns false (meaning not found).
Yuan
next prev parent reply other threads:[~2023-09-10 7:12 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-09 19:26 Treesit Regression In ec4d29c4494f32acf0ff7c5632a1d951d957f084 Danny Freeman
2023-09-10 1:15 ` Yuan Fu
2023-09-10 4:00 ` Danny Freeman
2023-09-10 5:26 ` Yuan Fu
2023-09-10 7:12 ` Yuan Fu [this message]
2023-09-11 12:41 ` Danny Freeman
2023-09-11 22:19 ` Yuan Fu
2023-09-12 3:49 ` Danny Freeman
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=945F818F-AA9B-402B-BCC7-53286EAD2C05@gmail.com \
--to=casouri@gmail.com \
--cc=danny@dfreeman.email \
--cc=emacs-devel@gnu.org \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).