bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#67061: [PATCH] Improve syntax highlighting for python-ts-mode


From: Dmitry Gutov
Subject: bug#67061: [PATCH] Improve syntax highlighting for python-ts-mode
Date: Mon, 18 Dec 2023 01:38:46 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0

On 17/12/2023 03:56, Denis Zubarev wrote:
 > Do we want to have a common face which would inherit from
 > font-lock-variable-name-face and would be used solely for
 > function/methods parameters and nothing else? I don't object, but I
 > don't quite see the point either.
The point is to make it easy for users to customize faces of features
independently from each other.
It is not only about variables/parameters.

Granularity of faces can be increased, but one should also consider which nodes go together better with which others.

E.g. even if variable-assignment is a separate face, we would need to make it inherit from one of the more basic faces.

For example, if I want to change a face for decorators, I have to change
font-lock-type-face, which will change also all type faces.
I like approach from the helix editor. They introduce many captures with
different levels of specificity, for example @variable for (identifier),
@variable.parameter for function parameters, @variable.builtin for
self|cls etc. I guess by default the default face defined for a @variable
is used. But one can customize variable.parameter to their liking without touching any
other variables.
 > Then I suppose we should clarify whether Denis wants a face that only
 > matches function parameters, or implicit variable declarations as well.
 > Or maybe instead a face that is only used for assignments (only first
 > assignments?) -- which would separate them from the two semantic units
 > above.
I think ideally, there should be a face for a feature (or even multiple
faces).
For example, faces for variables in helix notation:
- @variable
- @variable.definition
- @variable.definition.parameter
- @variable.assignment
- @variable.use

I think this is fairly similar to our faces hierarchy, where children inherit attributes from the parent. Just using a shorter notation.

Going back to what is a good thing for highlighting assignments, I would separate "first assignments" from the rest, and either inherit their face from "variable definition", or simply used the same face. Only in languages like Python or Ruby, or course, where any first assignment is an implicit variable declaration.





reply via email to

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