Subject: Re: bug#79406: [PATCH] 31.0.50; csharp-ts-mode does not fontify variable-use consistently

From: Yuan Fu <[email-masked]>
Date: Tue, 9 Sep 2025 00:06:30 -0700

> On Sep 8, 2025, at 5:59 AM, Eli Zaretskii <[email-masked]> wrote:
> 
>> From: Jostein Kjønigsen <[email-masked]>
>> Date: Mon, 8 Sep 2025 14:50:23 +0200
>> Cc: [email-masked],
>> Yuan Fu <[email-masked]>
>> 
>> On 8 Sep 2025, at 13:14, Eli Zaretskii <[email-masked]> wrote:
>> 
>> Are all of these appropriate for the default value of
>> treesit-font-lock-level?  
>> 
>> I'll have to be honest and admit I haven't tested any major-mode in "default" fontification level in probably a
>> decade. My settings is maximum detail, and I've based my findings on that.
>> 
>> It may previously have been difficult to compartementalize some of these fontifications into different features
>> and levels (due to extensive use of override:t and rules being heavily order-dependent).
>> 
>> With the changes in this patch however, I can probably move some rules about if that's wanted. Anything in
>> particular you are thinking about?
> 
> Can you correlate the syntactic elements with the guidelines in the
> doc string of treesit-font-lock-level?
> 
>> I see that
>> csharp-ts-mode--font-lock-settings doesn't use the level at all -- is
>> that on purpose?
>> 
>> I'm not sure I'm following. We have the following LISP to configure tree-sitter for the different feature-levels?
>> 
>>  (setq-local treesit-font-lock-feature-list
>>              '(( comment definition)
>>                ( keyword string type directives)
>>                ( constant escape-sequence expression literal attribute)
>>                ( function bracket delimiter error)))
>> 
>> Can you provide a more concrete example of what you think is missing or inappropriate and I can try to
>> address that.
> 
> Hmm... maybe nothing.  Yuan, could you please see if anything is
> missing here?

Csharp-ts-mode is doing the right thing. Major modes don’t interact with treesit-font-lock-level directly. They just define font-lock rules categorized into features. And provide a feature list that’s split into levels. Emacs picks the features to enable based treesit-font-lock-level.

Most of the changes are good, I didn’t look into the rules themselves since I know Jostein is much more familiar to the grammar and C# than I do. I also like that we’re using less :override.

The only thing I’m not too sure about is the change from property to attribute. It’s technically a breaking change, I don’t think it’s “wait for 10 years to change it” level, but at least we should mention it in the NEWS. Also it seems you’re highlighting the brackets as well? Is there a particular reason to do that? And IMHO since attribute is metadata, property face is more suitable than variable-use face. But that’s subjective so it’s your call.

And there’s the small things like using full sentence for comments (period at the end) and the commit message format, those I can fix when applying the patch.

Yuan