[ < ] | [ > ] | [ << ] | [Plus haut] | [ >> ] | [Top] | [Table des matières] | [Index] | [ ? ] |
The way to define a new face is with defface
. This creates a kind of
customization item (voir la section Writing Customization Definitions) which the user can customize
using the Customization buffer (voir (emacs)Easy Customization section `Easy Customization' dans The GNU Emacs Manual).
This declares face as a customizable face that defaults according to
spec. You should not quote the symbol face, and it should not
end in ‘-face’ (that would be redundant). The argument doc
specifies the face documentation. The keywords you can use in
defface
are the same as in defgroup
and defcustom
(voir la section Common Item Keywords).
When defface
executes, it defines the face according to spec,
then uses any customizations that were read from the init file (voir la section 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 first element, if its
CAR is default
, is special—it specifies defaults for the
remaining elements). The element's CADR, 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 matches. If more than one element of spec matches a given frame, the first element that matches is the one used for that frame. There are three possibilities for display:
default
This element of spec doesn't match any frames; instead, it specifies defaults that apply to all frames. This kind of element, if used, must be the first element of spec. Each of the following elements can override any or all of these defaults.
t
This element of spec matches all frames. Therefore, any subsequent
elements of spec are never used. Normally t
is used in the
last (or only) element of spec.
If display is a list, each element should have the form
(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
The kind of window system the frame uses—either graphic
(any
graphics-capable display), x
, pc
(for the MS-DOS console),
w32
(for MS Windows 9X/NT/2K/XP), mac
(for the Macintosh
display), or tty
(a non-graphics-capable display). Voir la section window-system.
class
What kinds of colors the frame supports—either color
,
grayscale
, or mono
.
background
The kind of background—either light
or dark
.
min-colors
An integer that represents the minimum number of colors the frame should
support. This matches a frame if its display-color-cells
value is at
least the specified integer.
supports
Whether or not the frame can display the face attributes given in
value… (voir la section Face Attributes). See the documentation for the
function display-supports-face-attributes-p
for more information on
exactly how this testing is done. Voir Display Face Attribute Testing.
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 '((((class color) (min-colors 88) (background dark)) :background "blue3") (((class color) (min-colors 88) (background light)) :background "lightgoldenrod2") (((class color) (min-colors 16) (background dark)) :background "blue3") (((class color) (min-colors 16) (background light)) :background "lightgoldenrod2") (((class color) (min-colors 8)) :background "blue" :foreground "white") (((type tty) (class mono)) :inverse-video t) (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,
customized-face
for the attributes customized by the user for the
current session, but not saved, and face-documentation
for the
documentation string.
This option, if non-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.
[ < ] | [ > ] | [ << ] | [Plus haut] | [ >> ] | [Top] | [Table des matières] | [Index] | [ ? ] |
Ce document a été généré par Eric Reinbold le 13 Octobre 2007 en utilisant texi2html 1.78.