emacs-devel
[Top][All Lists]
Advanced

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

RE: faces and face variables


From: Drew Adams
Subject: RE: faces and face variables
Date: Sat, 13 Sep 2008 15:43:09 -0700

> I looked up defface in the elisp manual in order to find a hint. But
> there was none. So I suggest to mention there (or include a link
> pointing elsewhere) that such variables are deprecated.
> 
> > > Font-lock also has such variables, and the code contains 
> > > the comment that these variables
> > 
> > Don't use font-lock as an example, it's a law unto itself for
> > historical reasons.
> 
> As I said, the starting point for me was dired.el. Certainly, that
> code has its own history. But the bottom line is that there is more
> than one source for the "wrong inspiration" and it would be good if
> at some prominent point it was stated clearly what today's
> recommended strategy is (despite historical counter examples).
> 
> Are there, besides font-lock and dired, other fossils in GNU emacs
> that still use such variables?

Dunno, maybe there are. If so, they should be removed.

But I don't agree that face variables are or should be "deprecated" or that all
uses of face variables are necessarily "fossils". 

Yes, the message to users should be that you normally do not want to create face
variables - use faces directly instead. But that doesn't mean that face
variables should never be used. This is what I wrote last February (thread
"Default font 'default have no corresponding variable"):

> > Maybe we should work harder to document the fact that we do not want
> > such variables.  Where would such info have reached you better?
> > 
> > How about if we put comments in and among the variable 
> > definitions in font-lock.el saying not to imitate that practice.
> 
> I think the place to discuss this is in the Elisp manual, in 
> one of the sections about faces. This is really about
> understanding what a face is, IMO.
> 
> FWIW, I have a slightly different take on the practice to 
> recommend and the reasons to give for that recommendation. 
> 
> I agree with the recommended practice of defining and using 
> faces, not face variables, in general - and I follow it.
> However, I don't agree that the only case for defining and
> using face variables is the legacy case of the font-lock code. 
> 
> The use case I see, which, again, is not the usual case, is 
> when you want to make it easy for code to temporarily use a
> particular face. It is very easy for some code to dynamically
> bind a face variable and cause subsequently executed code to
> use that face. Getting the same effect with faces (without
> a face variable) can make for uglier code, IMO.
> 
> Just one opinion. I'm not interested in arguing about that.
> I agree that we should make it clear that you generally
> should not define face variables. And I think the place to
> communicate that guideline is the Elisp doc, not just
> comments in the code.

FWIW, Richard replied:

> I agree that this would be a good reason to have such a variable.
> Whether there are such cases, I don't know.

What's important, I think, is to propagate the general recommendation together
with its rationale. That is, help users understand what faces are, which is what
this is about. If all we provide is a catechism, then all we can expect is rote
learning with little understanding.

IOW, let's not confuse the effort to remove such fossils from the Emacs code
with the idea that no one should ever use face variables. Use them in the (rare)
cases where they are useful; don't use them otherwise.






reply via email to

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