Subject: bug#72691: closed (Re: bug#72691: Recursive descent in treesiter parse tree)

From: [email-masked] (GNU bug Tracking System)
Date: Sat, 31 Aug 2024 08:14:02 +0000

Your bug report

#72691: Recursive descent in treesiter parse tree

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
72691: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=72691
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#72691: Recursive descent in treesiter parse tree
From: Eli Zaretskii <[email-masked]>
To: Yuan Fu <[email-masked]>
Cc: [email-masked], [email-masked]
Date: Sat, 31 Aug 2024 11:12:23 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

> From: Yuan Fu <[email-masked]>
> Date: Mon, 19 Aug 2024 20:38:16 -0700
> Cc: Eli Zaretskii <[email-masked]>,
>  [email-masked]
> 
> 
> 
> > On Aug 18, 2024, at 7:57 AM, Pranshu Sharma <[email-masked]> wrote:
> > 
> > Ok, I found the solution: you have to capture  witha function and traverse the whole tree recursively
> 
> As you’ve found out, tree-sitter’s query system doesn’t support the feature you want (it’ll be quite expensive to implement, I think). Even if you’ve found a solution, if you want, maybe you can describe your actual use-case and I can check if your solution is the most optimal.

No further comments, so I'm now closing this bug.

Subject: Recursive descent in treesiter parse tree
From: Pranshu Sharma <[email-masked]>
To: [email-masked]
Date: Sun, 18 Aug 2024 14:57:10 +1000
List-Id: <debbugs-submit.debbugs.gnu.org>

Hello all,

I am trying to write a major mode in which all instances of a node in
another matched node. For this, recursion is needed, and for that it is
necessary to store a match in a variable:
Say I want to highlight all instances of (x) that are inside y in the
following parse tree, where bolded means I want to match:
(x) in (q (y (*x*) (l (*x*) (l (*x*) (p))) (x))

"(y) @test
        @test . (_) @font-lock-variable-name-face"
"(y) @test
        (@test . (_) @font-lock-variable-name-face)"
"(y) @test
        (test . (_) @font-lock-variable-name-face)"

All of the above fail, which leads me to think that @test stores the text
instead of the tree. In this case, how would I recursively match all
instances of