emacs-devel
[Top][All Lists]
Advanced

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

Re: Faces: How to clear an attribute while continuing to inherit other a


From: Eli Zaretskii
Subject: Re: Faces: How to clear an attribute while continuing to inherit other attributes?
Date: Thu, 10 Oct 2019 21:07:46 +0300

> From: Dave Goel <address@hidden>
> Date: Thu, 10 Oct 2019 13:50:33 -0400
> Cc: address@hidden
> 
> Of course, but that runs counter to the philosophy of inheritance. If you 
> changed the default, you have to then
> go back and change all such faces. 

Not if your code does

  (set-face-foreground FACE (face-foreground 'default))

With this, if the default face changes the color, FACE will follow
suit.

You could also try inheriting from both default and another face,
although I'm not sure this will do what you want (as I don't yet have
a clear idea of what you are trying to do)

> Again, if it was something like :underline or :bold or :height, you wouldn't 
> see this problem: setting them to nil
> would remove any inheritance, and then, whenever you change the 'default 
> face, your face's final resolved
> value automatically uses that.   

That's because for boolean attributes nil is a valid value, whereas
valid values for colors are strings, so nil isn't valid and is taken
as unspecified.

You must understand that face inheritance is a one-way street: Emacs
merges all the faces in the chain starting from default and going down
the inheritance chain, so the last face in the chain that specifies a
color wins.

> It seems that :fg and :bg also try to implement precisely that (providing a 
> nil option as well as 'unspecified),
> but then don't do the final step correctly.

I don't see anything incorrect in what you describe, it is all
expected behavior.

> It seems that the design of faces goes out of its way to carefully 
> distinguish nil from 'unspecified, precisely to
> allow you to clear an attribute..

See above: I think your conclusion is wrong.



reply via email to

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