emacs-devel
[Top][All Lists]
Advanced

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

Faces: How to clear an attribute while continuing to inherit other attri


From: Dave Goel
Subject: Faces: How to clear an attribute while continuing to inherit other attributes?
Date: Wed, 9 Oct 2019 22:42:50 -0400

How to unset an inherited face attribute while continuing to inherit other attributes?

Face 'a inherits from 'b, which sets foreground to yellow. How do I keep 'a inheriting from 'b, but set the foreground to (nothing), so that actually rendering 'a goes to the default foreground (white) instead of yellow?

Emacs allows us to set a's foreground to nil (instead of 'unspecified), but it magically becomes 'unspecified when queried. That's not what I was aiming for. That is because 'unspecified means actually rendering face 'a would yield yellow, the color inherited from 'b instead of the default foreground.

Here's a test:  

(progn
  (defface a nil "")
  (defface b nil "")
  (set-face-attribute  'b nil :foreground "yellow")
  (set-face-attribute 'a nil :inherit 'b)
  (set-face-attribute 'a nil :foreground nil)
  ;; let's chase how 'a would render:
  (face-attribute 'a :foreground nil t))

=> "yellow"

We expected either "white", the default foreground.


So, unfortunately, setting a's foreground to nil seems to be equivalent to setting a's foreground to 'unspecified. 

Once I set it to nil, I edebugged (face-attribute), and it calls  ' internal-get-lisp-face-attribute which yields 'unspecified instead of the expected nil.

(Please cc replies if you can. I tested all this with emacs24.)

Thanks
Dave


reply via email to

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