unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Yuan Fu <casouri@gmail.com>
To: Ihor Radchenko <yantar92@gmail.com>
Cc: emacs-devel <emacs-devel@gnu.org>, Theodor Thornhill <theo@thornhill.no>
Subject: Re: Recent updates to tree-sitter branch
Date: Sat, 1 Oct 2022 20:46:05 -0700	[thread overview]
Message-ID: <59AE5D4B-39D2-4C18-BAC6-9C71B736F0D0@gmail.com> (raw)
In-Reply-To: <871qrs2mzl.fsf@localhost>



> 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	other threads:[~2022-10-02  3:46 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-25  4:27 Recent updates to tree-sitter branch Yuan Fu
2022-09-25  6:17 ` Ihor Radchenko
2022-09-26  8:35   ` Yuan Fu
2022-09-26  9:43     ` Ihor Radchenko
2022-09-27 22:28       ` Yuan Fu
2022-09-29  4:01         ` Ihor Radchenko
2022-09-30 21:03           ` Yuan Fu
2022-10-01  4:20             ` Ihor Radchenko
2022-10-02  3:46               ` Yuan Fu [this message]
2022-10-02  7:33                 ` Ihor Radchenko
2022-10-02 22:54                   ` Yuan Fu
2022-10-03  5:58                     ` Ihor Radchenko
2022-10-04 16:58                       ` Yuan Fu
2022-09-29 10:13 ` Aurélien Aptel

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=59AE5D4B-39D2-4C18-BAC6-9C71B736F0D0@gmail.com \
    --to=casouri@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=theo@thornhill.no \
    --cc=yantar92@gmail.com \
    /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).