emacs-devel
[Top][All Lists]
Advanced

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

Re: Tree-sitter integration in python.el


From: Stefan Monnier
Subject: Re: Tree-sitter integration in python.el
Date: Tue, 11 Oct 2022 18:15:22 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

>>> The complaint for font-lock-maximum-decoration is that it’s obscure and
>>> too corse-grained. So my idea is for each major mode to provide
>>> fined-grained controls like
>>> python-fontify-type/f-string/assignment/built-in/etc. And tree-sitter
>>> makes it easy to implement this kind of toggle. But I guess a global
>>> control is also nice, I can make tree-sitter respect
>>> font-lock-maximum-decoration, in addition to the fined grained
>>> local-control.
>> 
>> I think having tree-sitter respect font-lock-maximum-decoration would
>> be good, because it allows a major-mode agnostic way of controlling
>> fontifications.  With tree-sitter in mind, we'd need to agree on what
>> kind of syntactic entities are included in each level (which is also a
>> Good Thing, because currently what is level N of font-lock is entirely
>> up to the major-mode, AFAIU).
>
> I think it is difficult to define syntactic entities for each level such
> that it is generally enough to include all kinds of major mode out there,
> and specific enough to be useful. It is easy for common programming
> languages, but hard for others like html, css, prolog, etc.

How 'bout:

- Major modes provide a list of available fontification "features"
  in a buffer-local variable like `treesit-font-lock-features`
  e.g. `(type f-string assignment built-in ...)`.
- the list of features is *ordered* so that
  the user can control the fontification via a Customizable
  `treesit-font-lock-level` that can be set between 0 and 100 to
  select the corresponding proportion of features.
- Users can additionally enable/disable those features individually via
  some `treesit-font-lock-control` variable.


        Stefan




reply via email to

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