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

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

bug#61655: [Tree sitter] [Feature Request] font-lock function calls, def


From: Randy Taylor
Subject: bug#61655: [Tree sitter] [Feature Request] font-lock function calls, definitions, separately
Date: Sat, 25 Feb 2023 03:59:46 +0000

On Friday, February 24th, 2023 at 21:28, Dmitry Gutov <dgutov@yandex.ru> wrote:
> Hi Randy,
> 
> Thanks for the reply.
> 
> On 25/02/2023 03:06, Randy Taylor wrote:
> 
> > > Here's the patch which adds the faces and their uses in all ts modes.
> > > 
> > > Comments welcome from all the interested parties. The patch is mostly
> > > straightforward, but there are some changes added as well, where it was
> > > needed to differentiate between declarations and references.
> > > 
> > > The important question here, I think, is whether we want to split
> > > font-lock-property-faces in two, like I did here.
> > > 
> > > By analogy with the other faces, I think it's going to be useful to
> > > differentiate between property definitions and property references. Not
> > > many of the languages modes used font-lock-property-face for
> > > property/attribute definitions, but some did.
> > 
> > I'm not sure about the naming of font-lock-variable-ref-face. It's 
> > confusing for languages that support actual references like C++ and Rust.
> 
> 
> But even there "variable reference" is probably a suitable term for any
> occurrence of a variable other than its definition. While the references
> you're talking about are "value references".

It is a suitable term, but there is a confusing overlap, at least to me. In C++ 
parlance, for example, they are referred to as reference variables. I wasn't 
really getting down to the semantics of it, just when I see something like:

void quack(int& thing)
                ^^^^^
obj_t& thing2 = otherthing;
       ^^^^^^

Those are the things I would expect font-lock-variable-ref-face to highlight if 
I was just going off of the name, and I would expect many others to think the 
same.

> 
> > Maybe the opposite direction is better: font-lock-variable-def-face (or 
> > something similar) for definitions (or whatnot), and 
> > font-lock-variable-name-face to refer to uses (same goes for property). Or 
> > font-lock-variable-use-face. I don't know, naming is hard :).
> 
> 
> I, uh, pushed the change before I noticed your email. ^^;
> 
> But perhaps we could refine, if there is enough support.
> 
> Indeed, I was slightly uneasy about the -ref- names, if only because
> they might seem a little cryptic. Using the name -def-face is something
> I thought about too, but it sounded a bit like the name of a macro.
> 
> A bigger problem, though, is that existing themes customize
> font-lock-variable-name-face. So we'd have to create inheritance the
> other way around (for the themes to continue working unchanged). Or we'd
> have to create face alias and use a yet different name for "variable
> references" (or "uses", or whatever we'd call them).
> 
> Inheritance "the other way around" would break the usage scenario 1
> below for users of existing themes. Or at least make it more difficult.

I don't have any better ideas than font-lock-{property,variable}-use-face, so I 
guess we can see if anyone else has any opinions on the matter.

> 
> > Personally, I don't really see the value in differentiating these for 
> > variables. I can understand it a little more for properties. But I guess it 
> > doesn't hurt to add if folks want it.
> 
> 
> I see two potential uses:
> 
> 1. Customize treesit-font-lock-level to 4 but
> font-lock-variable-ref-face to copy 'default' (or close to it), to skip
> variable reference highlighting or make it less noticeable.

Wouldn't they just remove the variable feature if they want that?

> 
> 2. Pattern matching or comparably complex syntax which at a first glance
> may look like variable reference, but actually creates new bindings (or
> vice versa, creates new binding when one wanted to refer to an existing
> value).
> 
> Emphasizing the difference can help people, beginners especially [in a
> particular language].
>

No doubt there are uses, I just don't really see them actually getting much use 
in practice. But maybe I'm wrong :).





reply via email to

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