emacs-devel
[Top][All Lists]
Advanced

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

Re: Status update of tree-sitter features


From: Mickey Petersen
Subject: Re: Status update of tree-sitter features
Date: Wed, 28 Dec 2022 15:40:23 +0000
User-agent: mu4e @VERSION@; emacs 30.0.50

Yuan Fu <casouri@gmail.com> writes:

> Hi,
>
> As the complete feature freeze approaching, this is probably the last set of 
> features added to Emacs 29. I stuffed  them in just in time ;-)
>
> 1. There is a new predicate in the query language, #pred. It’s like #equal 
> and #match. Basically it allows you to filter the captured node with an 
> arbitrary function. Right now there are some queries in the font-lock 
> settings that matches a little more than what we actually want. For example, 
> for the property feature, we only want the “bb” in “aa.bb”, but not in 
> “aa.bb(cc)”, because the latter is a method, not property. The query usually 
> matches both. With this new predicate we can use a function to filter out the 
> methods.
>
> If we can ensure that every query only captures the intended nodes, the 
> font-lock queries can be reused for context extraction: using the query for 
> the variable feature, I can find all the variables in a given region, etc.
>

Looks useful. But this, I think, goes back to the issue I raised with you in an 
email: that queries are recursive, as each query is (I pressume this is how it 
is done in tree-sitter) applied to each node in the tree. That makes it very 
hard to build a query that pattern matches against nested nodes only once. It 
is very hard, when you have recursive queries with self-similar matches, to 
filter out recursed matches. Particularly when you are writing generic code 
that merely acts on the output of arbitrary queries.

#pred is surely no different to applying `seq-filter' or similar to the query 
result, no?



reply via email to

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