[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The way to define a new face is with defface
. This creates a
kind of customization item (see section 14. Writing Customization Definitions) which the user can
customize using the Customization buffer (see section `Easy Customization' in The GNU Emacs Manual).
defface
are the same ones that are meaningful in both
defgroup
and defcustom
(see section 14.1 Common Item Keywords).
When defface
executes, it defines the face according to
spec, then uses any customizations that were read from the
init file (see section 40.1.2 The Init File, `.emacs') 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)
. Each element's CAR,
display, specifies a class of terminals. The element's second element,
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
graphic
(any
graphics-capable display), x
, pc
(for the MS-DOS console),
w32
(for MS Windows 9X/NT), or tty
(a non-graphics-capable
display).
class
color
,
grayscale
, or mono
.
background
light
or dark
.
If an element of display specifies more than one value for a given characteristic, any of those values is acceptable. If display has more than one element, each element should specify a different characteristic; then each characteristic of the frame must match one of the values specified for it in display.
Here's how the standard face region
is defined:
(defface region `((((type tty) (class color)) (:background "blue" :foreground "white")) (((type tty) (class mono)) (:inverse-video t)) (((class color) (background dark)) (:background "blue")) (((class color) (background light)) (:background "lightblue")) (t (:background "gray"))) "Basic face for highlighting the region." :group 'basic-faces) |
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.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |