Function: face-attribute
face-attribute is a byte-compiled function defined in faces.el.gz.
Signature
(face-attribute FACE ATTRIBUTE &optional FRAME INHERIT)
Documentation
Return the value of FACE's ATTRIBUTE on FRAME.
See set-face-attribute for the list of supported attributes
and their meanings and allowed values.
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).
Probably introduced at or before Emacs version 21.1.
Source Code
;; Defined in /usr/src/emacs/lisp/faces.el.gz
(defun face-attribute (face attribute &optional frame inherit)
"Return the value of FACE's ATTRIBUTE on FRAME.
See `set-face-attribute' for the list of supported attributes
and their meanings and allowed values.
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)."
(let ((value (internal-get-lisp-face-attribute face attribute frame)))
(when (and inherit (face-attribute-relative-p attribute value))
;; VALUE is relative, so merge with inherited faces
(let ((inh-from (face-attribute face :inherit frame)))
(unless (or (null inh-from) (eq inh-from 'unspecified))
(condition-case nil
(setq value
(face-attribute-merged-with attribute value inh-from frame))
;; The `inherit' attribute may point to non existent faces.
(error nil)))))
(when (and inherit
(not (eq inherit t))
(face-attribute-relative-p attribute value))
;; We should merge with INHERIT as well
(setq value (face-attribute-merged-with attribute value inherit frame)))
value))