49.1.5 Customizing Faces
You can customize faces (see Faces), which determine how Emacs displays different types of text. Customization groups can contain both variables and faces.
For example, in programming language modes, source code comments are shown with font-lock-comment-face
(see Font Lock). In a customization buffer, that face appears like this, after you click on the ‘[Show All Attributes]
’ link:
[Hide] Font Lock Comment Face:[sample]
[State] : STANDARD.
Font Lock mode face used to highlight comments.
[ ] Font Family: --
[ ] Font Foundry: --
[ ] Width: --
[ ] Height: --
[ ] Weight: --
[ ] Slant: --
[ ] Underline: --
[ ] Overline: --
[ ] Strike-through: --
[ ] Box around text: --
[ ] Inverse-video: --
[X] Foreground: Firebrick [Choose] (sample)
[ ] Background: --
[ ] Stipple: --
[ ] Inherit: --
[Hide Unused Attributes]
The first three lines show the name, ‘[State]
’ button, and documentation for the face. Below that is a list of face attributes. In front of each attribute is a checkbox. A filled checkbox, ‘[X]
’, means that the face specifies a value for this attribute; an empty checkbox, ‘[ ]
’, means that the face does not specify any special value for the attribute. You can activate a checkbox to specify or unspecify its attribute.
A face does not have to specify every single attribute; in fact, most faces only specify a few attributes. In the above example, font-lock-comment-face
only specifies the foreground color. Any unspecified attribute is taken from the special face named default
, whose attributes are all specified. The default
face is the face used to display any text that does not have an explicitly-assigned face; furthermore, its background color attribute serves as the background color of the frame.
The ‘[Hide Unused Attributes]
’ button, at the end of the attribute list, hides the unspecified attributes of the face. When attributes are being hidden, the button changes to ‘[Show All Attributes]
’, which reveals the entire attribute list. The customization buffer may start out with unspecified attributes hidden, to avoid cluttering the interface.
When an attribute is specified, you can change its value in the usual ways.
Foreground and background colors can be specified using either color names or RGB triplets (see Colors). You can also use the ‘[Choose]
’ button to switch to a list of color names; select a color with RET
in that buffer to put the color name in the value field.
Setting, saving and resetting a face work like the same operations for variables (see Changing a Variable).
A face can specify different appearances for different types of displays. For example, a face can make text red on a color display, but use a bold font on a monochrome display. To specify multiple appearances for a face, select ‘For All Kinds of Displays
’ in the menu you get from invoking ‘[State]
’.