emacs-devel
[Top][All Lists]
Advanced

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

Re: Recent updates to tree-sitter branch


From: Yuan Fu
Subject: Re: Recent updates to tree-sitter branch
Date: Sat, 1 Oct 2022 20:46:05 -0700


> On Sep 30, 2022, at 9:20 PM, Ihor Radchenko <yantar92@gmail.com> wrote:
> 
> Yuan Fu <casouri@gmail.com> writes:
> 
>>> Will the currently matched node be passed to the function? Or should the
>>> function run yet another query to determine the node it was called on?
>> 
>> The matched node is passed to the function.
> 
> Thanks for the clarification! I missed this detail in the documentation.
> 
>>> OVERRIDE can also be 'prepend or 'append to combine faces from multiple
>>> nodes.
>> 
>> You can’t really pretend or append if the only face format we allow is 
>> symbol.
> 
> Why?
> 'prepend implies that if there is an existing font-lock-face, the new
> face will be prepended to it. Note the 'face text property may contain a
> list of faces:
> 
>    ‘face’
>         The ‘face’ property controls the appearance of the character (*note
>         Faces::).  The value of the property can be the following:
> 
>     ...
>             • A list of faces.  Each list element should be either a face
>              name or an anonymous face.  This specifies a face which is an
>              aggregate of the attributes of each of the listed faces.
>              Faces occurring earlier in the list have higher priority.

I see, yeah you are right.

>>> Also, OVERRIDE nil will not apply fontification on the already fontified
>>> parts of the region. Note that the parent node might only fontify
>>> fraction of the text inside the child node. The parts not yet fontified
>>> can make use of OVERRIDE nil.
>> 
>> Ok, I guess it’s good to have options. But I think it is more intuitive and 
>> convenient to override by default.
> 
> I disagree. The current default in font-lock-keywords is not to
> override. If programmatic font-lock behaves differently, it will be
> confusing.

I think the tree-sitter queries are different enough from font-lock keywords 
that it will not bring confusion. Further more, default to override should make 
things easier, especially to delicate things like string interpolation, or 
other nested constructs, where tree-sitter shines. By default, if the 
to-be-fontified region has any existing face, the whole fontification is given 
up instead of filling in new fontification. That would be IMO confusing because 
user would think the match failed.

Also bear in mind that the override flag can only be applied to the whole 
query, rather than individual captured nodes.

Yuan





reply via email to

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