This section describes the functions for accessing and modifying the attributes of an existing face.
This function sets one or more attributes of face for frame. The attributes you specify this way override whatever the
deffacesays.The extra arguments arguments specify the attributes to set, and the values for them. They should consist of alternating attribute names (such as
:familyor:underline) and corresponding values. Thus,(set-face-attribute 'foo nil :width 'extended :weight 'bold :underline "red")sets the attributes
:width,:weightand:underlineto the corresponding values.If frame is
t, this function sets the default attributes for new frames. Default attribute values specified this way override thedeffacefor newly created frames.If frame is
nil, this function sets the attributes for all existing frames, and the default for new frames.
This returns the value of the attribute attribute of face on frame. If frame is
nil, that means the selected frame (see Input Focus).If frame is
t, this returns whatever new-frames default value you previously specified withset-face-attributefor the attribute attribute of face. If you have not specified one, it returnsnil.If inherit is
nil, only attributes directly defined by face are considered, so the return value may beunspecified, or a relative value. If inherit is non-nil, face's definition of attribute is merged with the faces specified by its:inheritattribute; however the return value may still beunspecifiedor 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
defaultfor inherit; this will resolve any unspecified or relative values by merging with thedefaultface (which is always completely specified).For example,
(face-attribute 'bold :weight) ⇒ bold
This function returns non-
nilif value, when used as the value of the face attribute attribute, is relative. This means it would modify, rather than completely override, any value that comes from a subsequent face in the face list or that is inherited from another face.
unspecifiedis a relative value for all attributes. For:height, floating point and function values are also relative.For example:
(face-attribute-relative-p :height 2.0) ⇒ t
This function returns an alist of attributes of face. The elements of the result are name-value pairs of the form
(attr-name.attr-value). Optional argument frame specifies the frame whose definition of face to return; if omitted ornil, the returned value describes the default attributes of face for newly created frames.
If value1 is a relative value for the face attribute attribute, returns it merged with the underlying value value2; otherwise, if value1 is an absolute value for the face attribute attribute, returns value1 unchanged.
The following functions provide compatibility with Emacs 20 and
below. They work by calling set-face-attribute. Values of
t and nil for their frame argument are handled
just like set-face-attribute and face-attribute.
These functions set the
:foregroundattribute (or:backgroundattribute, respectively) of face to color.
This function sets the
:stippleattribute of face to pattern.
This function sets the
:fontattribute of face to font.
This function sets the
:weightattribute of face to normal if bold-p isnil, and to bold otherwise.
This function sets the
:slantattribute of face to normal if italic-p isnil, and to italic otherwise.
This function sets the
:underlineattribute of face to underline.
This function sets the
:inverse-videoattribute of face to inverse-video-p.
This function swaps the foreground and background colors of face face.
The following functions examine the attributes of a face. If you
don't specify frame, they refer to the selected frame; t
refers to the default data for new frames. They return the symbol
unspecified if the face doesn't define any value for that
attribute.
These functions return the foreground color (or background color, respectively) of face face, as a string.
If inherit is
nil, only a color directly defined by the face is returned. If inherit is non-nil, any faces specified by its:inheritattribute are considered as well, and if inherit is a face or a list of faces, then they are also considered, until a specified color is found. To ensure that the return value is always specified, use a value ofdefaultfor inherit.
This function returns the name of the background stipple pattern of face face, or
nilif it doesn't have one.If inherit is
nil, only a stipple directly defined by the face is returned. If inherit is non-nil, any faces specified by its:inheritattribute are considered as well, and if inherit is a face or a list of faces, then they are also considered, until a specified stipple is found. To ensure that the return value is always specified, use a value ofdefaultfor inherit.
This function returns a non-
nilvalue if the:weightattribute of face is bolder than normal (i.e., one ofsemi-bold,bold,extra-bold, orultra-bold). Otherwise, it returnsnil.
This function returns a non-
nilvalue if the:slantattribute of face isitalicoroblique, andnilotherwise.
This function returns the
:underlineattribute of face face.
This function returns the
:inverse-videoattribute of face face.