The way to define a new face is with defface
. This creates a
kind of customization item (see section Writing Customization Definitions) which the user can
customize using the Customization buffer (see section `Easy Customization' in The GNU Emacs Manual).
When defface
executes, it defines the face according to
spec, then uses any customizations that were read from the
`.emacs' file to override that specification.
The purpose of spec is to specify how the face should appear on
different kinds of terminals. It should be an alist whose elements have
the form (display atts)
. The element's CAR,
display, specifies a class of terminals. The CDR,
atts, is a list of face attributes and their values; it specifies
what the face should look like on that kind of terminal. The possible
attributes are defined in the value of custom-face-attributes
.
The display part of an element of spec determines which frames the element applies to. If more than one element of spec matches a given frame, the first matching element is the only one used for that frame. There are two possibilities for display:
t
t
is used in the last (or only) element of spec.
(characteristic value...)
. Here
characteristic specifies a way of classifying frames, and the
values are possible classifications which display should
apply to. Here are the possible values of characteristic:
type
x
, pc
(for the MS-DOS console), w32
(for MS Windows 9X/NT), or
tty
.
class
color
,
grayscale
, or mono
.
background
light
or dark
.
Here's how the standard face region
could be defined
with defface
:
(defface region ((((class color) (background dark)) (:background "blue")) (t (:background "gray"))) "Used for displaying the region.")
Internally, defface
uses the symbol property
face-defface-spec
to record the face attributes specified in
defface
, saved-face
for the attributes saved by the user
with the customization buffer, and face-documentation
for the
documentation string.
nil
, specifies the background type to use for
interpreting face definitions. If it is dark
, then Emacs treats
all frames as if they had a dark background, regardless of their actual
background colors. If it is light
, then Emacs treats all frames
as if they had a light background.
Go to the first, previous, next, last section, table of contents.