1

The following Emacs Lisp you can set the background color of face whitespace-trailing:

(set-face-attribute 'whitespace-trailing nil :background "#ff0000" :foreground nil))

How can a face attribute be read back?


Asking since I'd like to temporarily change a face background color:
https://emacs.stackexchange.com/a/29166/2418

4

You can use face-attribute.

To match the example given, the following expression gets the trailing space background color:

(face-attribute 'whitespace-trailing :background)

face-attribute is a compiled Lisp function in `faces.el'.

(face-attribute FACE ATTRIBUTE &optional FRAME INHERIT)

:around advice: `ad-Advice-face-attribute'

Return the value of FACE's ATTRIBUTE on FRAME. If the optional argument FRAME is given, report on face FACE in that frame. If FRAME is t, report on the defaults for face FACE (for new frames). If FRAME is omitted or nil, use the selected frame.

If INHERIT is nil, only attributes directly defined by FACE are considered, so the return value may be unspecified, or a relative value. If INHERIT is non-nil, FACE's definition of ATTRIBUTE is merged with the faces specified by its :inherit attribute; however the return value may still be unspecified or relative. If INHERIT is a face or a list of faces, then the result is further merged with that face (or faces), until it becomes specified and absolute.

To ensure that the return value is always specified and absolute, use a value of default for INHERIT; this will resolve any unspecified or relative values by merging with the default face (which is always completely specified).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.