unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Yuan Fu <casouri@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 60983@debbugs.gnu.org, theo@thornhill.no
Subject: bug#60983: 29.0.60; Tree-sitter user-level control
Date: Sat, 4 Feb 2023 23:54:56 -0800	[thread overview]
Message-ID: <1CC382C7-8663-4F12-9163-916EE1FFCFBB@gmail.com> (raw)
In-Reply-To: <83zg9sslat.fsf@gnu.org>



> On Feb 4, 2023, at 10:01 PM, Eli Zaretskii <eliz@gnu.org> wrote:
> 
>> From: Yuan Fu <casouri@gmail.com>
>> Date: Sat, 4 Feb 2023 15:38:17 -0800
>> Cc: Bug Report Emacs <bug-gnu-emacs@gnu.org>,
>> theo@thornhill.no
>> 
>>> treesit-font-lock-recompute-features is a non-interactive function, so
>>> mentioning it in the user manual is generally inappropriate.  Users
>>> are unlikely to add features that aren't already defined in the mode's
>>> font-lock setup.
>>> 
>>> This function and its use in these situations are described in the
>>> ELisp manual, where I think it belongs.
>>> 
>>> As for the fact that changing treesit-font-lock-feature-list directly
>>> doesn't have any effect, that is already in the doc string.  I'm not
>>> opposed to mentioning that in the manual as well, but I see no problem
>>> with what we have.
>> 
>> I see. Sounds good to me. I meant enabling/disabling features when I say “adding/removing” features. Does that make anything different?
> 
> Yes, that's how I understood what you were saying: changing the list
> of features enabled/disabled by specific levels.  This is not a
> user-level thing, so describing it in the ELisp manual is good enough,
> I think.  (If it turns out users want to do this kind of thing too
> often, it probably means our design of the user-facing features is
> sub-optimal and should be improved.)

I see, my description and the documentation is still not clear enough, I’m afraid. treesit-font-lock-recompute-feature does not add/remove features that belongs to a level. The design is that, the user uses decoration level to set the rough level, which enables a set of features, then use treesit-font-lock-recompute-feature to do more fine-grained control by additionally enabling/disabling features. 

For example in c-ts-mode, if I set the decoration level to 2, I’d have these features: comment, definition, keyword, preprocessor, string, type. If I also want the assignment features, which is in level 3, but don’t want other features in level 3, I would use treesit-font-lock-recompute-feature to enable that feature. Similarly, I can use treesit-font-lock-recompute-feature to disable the preprocessor which is at level 2, without affecting other features status.


Yuan






  reply	other threads:[~2023-02-05  7:54 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-21 11:11 bug#60983: 29.0.60; Tree-sitter user-level control Eli Zaretskii
2023-01-21 11:48 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-21 12:36   ` Eli Zaretskii
2023-01-21 12:40     ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-23 19:37       ` Yuan Fu
2023-01-23 19:59         ` Eli Zaretskii
2023-01-23 21:08           ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-23 23:55             ` Yuan Fu
2023-01-29 13:33               ` Eli Zaretskii
2023-01-29 19:12                 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-29 19:41                   ` Eli Zaretskii
2023-01-30  2:28                     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-30 13:45                       ` Eli Zaretskii
2023-01-24  3:26             ` Eli Zaretskii
2023-01-25 20:12               ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-25 21:16                 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-26  8:27                   ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-26  6:08                 ` Eli Zaretskii
2023-01-26  6:25                   ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-23 16:52   ` Eli Zaretskii
2023-01-26  7:27     ` Eli Zaretskii
2023-01-26  7:37       ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-26  9:08         ` Eli Zaretskii
2023-01-28 13:12       ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-28 13:25         ` Eli Zaretskii
2023-01-28 18:41           ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-29 13:24             ` Eli Zaretskii
2023-01-26  7:56 ` Yuan Fu
2023-02-03  3:07 ` Yuan Fu
2023-02-03  7:47   ` Eli Zaretskii
2023-02-04 23:38     ` Yuan Fu
2023-02-05  6:01       ` Eli Zaretskii
2023-02-05  7:54         ` Yuan Fu [this message]
2023-02-05  9:23           ` Eli Zaretskii
2023-02-05  9:42             ` Yuan Fu

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=1CC382C7-8663-4F12-9163-916EE1FFCFBB@gmail.com \
    --to=casouri@gmail.com \
    --cc=60983@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=theo@thornhill.no \
    /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).