1 ;;; faces.el --- Lisp faces
3 ;; Copyright (C) 1992,1993,1994,1995,1996,1998,1999,2000,2001,2002,2004
4 ;; Free Software Foundation, Inc.
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
32 ;; Warning suppression -- can't require x-win in batch:
33 (autoload 'xw-defined-colors
"x-win"))
36 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
38 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
40 (defgroup font-selection nil
41 "Influencing face font selection."
45 (defcustom face-font-selection-order
46 '(:width
:height
:weight
:slant
)
47 "*A list specifying how face font selection chooses fonts.
48 Each of the four symbols `:width', `:height', `:weight', and `:slant'
49 must appear once in the list, and the list must not contain any other
50 elements. Font selection tries to find a best matching font for
51 those face attributes first that appear first in the list. For
52 example, if `:slant' appears before `:height', font selection first
53 tries to find a font with a suitable slant, even if this results in
54 a font height that isn't optimal."
55 :tag
"Font selection order"
56 :type
'(list symbol symbol symbol symbol
)
57 :group
'font-selection
58 :set
#'(lambda (symbol value
)
59 (set-default symbol value
)
60 (internal-set-font-selection-order value
)))
63 ;; This is defined originally in xfaces.c.
64 (defcustom face-font-family-alternatives
66 ("helv" "helvetica" "arial" "fixed"))
67 "*Alist of alternative font family names.
68 Each element has the form (FAMILY ALTERNATIVE1 ALTERNATIVE2 ...).
69 If fonts of family FAMILY can't be loaded, try ALTERNATIVE1, then
71 :tag
"Alternative font families to try"
72 :type
'(repeat (repeat string
))
73 :group
'font-selection
74 :set
#'(lambda (symbol value
)
75 (set-default symbol value
)
76 (internal-set-alternative-font-family-alist value
)))
79 ;; This is defined originally in xfaces.c.
80 (defcustom face-font-registry-alternatives
81 (if (eq system-type
'windows-nt
)
82 '(("iso8859-1" "ms-oemlatin")
83 ("gb2312.1980" "gb2312")
84 ("jisx0208.1990" "jisx0208.1983" "jisx0208.1978")
85 ("ksc5601.1989" "ksx1001.1992" "ksc5601.1987")
86 ("muletibetan-2" "muletibetan-0"))
87 '(("gb2312.1980" "gb2312.80&gb8565.88" "gbk*")
88 ("jisx0208.1990" "jisx0208.1983" "jisx0208.1978")
89 ("ksc5601.1989" "ksx1001.1992" "ksc5601.1987")
90 ("muletibetan-2" "muletibetan-0")))
91 "*Alist of alternative font registry names.
92 Each element has the form (REGISTRY ALTERNATIVE1 ALTERNATIVE2 ...).
93 If fonts of registry REGISTRY can be loaded, font selection
94 tries to find a best matching font among all fonts of registry
95 REGISTRY, ALTERNATIVE1, ALTERNATIVE2, and etc."
96 :tag
"Alternative font registries to try"
97 :type
'(repeat (repeat string
))
99 :group
'font-selection
100 :set
#'(lambda (symbol value
)
101 (set-default symbol value
)
102 (internal-set-alternative-font-registry-alist value
)))
106 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
107 ;;; Creation, copying.
108 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
112 "Return a list of all defined face names."
113 (mapcar #'car face-new-frame-defaults
))
116 ;;; ### If not frame-local initialize by what X resources?
118 (defun make-face (face &optional no-init-from-resources
)
119 "Define a new face with name FACE, a symbol.
120 NO-INIT-FROM-RESOURCES non-nil means don't initialize frame-local
121 variants of FACE from X resources. (X resources recognized are found
122 in the global variable `face-x-resources'.) If FACE is already known
123 as a face, leave it unmodified. Value is FACE."
124 (interactive "SMake face: ")
126 ;; Make frame-local faces (this also makes the global one).
127 (dolist (frame (frame-list))
128 (internal-make-lisp-face face frame
))
129 ;; Add the face to the face menu.
130 (when (fboundp 'facemenu-add-new-face
)
131 (facemenu-add-new-face face
))
132 ;; Define frame-local faces for all frames from X resources.
133 (unless no-init-from-resources
134 (make-face-x-resource-internal face
)))
138 (defun make-empty-face (face)
139 "Define a new, empty face with name FACE.
140 If the face already exists, it is left unmodified. Value is FACE."
141 (interactive "SMake empty face: ")
142 (make-face face
'no-init-from-resources
))
145 (defun copy-face (old-face new-face
&optional frame new-frame
)
146 "Define a face just like OLD-FACE, with name NEW-FACE.
148 If NEW-FACE already exists as a face, it is modified to be like
149 OLD-FACE. If it doesn't already exist, it is created.
151 If the optional argument FRAME is given as a frame, NEW-FACE is
152 changed on FRAME only.
153 If FRAME is t, the frame-independent default specification for OLD-FACE
154 is copied to NEW-FACE.
155 If FRAME is nil, copying is done for the frame-independent defaults
156 and for each existing frame.
158 If the optional fourth argument NEW-FRAME is given,
159 copy the information from face OLD-FACE on frame FRAME
160 to NEW-FACE on frame NEW-FRAME."
161 (let ((inhibit-quit t
))
164 (dolist (frame (frame-list))
165 (copy-face old-face new-face frame
))
166 (copy-face old-face new-face t
))
167 (internal-copy-lisp-face old-face new-face frame new-frame
))
172 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
173 ;;; Obsolete functions
174 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
176 ;; The functions in this section are defined because Lisp packages use
177 ;; them, despite the prefix `internal-' suggesting that they are
178 ;; private to the face implementation.
180 (defun internal-find-face (name &optional frame
)
181 "Retrieve the face named NAME.
182 Return nil if there is no such face.
183 If the optional argument FRAME is given, this gets the face NAME for
184 that frame; otherwise, it uses the selected frame.
185 If FRAME is the symbol t, then the global, non-frame face is returned.
186 If NAME is already a face, it is simply returned."
188 (make-obsolete 'internal-find-face
'facep
"21.1")
191 (defun internal-get-face (name &optional frame
)
192 "Retrieve the face named NAME; error if there is none.
193 If the optional argument FRAME is given, this gets the face NAME for
194 that frame; otherwise, it uses the selected frame.
195 If FRAME is the symbol t, then the global, non-frame face is returned.
196 If NAME is already a face, it is simply returned."
199 (make-obsolete 'internal-get-face
"see `facep' and `check-face'." "21.1")
202 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
203 ;;; Predicates, type checks.
204 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
207 "Return non-nil if FACE is a face name."
208 (internal-lisp-face-p face
))
211 (defun check-face (face)
212 "Signal an error if FACE doesn't name a face.
215 (error "Not a face: %s" face
))
219 ;; The ID returned is not to be confused with the internally used IDs
220 ;; of realized faces. The ID assigned to Lisp faces is used to
221 ;; support faces in display table entries.
223 (defun face-id (face &optional frame
)
224 "Return the internal ID of face with name FACE.
225 The optional argument FRAME is ignored, since the internal face ID
226 of a face name is the same for all frames."
231 (defun face-equal (face1 face2
&optional frame
)
232 "Non-nil if faces FACE1 and FACE2 are equal.
233 Faces are considered equal if all their attributes are equal.
234 If the optional argument FRAME is given, report on FACE1 and FACE2 in that frame.
235 If FRAME is t, report on the defaults for FACE1 and FACE2 (for new frames).
236 If FRAME is omitted or nil, use the selected frame."
237 (internal-lisp-face-equal-p face1 face2 frame
))
240 (defun face-differs-from-default-p (face &optional frame
)
241 "Return non-nil if FACE displays differently from the default face.
242 If the optional argument FRAME is given, report on face FACE in that frame.
243 If FRAME is t, report on the defaults for face FACE (for new frames).
244 If FRAME is omitted or nil, use the selected frame."
246 '(:family
:width
:height
:weight
:slant
:foreground
247 :foreground
:background
:underline
:overline
248 :strike-through
:box
:inverse-video
))
250 (while (and attrs
(not differs
))
251 (let* ((attr (pop attrs
))
252 (attr-val (face-attribute face attr frame t
)))
254 (not (eq attr-val
'unspecified
))
255 (display-supports-face-attributes-p (list attr attr-val
)
257 (setq differs attr
))))
261 (defun face-nontrivial-p (face &optional frame
)
262 "True if face FACE has some non-nil attribute.
263 If the optional argument FRAME is given, report on face FACE in that frame.
264 If FRAME is t, report on the defaults for face FACE (for new frames).
265 If FRAME is omitted or nil, use the selected frame."
266 (not (internal-lisp-face-empty-p face frame
)))
270 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
271 ;;; Setting face attributes from X resources.
272 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
274 (defcustom face-x-resources
275 '((:family
(".attributeFamily" .
"Face.AttributeFamily"))
276 (:width
(".attributeWidth" .
"Face.AttributeWidth"))
277 (:height
(".attributeHeight" .
"Face.AttributeHeight"))
278 (:weight
(".attributeWeight" .
"Face.AttributeWeight"))
279 (:slant
(".attributeSlant" .
"Face.AttributeSlant"))
280 (:foreground
(".attributeForeground" .
"Face.AttributeForeground"))
281 (:background
(".attributeBackground" .
"Face.AttributeBackground"))
282 (:overline
(".attributeOverline" .
"Face.AttributeOverline"))
283 (:strike-through
(".attributeStrikeThrough" .
"Face.AttributeStrikeThrough"))
284 (:box
(".attributeBox" .
"Face.AttributeBox"))
285 (:underline
(".attributeUnderline" .
"Face.AttributeUnderline"))
286 (:inverse-video
(".attributeInverse" .
"Face.AttributeInverse"))
288 (".attributeStipple" .
"Face.AttributeStipple")
289 (".attributeBackgroundPixmap" .
"Face.AttributeBackgroundPixmap"))
290 (:bold
(".attributeBold" .
"Face.AttributeBold"))
291 (:italic
(".attributeItalic" .
"Face.AttributeItalic"))
292 (:font
(".attributeFont" .
"Face.AttributeFont"))
293 (:inherit
(".attributeInherit" .
"Face.AttributeInherit")))
294 "*List of X resources and classes for face attributes.
295 Each element has the form (ATTRIBUTE ENTRY1 ENTRY2...) where ATTRIBUTE is
296 the name of a face attribute, and each ENTRY is a cons of the form
297 \(RESOURCE . CLASS) with RESOURCE being the resource and CLASS being the
298 X resource class for the attribute."
299 :type
'(repeat (cons symbol
(repeat (cons string string
))))
303 (defun set-face-attribute-from-resource (face attribute resource class frame
)
304 "Set FACE's ATTRIBUTE from X resource RESOURCE, class CLASS on FRAME.
305 Value is the attribute value specified by the resource, or nil
306 if not present. This function displays a message if the resource
307 specifies an invalid attribute."
308 (let* ((face-name (face-name face
))
309 (value (internal-face-x-get-resource (concat face-name resource
)
313 (internal-set-lisp-face-attribute-from-resource
314 face attribute
(downcase value
) frame
)
316 (message "Face %s, frame %s: invalid attribute %s %s from X resource"
317 face-name frame attribute value
))))
321 (defun set-face-attributes-from-resources (face frame
)
322 "Set attributes of FACE from X resources for FRAME."
323 (when (memq (framep frame
) '(x w32 mac
))
324 (dolist (definition face-x-resources
)
325 (let ((attribute (car definition
)))
326 (dolist (entry (cdr definition
))
327 (set-face-attribute-from-resource face attribute
(car entry
)
328 (cdr entry
) frame
))))))
331 (defun make-face-x-resource-internal (face &optional frame
)
332 "Fill frame-local FACE on FRAME from X resources.
333 FRAME nil or not specified means do it for all frames."
335 (dolist (frame (frame-list))
336 (set-face-attributes-from-resources face frame
))
337 (set-face-attributes-from-resources face frame
)))
341 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
342 ;;; Retrieving face attributes.
343 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
345 (defun face-name (face)
346 "Return the name of face FACE."
347 (symbol-name (check-face face
)))
350 (defun face-attribute (face attribute
&optional frame inherit
)
351 "Return the value of FACE's ATTRIBUTE on FRAME.
352 If the optional argument FRAME is given, report on face FACE in that frame.
353 If FRAME is t, report on the defaults for face FACE (for new frames).
354 If FRAME is omitted or nil, use the selected frame.
356 If INHERIT is nil, only attributes directly defined by FACE are considered,
357 so the return value may be `unspecified', or a relative value.
358 If INHERIT is non-nil, FACE's definition of ATTRIBUTE is merged with the
359 faces specified by its `:inherit' attribute; however the return value
360 may still be `unspecified' or relative.
361 If INHERIT is a face or a list of faces, then the result is further merged
362 with that face (or faces), until it becomes specified and absolute.
364 To ensure that the return value is always specified and absolute, use a
365 value of `default' for INHERIT; this will resolve any unspecified or
366 relative values by merging with the `default' face (which is always
367 completely specified)."
368 (let ((value (internal-get-lisp-face-attribute face attribute frame
)))
369 (when (and inherit
(face-attribute-relative-p attribute value
))
370 ;; VALUE is relative, so merge with inherited faces
371 (let ((inh-from (face-attribute face
:inherit frame
)))
372 (unless (or (null inh-from
) (eq inh-from
'unspecified
))
374 (face-attribute-merged-with attribute value inh-from frame
)))))
377 (face-attribute-relative-p attribute value
))
378 ;; We should merge with INHERIT as well
379 (setq value
(face-attribute-merged-with attribute value inherit frame
)))
382 (defun face-attribute-merged-with (attribute value faces
&optional frame
)
383 "Merges ATTRIBUTE, initially VALUE, with faces from FACES until absolute.
384 FACES may be either a single face or a list of faces.
385 \[This is an internal function]"
386 (cond ((not (face-attribute-relative-p attribute value
))
391 (face-attribute-merged-with
393 (face-attribute-merged-with attribute value
(car faces
) frame
)
397 (merge-face-attribute attribute
399 (face-attribute faces attribute frame t
)))))
402 (defmacro face-attribute-specified-or
(value &rest body
)
403 "Return VALUE, unless it's `unspecified', in which case evaluate BODY and return the result."
404 (let ((temp (make-symbol "value")))
405 `(let ((,temp
,value
))
406 (if (not (eq ,temp
'unspecified
))
410 (defun face-foreground (face &optional frame inherit
)
411 "Return the foreground color name of FACE, or nil if unspecified.
412 If the optional argument FRAME is given, report on face FACE in that frame.
413 If FRAME is t, report on the defaults for face FACE (for new frames).
414 If FRAME is omitted or nil, use the selected frame.
416 If INHERIT is nil, only a foreground color directly defined by FACE is
417 considered, so the return value may be nil.
418 If INHERIT is t, and FACE doesn't define a foreground color, then any
419 foreground color that FACE inherits through its `:inherit' attribute
420 is considered as well; however the return value may still be nil.
421 If INHERIT is a face or a list of faces, then it is used to try to
422 resolve an unspecified foreground color.
424 To ensure that a valid color is always returned, use a value of
425 `default' for INHERIT; this will resolve any unspecified values by
426 merging with the `default' face (which is always completely specified)."
427 (face-attribute-specified-or (face-attribute face
:foreground frame inherit
)
430 (defun face-background (face &optional frame inherit
)
431 "Return the background color name of FACE, or nil if unspecified.
432 If the optional argument FRAME is given, report on face FACE in that frame.
433 If FRAME is t, report on the defaults for face FACE (for new frames).
434 If FRAME is omitted or nil, use the selected frame.
436 If INHERIT is nil, only a background color directly defined by FACE is
437 considered, so the return value may be nil.
438 If INHERIT is t, and FACE doesn't define a background color, then any
439 background color that FACE inherits through its `:inherit' attribute
440 is considered as well; however the return value may still be nil.
441 If INHERIT is a face or a list of faces, then it is used to try to
442 resolve an unspecified background color.
444 To ensure that a valid color is always returned, use a value of
445 `default' for INHERIT; this will resolve any unspecified values by
446 merging with the `default' face (which is always completely specified)."
447 (face-attribute-specified-or (face-attribute face
:background frame inherit
)
450 (defun face-stipple (face &optional frame inherit
)
451 "Return the stipple pixmap name of FACE, or nil if unspecified.
452 If the optional argument FRAME is given, report on face FACE in that frame.
453 If FRAME is t, report on the defaults for face FACE (for new frames).
454 If FRAME is omitted or nil, use the selected frame.
456 If INHERIT is nil, only a stipple directly defined by FACE is
457 considered, so the return value may be nil.
458 If INHERIT is t, and FACE doesn't define a stipple, then any stipple
459 that FACE inherits through its `:inherit' attribute is considered as
460 well; however the return value may still be nil.
461 If INHERIT is a face or a list of faces, then it is used to try to
462 resolve an unspecified stipple.
464 To ensure that a valid stipple or nil is always returned, use a value of
465 `default' for INHERIT; this will resolve any unspecified values by merging
466 with the `default' face (which is always completely specified)."
467 (face-attribute-specified-or (face-attribute face
:stipple frame inherit
)
471 (defalias 'face-background-pixmap
'face-stipple
)
474 (defun face-underline-p (face &optional frame
)
475 "Return non-nil if FACE is underlined.
476 If the optional argument FRAME is given, report on face FACE in that frame.
477 If FRAME is t, report on the defaults for face FACE (for new frames).
478 If FRAME is omitted or nil, use the selected frame."
479 (eq (face-attribute face
:underline frame
) t
))
482 (defun face-inverse-video-p (face &optional frame
)
483 "Return non-nil if FACE is in inverse video on FRAME.
484 If the optional argument FRAME is given, report on face FACE in that frame.
485 If FRAME is t, report on the defaults for face FACE (for new frames).
486 If FRAME is omitted or nil, use the selected frame."
487 (eq (face-attribute face
:inverse-video frame
) t
))
490 (defun face-bold-p (face &optional frame
)
491 "Return non-nil if the font of FACE is bold on FRAME.
492 If the optional argument FRAME is given, report on face FACE in that frame.
493 If FRAME is t, report on the defaults for face FACE (for new frames).
494 If FRAME is omitted or nil, use the selected frame.
495 Use `face-attribute' for finer control."
496 (let ((bold (face-attribute face
:weight frame
)))
497 (memq bold
'(semi-bold bold extra-bold ultra-bold
))))
500 (defun face-italic-p (face &optional frame
)
501 "Return non-nil if the font of FACE is italic on FRAME.
502 If the optional argument FRAME is given, report on face FACE in that frame.
503 If FRAME is t, report on the defaults for face FACE (for new frames).
504 If FRAME is omitted or nil, use the selected frame.
505 Use `face-attribute' for finer control."
506 (let ((italic (face-attribute face
:slant frame
)))
507 (memq italic
'(italic oblique
))))
511 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
512 ;;; Face documentation.
513 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
515 (defun face-documentation (face)
516 "Get the documentation string for FACE."
517 (get face
'face-documentation
))
520 (defun set-face-documentation (face string
)
521 "Set the documentation string for FACE to STRING."
522 ;; Perhaps the text should go in DOC.
523 (put face
'face-documentation
(purecopy string
)))
526 (defalias 'face-doc-string
'face-documentation
)
527 (defalias 'set-face-doc-string
'set-face-documentation
)
531 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
532 ;; Setting face attributes.
533 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
536 (defun set-face-attribute (face frame
&rest args
)
537 "Set attributes of FACE on FRAME from ARGS.
539 FRAME nil means change attributes on all frames. FRAME t means change
540 the default for new frames (this is done automatically each time an
541 attribute is changed on all frames).
543 ARGS must come in pairs ATTRIBUTE VALUE. ATTRIBUTE must be a valid
544 face attribute name. All attributes can be set to `unspecified';
545 this fact is not further mentioned below.
547 The following attributes are recognized:
551 VALUE must be a string specifying the font family, e.g. ``courier'',
552 or a fontset alias name. If a font family is specified, wild-cards `*'
557 VALUE specifies the relative proportionate width of the font to use.
558 It must be one of the symbols `ultra-condensed', `extra-condensed',
559 `condensed', `semi-condensed', `normal', `semi-expanded', `expanded',
560 `extra-expanded', or `ultra-expanded'.
564 VALUE must be either an integer specifying the height of the font to use
565 in 1/10 pt, a floating point number specifying the amount by which to
566 scale any underlying face, or a function, which is called with the old
567 height (from the underlying face), and should return the new height.
571 VALUE specifies the weight of the font to use. It must be one of the
572 symbols `ultra-bold', `extra-bold', `bold', `semi-bold', `normal',
573 `semi-light', `light', `extra-light', `ultra-light'.
577 VALUE specifies the slant of the font to use. It must be one of the
578 symbols `italic', `oblique', `normal', `reverse-italic', or
581 `:foreground', `:background'
583 VALUE must be a color name, a string.
587 VALUE specifies whether characters in FACE should be underlined. If
588 VALUE is t, underline with foreground color of the face. If VALUE is
589 a string, underline with that color. If VALUE is nil, explicitly
594 VALUE specifies whether characters in FACE should be overlined. If
595 VALUE is t, overline with foreground color of the face. If VALUE is a
596 string, overline with that color. If VALUE is nil, explicitly don't
601 VALUE specifies whether characters in FACE should be drawn with a line
602 striking through them. If VALUE is t, use the foreground color of the
603 face. If VALUE is a string, strike-through with that color. If VALUE
604 is nil, explicitly don't strike through.
608 VALUE specifies whether characters in FACE should have a box drawn
609 around them. If VALUE is nil, explicitly don't draw boxes. If
610 VALUE is t, draw a box with lines of width 1 in the foreground color
611 of the face. If VALUE is a string, the string must be a color name,
612 and the box is drawn in that color with a line width of 1. Otherwise,
613 VALUE must be a property list of the form `(:line-width WIDTH
614 :color COLOR :style STYLE)'. If a keyword/value pair is missing from
615 the property list, a default value will be used for the value, as
616 specified below. WIDTH specifies the width of the lines to draw; it
617 defaults to 1. If WIDTH is negative, the absolute value is the width
618 of the lines, and draw top/bottom lines inside the characters area,
619 not around it. COLOR is the name of the color to draw in, default is
620 the foreground color of the face for simple boxes, and the background
621 color of the face for 3D boxes. STYLE specifies whether a 3D box
622 should be draw. If STYLE is `released-button', draw a box looking
623 like a released 3D button. If STYLE is `pressed-button' draw a box
624 that appears like a pressed button. If STYLE is nil, the default if
625 the property list doesn't contain a style specification, draw a 2D
630 VALUE specifies whether characters in FACE should be displayed in
631 inverse video. VALUE must be one of t or nil.
635 If VALUE is a string, it must be the name of a file of pixmap data.
636 The directories listed in the `x-bitmap-file-path' variable are
637 searched. Alternatively, VALUE may be a list of the form (WIDTH
638 HEIGHT DATA) where WIDTH and HEIGHT are the size in pixels, and DATA
639 is a string containing the raw bits of the bitmap. VALUE nil means
640 explicitly don't use a stipple pattern.
642 For convenience, attributes `:family', `:width', `:height', `:weight',
643 and `:slant' may also be set in one step from an X font name:
647 Set font-related face attributes from VALUE. VALUE must be a valid
648 XLFD font name. If it is a font name pattern, the first matching font
651 For compatibility with Emacs 20, keywords `:bold' and `:italic' can
652 be used to specify that a bold or italic font should be used. VALUE
653 must be t or nil in that case. A value of `unspecified' is not allowed.
657 VALUE is the name of a face from which to inherit attributes, or a list
658 of face names. Attributes from inherited faces are merged into the face
659 like an underlying face would be, with higher priority than underlying faces."
660 (let ((where (if (null frame
) 0 frame
)))
661 (setq args
(purecopy args
))
662 ;; If we set the new-frame defaults, this face is modified outside Custom.
663 (if (memq where
'(0 t
))
664 (put face
'face-modified t
))
666 (internal-set-lisp-face-attribute face
(car args
)
667 (purecopy (cadr args
))
669 (setq args
(cdr (cdr args
))))))
672 (defun make-face-bold (face &optional frame noerror
)
673 "Make the font of FACE be bold, if possible.
674 FRAME nil or not specified means change face on all frames.
675 Argument NOERROR is ignored and retained for compatibility.
676 Use `set-face-attribute' for finer control of the font weight."
677 (interactive (list (read-face-name "Make which face bold")))
678 (set-face-attribute face frame
:weight
'bold
))
681 (defun make-face-unbold (face &optional frame noerror
)
682 "Make the font of FACE be non-bold, if possible.
683 FRAME nil or not specified means change face on all frames.
684 Argument NOERROR is ignored and retained for compatibility."
685 (interactive (list (read-face-name "Make which face non-bold")))
686 (set-face-attribute face frame
:weight
'normal
))
689 (defun make-face-italic (face &optional frame noerror
)
690 "Make the font of FACE be italic, if possible.
691 FRAME nil or not specified means change face on all frames.
692 Argument NOERROR is ignored and retained for compatibility.
693 Use `set-face-attribute' for finer control of the font slant."
694 (interactive (list (read-face-name "Make which face italic")))
695 (set-face-attribute face frame
:slant
'italic
))
698 (defun make-face-unitalic (face &optional frame noerror
)
699 "Make the font of FACE be non-italic, if possible.
700 FRAME nil or not specified means change face on all frames.
701 Argument NOERROR is ignored and retained for compatibility."
702 (interactive (list (read-face-name "Make which face non-italic")))
703 (set-face-attribute face frame
:slant
'normal
))
706 (defun make-face-bold-italic (face &optional frame noerror
)
707 "Make the font of FACE be bold and italic, if possible.
708 FRAME nil or not specified means change face on all frames.
709 Argument NOERROR is ignored and retained for compatibility.
710 Use `set-face-attribute' for finer control of font weight and slant."
711 (interactive (list (read-face-name "Make which face bold-italic")))
712 (set-face-attribute face frame
:weight
'bold
:slant
'italic
))
715 (defun set-face-font (face font
&optional frame
)
716 "Change font-related attributes of FACE to those of FONT (a string).
717 FRAME nil or not specified means change face on all frames.
718 This sets the attributes `:family', `:width', `:height', `:weight',
719 and `:slant'. When called interactively, prompt for the face and font."
720 (interactive (read-face-and-attribute :font
))
721 (set-face-attribute face frame
:font font
))
724 ;; Implementation note: Emulating gray background colors with a
725 ;; stipple pattern is now part of the face realization process, and is
726 ;; done in C depending on the frame on which the face is realized.
728 (defun set-face-background (face color
&optional frame
)
729 "Change the background color of face FACE to COLOR (a string).
730 FRAME nil or not specified means change face on all frames.
731 COLOR can be a system-defined color name (see `list-colors-display')
732 or a hex spec of the form #RRGGBB.
733 When called interactively, prompts for the face and color."
734 (interactive (read-face-and-attribute :background
))
735 (set-face-attribute face frame
:background
(or color
'unspecified
)))
738 (defun set-face-foreground (face color
&optional frame
)
739 "Change the foreground color of face FACE to COLOR (a string).
740 FRAME nil or not specified means change face on all frames.
741 COLOR can be a system-defined color name (see `list-colors-display')
742 or a hex spec of the form #RRGGBB.
743 When called interactively, prompts for the face and color."
744 (interactive (read-face-and-attribute :foreground
))
745 (set-face-attribute face frame
:foreground
(or color
'unspecified
)))
748 (defun set-face-stipple (face stipple
&optional frame
)
749 "Change the stipple pixmap of face FACE to STIPPLE.
750 FRAME nil or not specified means change face on all frames.
751 STIPPLE should be a string, the name of a file of pixmap data.
752 The directories listed in the `x-bitmap-file-path' variable are searched.
754 Alternatively, STIPPLE may be a list of the form (WIDTH HEIGHT DATA)
755 where WIDTH and HEIGHT are the size in pixels,
756 and DATA is a string, containing the raw bits of the bitmap."
757 (interactive (read-face-and-attribute :stipple
))
758 (set-face-attribute face frame
:stipple
(or stipple
'unspecified
)))
761 (defun set-face-underline (face underline
&optional frame
)
762 "Specify whether face FACE is underlined.
763 UNDERLINE nil means FACE explicitly doesn't underline.
764 UNDERLINE non-nil means FACE explicitly does underlining
765 with the same of the foreground color.
766 If UNDERLINE is a string, underline with the color named UNDERLINE.
767 FRAME nil or not specified means change face on all frames.
768 Use `set-face-attribute' to ``unspecify'' underlining."
770 (let ((list (read-face-and-attribute :underline
)))
771 (list (car list
) (eq (car (cdr list
)) t
))))
772 (set-face-attribute face frame
:underline underline
))
775 (defun set-face-underline-p (face underline-p
&optional frame
)
776 "Specify whether face FACE is underlined.
777 UNDERLINE-P nil means FACE explicitly doesn't underline.
778 UNDERLINE-P non-nil means FACE explicitly does underlining.
779 FRAME nil or not specified means change face on all frames.
780 Use `set-face-attribute' to ``unspecify'' underlining."
782 (let ((list (read-face-and-attribute :underline
)))
783 (list (car list
) (eq (car (cdr list
)) t
))))
784 (set-face-attribute face frame
:underline underline-p
))
787 (defun set-face-inverse-video-p (face inverse-video-p
&optional frame
)
788 "Specify whether face FACE is in inverse video.
789 INVERSE-VIDEO-P non-nil means FACE displays explicitly in inverse video.
790 INVERSE-VIDEO-P nil means FACE explicitly is not in inverse video.
791 FRAME nil or not specified means change face on all frames.
792 Use `set-face-attribute' to ``unspecify'' the inverse video attribute."
794 (let ((list (read-face-and-attribute :inverse-video
)))
795 (list (car list
) (eq (car (cdr list
)) t
))))
796 (set-face-attribute face frame
:inverse-video inverse-video-p
))
799 (defun set-face-bold-p (face bold-p
&optional frame
)
800 "Specify whether face FACE is bold.
801 BOLD-P non-nil means FACE should explicitly display bold.
802 BOLD-P nil means FACE should explicitly display non-bold.
803 FRAME nil or not specified means change face on all frames.
804 Use `set-face-attribute' or `modify-face' for finer control."
806 (make-face-unbold face frame
)
807 (make-face-bold face frame
)))
810 (defun set-face-italic-p (face italic-p
&optional frame
)
811 "Specify whether face FACE is italic.
812 ITALIC-P non-nil means FACE should explicitly display italic.
813 ITALIC-P nil means FACE should explicitly display non-italic.
814 FRAME nil or not specified means change face on all frames.
815 Use `set-face-attribute' or `modify-face' for finer control."
817 (make-face-unitalic face frame
)
818 (make-face-italic face frame
)))
821 (defalias 'set-face-background-pixmap
'set-face-stipple
)
824 (defun invert-face (face &optional frame
)
825 "Swap the foreground and background colors of FACE.
826 If FRAME is omitted or nil, it means change face on all frames.
827 If FACE specifies neither foreground nor background color,
828 set its foreground and background to the background and foreground
829 of the default face. Value is FACE."
830 (interactive (list (read-face-name "Invert face")))
831 (let ((fg (face-attribute face
:foreground frame
))
832 (bg (face-attribute face
:background frame
)))
833 (if (not (and (eq fg
'unspecified
) (eq bg
'unspecified
)))
834 (set-face-attribute face frame
:foreground bg
:background fg
)
835 (set-face-attribute face frame
837 (face-attribute 'default
:background frame
)
839 (face-attribute 'default
:foreground frame
))))
843 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
844 ;;; Interactively modifying faces.
845 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
847 (defun read-face-name (prompt &optional string-describing-default multiple
)
848 "Read a face, defaulting to the face or faces on the char after point.
849 If it has a `read-face-name' property, that overrides the `face' property.
850 PROMPT describes what you will do with the face (don't end in a space).
851 STRING-DESCRIBING-DEFAULT describes what default you will use
852 if this function returns nil.
853 If MULTIPLE is non-nil, return a list of faces (possibly only one).
854 Otherwise, return a single face."
855 (let ((faceprop (or (get-char-property (point) 'read-face-name
)
856 (get-char-property (point) 'face
)))
858 ;; Make a list of the named faces that the `face' property uses.
859 (if (and (listp faceprop
)
860 ;; Don't treat an attribute spec as a list of faces.
861 (not (keywordp (car faceprop
)))
862 (not (memq (car faceprop
) '(foreground-color background-color
))))
866 (if (symbolp faceprop
)
867 (push faceprop faces
)))
868 ;; If there are none, try to get a face name from the buffer.
869 (if (and (null faces
)
870 (memq (intern-soft (thing-at-point 'symbol
)) (face-list)))
871 (setq faces
(list (intern-soft (thing-at-point 'symbol
)))))
873 ;; If we only want one, and the default is more than one,
874 ;; discard the unwanted ones now.
877 (setq faces
(list (car faces
)))))
881 (if (or faces string-describing-default
)
882 (format "%s (default %s): " prompt
883 (if faces
(mapconcat 'symbol-name faces
", ")
884 string-describing-default
))
885 (format "%s: " prompt
))
886 obarray
'custom-facep t
))
887 ;; Canonicalize the output.
892 (list (intern input
))
894 ;; Return either a list of faces or just one face.
900 (defun face-valid-attribute-values (attribute &optional frame
)
901 "Return valid values for face attribute ATTRIBUTE.
902 The optional argument FRAME is used to determine available fonts
903 and colors. If it is nil or not specified, the selected frame is
904 used. Value is an alist of (NAME . VALUE) if ATTRIBUTE expects a value
905 out of a set of discrete values. Value is `integerp' if ATTRIBUTE expects
911 (mapcar #'(lambda (x) (cons (car x
) (car x
)))
912 (x-font-family-list))
913 ;; Only one font on TTYs.
914 (list (cons "default" "default"))))
915 ((:width
:weight
:slant
:inverse-video
)
916 (mapcar #'(lambda (x) (cons (symbol-name x
) x
))
917 (internal-lisp-face-attribute-values attribute
)))
918 ((:underline
:overline
:strike-through
:box
)
920 (nconc (mapcar #'(lambda (x) (cons (symbol-name x
) x
))
921 (internal-lisp-face-attribute-values attribute
))
922 (mapcar #'(lambda (c) (cons c c
))
923 (x-defined-colors frame
)))
924 (mapcar #'(lambda (x) (cons (symbol-name x
) x
))
925 (internal-lisp-face-attribute-values attribute
))))
926 ((:foreground
:background
)
927 (mapcar #'(lambda (c) (cons c c
))
928 (defined-colors frame
)))
932 (and (memq window-system
'(x w32 mac
))
935 (mapcar (lambda (dir)
936 (and (file-readable-p dir
)
937 (file-directory-p dir
)
938 (directory-files dir
)))
939 x-bitmap-file-path
)))))
941 (cons '("none" . nil
)
942 (mapcar #'(lambda (c) (cons (symbol-name c
) c
))
945 (error "Internal error")))))
946 (if (and (listp valid
) (not (memq attribute
'(:inherit
))))
947 (nconc (list (cons "unspecified" 'unspecified
)) valid
)
951 (defvar face-attribute-name-alist
952 '((:family .
"font family")
953 (:width .
"character set width")
954 (:height .
"height in 1/10 pt")
957 (:underline .
"underline")
958 (:overline .
"overline")
959 (:strike-through .
"strike-through")
961 (:inverse-video .
"inverse-video display")
962 (:foreground .
"foreground color")
963 (:background .
"background color")
964 (:stipple .
"background stipple")
965 (:inherit .
"inheritance"))
966 "An alist of descriptive names for face attributes.
967 Each element has the form (ATTRIBUTE-NAME . DESCRIPTION) where
968 ATTRIBUTE-NAME is a face attribute name (a keyword symbol), and
969 DESCRIPTION is a descriptive name for ATTRIBUTE-NAME.")
972 (defun face-descriptive-attribute-name (attribute)
973 "Return a descriptive name for ATTRIBUTE."
974 (cdr (assq attribute face-attribute-name-alist
)))
977 (defun face-read-string (face default name
&optional completion-alist
)
978 "Interactively read a face attribute string value.
979 FACE is the face whose attribute is read. If non-nil, DEFAULT is the
980 default string to return if no new value is entered. NAME is a
981 descriptive name of the attribute for prompting. COMPLETION-ALIST is an
982 alist of valid values, if non-nil.
984 Entering nothing accepts the default string DEFAULT.
985 Value is the new attribute value."
986 ;; Capitalize NAME (we don't use `capitalize' because that capitalizes
987 ;; each word in a string separately).
988 (setq name
(concat (upcase (substring name
0 1)) (substring name
1)))
989 (let* ((completion-ignore-case t
)
990 (value (completing-read
992 (format "%s for face `%s' (default %s): "
994 (format "%s for face `%s': " name face
))
996 (if (equal value
"") default value
)))
999 (defun face-read-integer (face default name
)
1000 "Interactively read an integer face attribute value.
1001 FACE is the face whose attribute is read. DEFAULT is the default
1002 value to return if no new value is entered. NAME is a descriptive
1003 name of the attribute for prompting. Value is the new attribute value."
1005 (face-read-string face
1006 (format "%s" default
)
1008 (list (cons "unspecified" 'unspecified
)))))
1009 (cond ((equal new-value
"unspecified")
1011 ((member new-value
'("unspecified-fg" "unspecified-bg"))
1014 (string-to-number new-value
)))))
1017 (defun read-face-attribute (face attribute
&optional frame
)
1018 "Interactively read a new value for FACE's ATTRIBUTE.
1019 Optional argument FRAME nil or unspecified means read an attribute value
1020 of a global face. Value is the new attribute value."
1021 (let* ((old-value (face-attribute face attribute frame
))
1022 (attribute-name (face-descriptive-attribute-name attribute
))
1023 (valid (face-valid-attribute-values attribute frame
))
1025 ;; Represent complex attribute values as strings by printing them
1026 ;; out. Stipple can be a vector; (WIDTH HEIGHT DATA). Box can be
1027 ;; a list `(:width WIDTH :color COLOR)' or `(:width WIDTH :shadow
1029 (when (and (or (eq attribute
:stipple
)
1030 (eq attribute
:box
))
1031 (or (consp old-value
)
1032 (vectorp old-value
)))
1033 (setq old-value
(prin1-to-string old-value
)))
1034 (cond ((listp valid
)
1036 (or (car (rassoc old-value valid
))
1037 (format "%s" old-value
))))
1039 (face-read-string face default attribute-name valid
))
1040 (if (equal new-value default
)
1041 ;; Nothing changed, so don't bother with all the stuff
1042 ;; below. In particular, this avoids a non-tty color
1043 ;; from being canonicalized for a tty when the user
1044 ;; just uses the default.
1045 (setq new-value old-value
)
1046 ;; Terminal frames can support colors that don't appear
1047 ;; explicitly in VALID, using color approximation code
1048 ;; in tty-colors.el.
1049 (when (and (memq attribute
'(:foreground
:background
))
1050 (not (memq window-system
'(x w32 mac
)))
1051 (not (member new-value
1053 "unspecified-fg" "unspecified-bg"))))
1054 (setq new-value
(car (tty-color-desc new-value frame
))))
1055 (when (assoc new-value valid
)
1056 (setq new-value
(cdr (assoc new-value valid
)))))))
1057 ((eq valid
'integerp
)
1058 (setq new-value
(face-read-integer face old-value attribute-name
)))
1059 (t (error "Internal error")))
1060 ;; Convert stipple and box value text we read back to a list or
1061 ;; vector if it looks like one. This makes the assumption that a
1062 ;; pixmap file name won't start with an open-paren.
1063 (when (and (or (eq attribute
:stipple
)
1064 (eq attribute
:box
))
1066 (string-match "^[[(]" new-value
))
1067 (setq new-value
(read new-value
)))
1071 (defun read-face-font (face &optional frame
)
1072 "Read the name of a font for FACE on FRAME.
1073 If optional argument FRAME Is nil or omitted, use the selected frame."
1074 (let ((completion-ignore-case t
))
1075 (completing-read (format "Set font attributes of face `%s' from font: " face
)
1076 (x-list-fonts "*" nil frame
))))
1079 (defun read-all-face-attributes (face &optional frame
)
1080 "Interactively read all attributes for FACE.
1081 If optional argument FRAME Is nil or omitted, use the selected frame.
1082 Value is a property list of attribute names and new values."
1084 (dolist (attribute face-attribute-name-alist result
)
1085 (setq result
(cons (car attribute
)
1086 (cons (read-face-attribute face
(car attribute
) frame
)
1089 (defun modify-face (&optional face foreground background stipple
1090 bold-p italic-p underline-p inverse-p frame
)
1091 "Modify attributes of faces interactively.
1092 If optional argument FRAME is nil or omitted, modify the face used
1093 for newly created frame, i.e. the global face.
1094 For non-interactive use, `set-face-attribute' is preferred.
1095 When called from elisp, if FACE is nil, all arguments but FRAME are ignored
1096 and the face and its settings are obtained by querying the user."
1099 (set-face-attribute face frame
1100 :foreground
(or foreground
'unspecified
)
1101 :background
(or background
'unspecified
)
1105 :underline underline-p
1106 :inverse-video inverse-p
)
1107 (setq face
(read-face-name "Modify face"))
1108 (apply #'set-face-attribute face frame
1109 (read-all-face-attributes face frame
))))
1111 (defun read-face-and-attribute (attribute &optional frame
)
1112 "Read face name and face attribute value.
1113 ATTRIBUTE is the attribute whose new value is read.
1114 FRAME nil or unspecified means read attribute value of global face.
1115 Value is a list (FACE NEW-VALUE) where FACE is the face read
1116 \(a symbol), and NEW-VALUE is value read."
1117 (cond ((eq attribute
:font
)
1118 (let* ((prompt "Set font-related attributes of face")
1119 (face (read-face-name prompt
))
1120 (font (read-face-font face frame
)))
1123 (let* ((attribute-name (face-descriptive-attribute-name attribute
))
1124 (prompt (format "Set %s of face" attribute-name
))
1125 (face (read-face-name prompt
))
1126 (new-value (read-face-attribute face attribute frame
)))
1127 (list face new-value
)))))
1131 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1133 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1135 (defvar list-faces-sample-text
1136 "abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ"
1137 "*Text string to display as the sample text for `list-faces-display'.")
1140 ;; The name list-faces would be more consistent, but let's avoid a
1141 ;; conflict with Lucid, which uses that name differently.
1143 (defvar help-xref-stack
)
1144 (defun list-faces-display (&optional regexp
)
1145 "List all faces, using the same sample text in each.
1146 The sample text is a string that comes from the variable
1147 `list-faces-sample-text'.
1149 If REGEXP is non-nil, list only those faces with names matching
1150 this regular expression. When called interactively with a prefix
1151 arg, prompt for a regular expression."
1152 (interactive (list (and current-prefix-arg
1153 (read-string "List faces matching regexp: "))))
1154 (let ((all-faces (zerop (length regexp
)))
1155 (frame (selected-frame))
1158 disp-frame window face-name
)
1159 ;; We filter and take the max length in one pass
1163 (let ((s (symbol-name f
)))
1164 (when (or all-faces
(string-match regexp s
))
1165 (setq max-length
(max (length s
) max-length
))
1167 (sort (face-list) #'string-lessp
))))
1169 (error "No faces matching \"%s\"" regexp
))
1170 (setq max-length
(1+ max-length
)
1171 line-format
(format "%%-%ds" max-length
))
1172 (with-output-to-temp-buffer "*Faces*"
1174 (set-buffer standard-output
)
1175 (setq truncate-lines t
)
1177 (substitute-command-keys
1180 (if (display-mouse-p) "\\[help-follow-mouse] or ")
1181 "\\[help-follow] on a face name to customize it\n"
1182 "or on its sample text for a description of the face.\n\n")))
1183 (setq help-xref-stack nil
)
1184 (dolist (face faces
)
1185 (setq face-name
(symbol-name face
))
1186 (insert (format line-format face-name
))
1187 ;; Hyperlink to a customization buffer for the face. Using
1188 ;; the help xref mechanism may not be the best way.
1191 (search-backward face-name
)
1192 (setq help-xref-stack-item
`(list-faces-display ,regexp
))
1193 (help-xref-button 0 'help-customize-face face
)))
1195 (line-beg (line-beginning-position)))
1196 (insert list-faces-sample-text
)
1197 ;; Hyperlink to a help buffer for the face.
1200 (search-backward list-faces-sample-text
)
1201 (help-xref-button 0 'help-face face
)))
1203 (put-text-property beg
(1- (point)) 'face face
)
1204 ;; Make all face commands default to the proper face
1205 ;; anywhere in the line.
1206 (put-text-property line-beg
(1- (point)) 'read-face-name face
)
1207 ;; If the sample text has multiple lines, line up all of them.
1211 (insert-char ?\s max-length
)
1213 (goto-char (point-min)))
1214 (print-help-return-message))
1215 ;; If the *Faces* buffer appears in a different frame,
1216 ;; copy all the face definitions from FRAME,
1217 ;; so that the display will reflect the frame that was selected.
1218 (setq window
(get-buffer-window (get-buffer "*Faces*") t
))
1219 (setq disp-frame
(if window
(window-frame window
)
1220 (car (frame-list))))
1221 (or (eq frame disp-frame
)
1222 (let ((faces (face-list)))
1224 (copy-face (car faces
) (car faces
) frame disp-frame
)
1225 (setq faces
(cdr faces
)))))))
1228 (defun describe-face (face &optional frame
)
1229 "Display the properties of face FACE on FRAME.
1230 Interactively, FACE defaults to the faces of the character after point
1231 and FRAME defaults to the selected frame.
1233 If the optional argument FRAME is given, report on face FACE in that frame.
1234 If FRAME is t, report on the defaults for face FACE (for new frames).
1235 If FRAME is omitted or nil, use the selected frame."
1236 (interactive (list (read-face-name "Describe face" "= `default' face" t
)))
1237 (let* ((attrs '((:family .
"Family")
1239 (:height .
"Height")
1240 (:weight .
"Weight")
1242 (:foreground .
"Foreground")
1243 (:background .
"Background")
1244 (:underline .
"Underline")
1245 (:overline .
"Overline")
1246 (:strike-through .
"Strike-through")
1248 (:inverse-video .
"Inverse")
1249 (:stipple .
"Stipple")
1250 (:font .
"Font or fontset")
1251 (:inherit .
"Inherit")))
1252 (max-width (apply #'max
(mapcar #'(lambda (x) (length (cdr x
)))
1254 (help-setup-xref (list #'describe-face face
) (interactive-p))
1256 (setq face
'default
))
1257 (if (not (listp face
))
1258 (setq face
(list face
)))
1259 (with-output-to-temp-buffer (help-buffer)
1261 (set-buffer standard-output
)
1263 (insert "Face: " (symbol-name f
))
1265 (insert " undefined face.\n")
1266 (let ((customize-label "customize this face")
1268 (princ (concat " (" customize-label
")\n"))
1269 (insert "Documentation: "
1270 (or (face-documentation f
)
1271 "Not documented as a face.")
1273 (with-current-buffer standard-output
1276 (concat "\\(" customize-label
"\\)") nil t
)
1277 (help-xref-button 1 'help-customize-face f
)))
1278 ;; The next 4 sexps are copied from describe-function-1
1280 (setq file-name
(symbol-file f
'defface
))
1282 (princ "Defined in `")
1285 ;; Make a hyperlink to the library.
1287 (re-search-backward "`\\([^`']+\\)'" nil t
)
1288 (help-xref-button 1 'help-face-def f file-name
))
1293 (let ((attr (face-attribute f
(car a
) frame
)))
1294 (insert (make-string (- max-width
(length (cdr a
))) ?\
)
1295 (cdr a
) ": " (format "%s" attr
) "\n")))))
1297 (print-help-return-message))))
1300 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1301 ;;; Face specifications (defface).
1302 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1304 ;; Parameter FRAME Is kept for call compatibility to with previous
1305 ;; face implementation.
1307 (defun face-attr-construct (face &optional frame
)
1308 "Return a defface-style attribute list for FACE on FRAME.
1309 Value is a property list of pairs ATTRIBUTE VALUE for all specified
1310 face attributes of FACE where ATTRIBUTE is the attribute name and
1311 VALUE is the specified value of that attribute."
1313 (dolist (entry face-attribute-name-alist result
)
1314 (let* ((attribute (car entry
))
1315 (value (face-attribute face attribute
)))
1316 (unless (eq value
'unspecified
)
1317 (setq result
(nconc (list attribute value
) result
)))))))
1320 (defun face-spec-set-match-display (display frame
)
1321 "Non-nil if DISPLAY matches FRAME.
1322 DISPLAY is part of a spec such as can be used in `defface'.
1323 If FRAME is nil, the current FRAME is used."
1324 (let* ((conjuncts display
)
1325 conjunct req options
1326 ;; t means we have succeeded against all the conjuncts in
1327 ;; DISPLAY that have been tested so far.
1329 (if (eq conjuncts t
)
1330 (setq conjuncts nil
))
1331 (while (and conjuncts match
)
1332 (setq conjunct
(car conjuncts
)
1333 conjuncts
(cdr conjuncts
)
1335 options
(cdr conjunct
)
1336 match
(cond ((eq req
'type
)
1337 (or (memq window-system options
)
1338 ;; FIXME: This should be revisited to use
1339 ;; display-graphic-p, provided that the
1340 ;; color selection depends on the number
1341 ;; of supported colors, and all defface's
1342 ;; are changed to look at number of colors
1343 ;; instead of (type graphic) etc.
1344 (and (null window-system
)
1345 (memq 'tty options
))
1346 (and (memq 'motif options
)
1348 (and (memq 'gtk options
)
1350 (and (memq 'lucid options
)
1351 (featurep 'x-toolkit
)
1352 (not (featurep 'motif
))
1353 (not (featurep 'gtk
)))
1354 (and (memq 'x-toolkit options
)
1355 (featurep 'x-toolkit
))))
1356 ((eq req
'min-colors
)
1357 (>= (display-color-cells frame
) (car options
)))
1359 (memq (frame-parameter frame
'display-type
) options
))
1360 ((eq req
'background
)
1361 (memq (frame-parameter frame
'background-mode
)
1364 (display-supports-face-attributes-p options frame
))
1365 (t (error "Unknown req `%S' with options `%S'"
1370 (defun face-spec-choose (spec &optional frame
)
1371 "Choose the proper attributes for FRAME, out of SPEC.
1372 If SPEC is nil, return nil."
1374 (setq frame
(selected-frame)))
1378 (let* ((entry (pop tail
))
1379 (display (car entry
))
1382 ;; Get the attributes as actually specified by this alternative.
1384 (if (null (cdr attrs
)) ;; was (listp (car attrs))
1385 ;; Old-style entry, the attribute list is the
1390 ;; If the condition is `default', that sets the default
1391 ;; for following conditions.
1392 (if (eq display
'default
)
1393 (setq defaults thisval
)
1394 ;; Otherwise, if it matches, use it.
1395 (when (face-spec-set-match-display display frame
)
1396 (setq result thisval
)
1398 (if defaults
(append result defaults
) result
)))
1401 (defun face-spec-reset-face (face &optional frame
)
1402 "Reset all attributes of FACE on FRAME to unspecified."
1403 (let ((attrs face-attribute-name-alist
))
1405 (let ((attr-and-name (car attrs
)))
1406 (set-face-attribute face frame
(car attr-and-name
) 'unspecified
))
1407 (setq attrs
(cdr attrs
)))))
1410 (defun face-spec-set (face spec
&optional frame
)
1411 "Set FACE's attributes according to the first matching entry in SPEC.
1412 FRAME is the frame whose frame-local face is set. FRAME nil means
1413 do it on all frames. See `defface' for information about SPEC.
1414 If SPEC is nil, do nothing."
1415 (let ((attrs (face-spec-choose spec frame
)))
1417 (face-spec-reset-face face frame
))
1419 (let ((attribute (car attrs
))
1420 (value (car (cdr attrs
))))
1421 ;; Support some old-style attribute names and values.
1423 (:bold
(setq attribute
:weight value
(if value
'bold
'normal
)))
1424 (:italic
(setq attribute
:slant value
(if value
'italic
'normal
)))
1425 ((:foreground
:background
)
1426 ;; Compatibility with 20.x. Some bogus face specs seem to
1427 ;; exist containing things like `:foreground nil'.
1428 (if (null value
) (setq value
'unspecified
)))
1429 (t (unless (assq attribute face-x-resources
)
1430 (setq attribute nil
))))
1432 (set-face-attribute face frame attribute value
)))
1433 (setq attrs
(cdr (cdr attrs
)))))
1434 ;; When we reset the face based on its spec, then it is unmodified
1435 ;; as far as Custom is concerned.
1437 (put face
'face-modified nil
)))
1440 (defun face-attr-match-p (face attrs
&optional frame
)
1441 "Return t if attributes of FACE match values in plist ATTRS.
1442 Optional parameter FRAME is the frame whose definition of FACE
1443 is used. If nil or omitted, use the selected frame."
1445 (setq frame
(selected-frame)))
1446 (let ((list face-attribute-name-alist
)
1448 (while (and match
(not (null list
)))
1449 (let* ((attr (car (car list
)))
1451 (if (plist-member attrs attr
)
1452 (plist-get attrs attr
)
1454 (value-now (face-attribute face attr frame
)))
1455 (setq match
(equal specified-value value-now
))
1456 (setq list
(cdr list
))))
1459 (defun face-spec-match-p (face spec
&optional frame
)
1460 "Return t if FACE, on FRAME, matches what SPEC says it should look like."
1461 (face-attr-match-p face
(face-spec-choose spec frame
) frame
))
1463 (defsubst face-default-spec
(face)
1464 "Return the default face-spec for FACE, ignoring any user customization.
1465 If there is no default for FACE, return nil."
1466 (get face
'face-defface-spec
))
1468 (defsubst face-user-default-spec
(face)
1469 "Return the user's customized face-spec for FACE, or the default if none.
1470 If there is neither a user setting nor a default for FACE, return nil."
1471 (or (get face
'saved-face
)
1472 (face-default-spec face
)))
1475 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1476 ;;; Frame-type independent color support.
1477 ;;; We keep the old x-* names as aliases for back-compatibility.
1478 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1480 (defun defined-colors (&optional frame
)
1481 "Return a list of colors supported for a particular frame.
1482 The argument FRAME specifies which frame to try.
1483 The value may be different for frames on different display types.
1484 If FRAME doesn't support colors, the value is nil."
1485 (if (memq (framep (or frame
(selected-frame))) '(x w32 mac
))
1486 (xw-defined-colors frame
)
1487 (mapcar 'car
(tty-color-alist frame
))))
1488 (defalias 'x-defined-colors
'defined-colors
)
1490 (defun color-defined-p (color &optional frame
)
1491 "Return non-nil if color COLOR is supported on frame FRAME.
1492 If FRAME is omitted or nil, use the selected frame.
1493 If COLOR is the symbol `unspecified' or one of the strings
1494 \"unspecified-fg\" or \"unspecified-bg\", the value is nil."
1495 (if (member color
'(unspecified "unspecified-bg" "unspecified-fg"))
1497 (if (member (framep (or frame
(selected-frame))) '(x w32 mac
))
1498 (xw-color-defined-p color frame
)
1499 (numberp (tty-color-translate color frame
)))))
1500 (defalias 'x-color-defined-p
'color-defined-p
)
1502 (defun color-values (color &optional frame
)
1503 "Return a description of the color named COLOR on frame FRAME.
1504 The value is a list of integer RGB values--\(RED GREEN BLUE\).
1505 These values appear to range from 0 65535; white is \(65535 65535 65535\).
1506 If FRAME is omitted or nil, use the selected frame.
1507 If FRAME cannot display COLOR, the value is nil.
1508 If COLOR is the symbol `unspecified' or one of the strings
1509 \"unspecified-fg\" or \"unspecified-bg\", the value is nil."
1510 (if (member color
'(unspecified "unspecified-fg" "unspecified-bg"))
1512 (if (memq (framep (or frame
(selected-frame))) '(x w32 mac
))
1513 (xw-color-values color frame
)
1514 (tty-color-values color frame
))))
1515 (defalias 'x-color-values
'color-values
)
1517 (defun display-color-p (&optional display
)
1518 "Return t if DISPLAY supports color.
1519 The optional argument DISPLAY specifies which display to ask about.
1520 DISPLAY should be either a frame or a display name (a string).
1521 If omitted or nil, that stands for the selected frame's display."
1522 (if (memq (framep-on-display display
) '(x w32 mac
))
1523 (xw-display-color-p display
)
1524 (tty-display-color-p display
)))
1525 (defalias 'x-display-color-p
'display-color-p
)
1527 (defun display-grayscale-p (&optional display
)
1528 "Return non-nil if frames on DISPLAY can display shades of gray."
1529 (let ((frame-type (framep-on-display display
)))
1531 ((memq frame-type
'(x w32 mac
))
1532 (x-display-grayscale-p display
))
1534 (> (tty-color-gray-shades display
) 2)))))
1537 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1538 ;;; Background mode.
1539 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1541 (defcustom frame-background-mode nil
1542 "*The brightness of the background.
1543 Set this to the symbol `dark' if your background color is dark, `light' if
1544 your background is light, or nil (default) if you want Emacs to
1545 examine the brightness for you. Don't set this variable with `setq';
1546 this won't have the expected effect."
1548 :set
#'(lambda (var value
)
1549 (set-default var value
)
1550 (mapc 'frame-set-background-mode
(frame-list)))
1551 :initialize
'custom-initialize-changed
1552 :type
'(choice (choice-item dark
)
1554 (choice-item :tag
"default" nil
)))
1557 (defun frame-set-background-mode (frame)
1558 "Set up display-dependent faces on FRAME.
1559 Display-dependent faces are those which have different definitions
1560 according to the `background-mode' and `display-type' frame parameters."
1563 (x-get-resource "backgroundMode" "BackgroundMode")))
1564 (bg-color (frame-parameter frame
'background-color
))
1566 (cond (frame-background-mode)
1568 (intern (downcase bg-resource
)))
1569 ((and (null window-system
) (null bg-color
))
1570 ;; No way to determine this automatically (?).
1572 ;; Unspecified frame background color can only happen
1574 ((member bg-color
'(unspecified "unspecified-bg"))
1576 ((equal bg-color
"unspecified-fg") ; inverted colors
1578 ((>= (apply '+ (x-color-values bg-color frame
))
1579 ;; Just looking at the screen, colors whose
1580 ;; values add up to .6 of the white total
1581 ;; still look dark to me.
1582 (* (apply '+ (x-color-values "white" frame
)) .6))
1586 (cond ((null window-system
)
1587 (if (tty-display-color-p frame
) 'color
'mono
))
1588 ((x-display-color-p frame
)
1590 ((x-display-grayscale-p frame
)
1594 (frame-parameter frame
'background-mode
))
1596 (frame-parameter frame
'display-type
)))
1598 (unless (and (eq bg-mode old-bg-mode
) (eq display-type old-display-type
))
1599 (let ((locally-modified-faces nil
))
1600 ;; Before modifying the frame parameters, we collect a list of
1601 ;; faces that don't match what their face-spec says they should
1602 ;; look like; we then avoid changing these faces below. A
1603 ;; negative list is used on the assumption that most faces will
1604 ;; be unmodified, so we can avoid consing in the common case.
1605 (dolist (face (face-list))
1606 (when (not (face-spec-match-p face
1607 (face-user-default-spec face
)
1609 (push face locally-modified-faces
)))
1610 ;; Now change to the new frame parameters
1611 (modify-frame-parameters frame
1612 (list (cons 'background-mode bg-mode
)
1613 (cons 'display-type display-type
)))
1614 ;; For all named faces, choose face specs matching the new frame
1615 ;; parameters, unless they have been locally modified.
1616 (dolist (face (face-list))
1617 (unless (memq face locally-modified-faces
)
1618 (face-spec-set face
(face-user-default-spec face
) frame
)))))))
1621 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1623 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1625 (defun x-handle-named-frame-geometry (parameters)
1626 "Add geometry parameters for a named frame to parameter list PARAMETERS.
1627 Value is the new parameter list."
1628 (let* ((name (or (cdr (assq 'name parameters
))
1629 (cdr (assq 'name default-frame-alist
))))
1630 (x-resource-name name
)
1631 (res-geometry (if name
(x-get-resource "geometry" "Geometry"))))
1633 (let ((parsed (x-parse-geometry res-geometry
)))
1634 ;; If the resource specifies a position, call the position
1635 ;; and size "user-specified".
1636 (when (or (assq 'top parsed
)
1637 (assq 'left parsed
))
1638 (setq parsed
(append '((user-position . t
) (user-size . t
)) parsed
)))
1639 ;; Put the geometry parameters at the end. Copy
1640 ;; default-frame-alist so that they go after it.
1641 (setq parameters
(append parameters default-frame-alist parsed
))))
1645 (defun x-handle-reverse-video (frame parameters
)
1646 "Handle the reverse-video frame parameter and X resource.
1647 `x-create-frame' does not handle this one."
1648 (when (cdr (or (assq 'reverse parameters
)
1649 (assq 'reverse default-frame-alist
)
1650 (let ((resource (x-get-resource "reverseVideo"
1653 (cons nil
(member (downcase resource
)
1654 '("on" "true")))))))
1655 (let* ((params (frame-parameters frame
))
1656 (bg (cdr (assq 'foreground-color params
)))
1657 (fg (cdr (assq 'background-color params
))))
1658 (modify-frame-parameters frame
1659 (list (cons 'foreground-color fg
)
1660 (cons 'background-color bg
)))
1661 (if (equal bg
(cdr (assq 'border-color params
)))
1662 (modify-frame-parameters frame
1663 (list (cons 'border-color fg
))))
1664 (if (equal bg
(cdr (assq 'mouse-color params
)))
1665 (modify-frame-parameters frame
1666 (list (cons 'mouse-color fg
))))
1667 (if (equal bg
(cdr (assq 'cursor-color params
)))
1668 (modify-frame-parameters frame
1669 (list (cons 'cursor-color fg
)))))))
1672 (defun x-create-frame-with-faces (&optional parameters
)
1673 "Create a frame from optional frame parameters PARAMETERS.
1674 Parameters not specified by PARAMETERS are taken from
1675 `default-frame-alist'. If PARAMETERS specify a frame name,
1676 handle X geometry resources for that name. If either PARAMETERS
1677 or `default-frame-alist' contains a `reverse' parameter, or
1678 the X resource ``reverseVideo'' is present, handle that.
1679 Value is the new frame created."
1680 (setq parameters
(x-handle-named-frame-geometry parameters
))
1681 (let ((visibility-spec (assq 'visibility parameters
))
1682 (frame-list (frame-list))
1683 (frame (x-create-frame (cons '(visibility . nil
) parameters
)))
1687 (x-handle-reverse-video frame parameters
)
1688 (frame-set-background-mode frame
)
1689 (face-set-after-frame-default frame
)
1690 (if (or (null frame-list
) (null visibility-spec
))
1691 (make-frame-visible frame
)
1692 (modify-frame-parameters frame
(list visibility-spec
)))
1695 (delete-frame frame
)))
1699 (defun face-set-after-frame-default (frame)
1700 "Set frame-local faces of FRAME from face specs and resources.
1701 Initialize colors of certain faces from frame parameters."
1702 (if (face-attribute 'default
:font t
)
1703 (set-face-attribute 'default frame
:font
1704 (face-attribute 'default
:font t
))
1705 (set-face-attribute 'default frame
:family
1706 (face-attribute 'default
:family t
))
1707 (set-face-attribute 'default frame
:height
1708 (face-attribute 'default
:height t
))
1709 (set-face-attribute 'default frame
:slant
1710 (face-attribute 'default
:slant t
))
1711 (set-face-attribute 'default frame
:weight
1712 (face-attribute 'default
:weight t
))
1713 (set-face-attribute 'default frame
:width
1714 (face-attribute 'default
:width t
)))
1715 (dolist (face (face-list))
1716 ;; Don't let frame creation fail because of an invalid face spec.
1718 (when (not (equal face
'default
))
1719 (face-spec-set face
(face-user-default-spec face
) frame
)
1720 (internal-merge-in-global-face face frame
)
1721 (when (and (memq window-system
'(x w32 mac
))
1722 (or (not (boundp 'inhibit-default-face-x-resources
))
1723 (not (eq face
'default
))))
1724 (make-face-x-resource-internal face frame
)))
1726 ;; Initialize attributes from frame parameters.
1727 (let ((params '((foreground-color default
:foreground
)
1728 (background-color default
:background
)
1729 (border-color border
:background
)
1730 (cursor-color cursor
:background
)
1731 (scroll-bar-foreground scroll-bar
:foreground
)
1732 (scroll-bar-background scroll-bar
:background
)
1733 (mouse-color mouse
:background
))))
1734 (dolist (param params
)
1735 (let ((frame-param (frame-parameter frame
(nth 0 param
)))
1736 (face (nth 1 param
))
1737 (attr (nth 2 param
)))
1738 (when (and frame-param
1739 ;; Don't override face attributes explicitly
1740 ;; specified for new frames.
1741 (eq (face-attribute face attr t
) 'unspecified
))
1742 (set-face-attribute face frame attr frame-param
))))))
1745 (defun tty-handle-reverse-video (frame parameters
)
1746 "Handle the reverse-video frame parameter for terminal frames."
1747 (when (cdr (or (assq 'reverse parameters
)
1748 (assq 'reverse default-frame-alist
)))
1749 (let* ((params (frame-parameters frame
))
1750 (bg (cdr (assq 'foreground-color params
)))
1751 (fg (cdr (assq 'background-color params
))))
1752 (modify-frame-parameters frame
1753 (list (cons 'foreground-color fg
)
1754 (cons 'background-color bg
)))
1755 (if (equal bg
(cdr (assq 'mouse-color params
)))
1756 (modify-frame-parameters frame
1757 (list (cons 'mouse-color fg
))))
1758 (if (equal bg
(cdr (assq 'cursor-color params
)))
1759 (modify-frame-parameters frame
1760 (list (cons 'cursor-color fg
)))))))
1763 (defun tty-create-frame-with-faces (&optional parameters
)
1764 "Create a frame from optional frame parameters PARAMETERS.
1765 Parameters not specified by PARAMETERS are taken from
1766 `default-frame-alist'. If either PARAMETERS or `default-frame-alist'
1767 contains a `reverse' parameter, handle that. Value is the new frame
1769 (let ((frame (make-terminal-frame parameters
))
1773 (tty-handle-reverse-video frame
(frame-parameters frame
))
1774 (frame-set-background-mode frame
)
1775 (face-set-after-frame-default frame
)
1778 (delete-frame frame
)))
1782 ;; Called from C function init_display to initialize faces of the
1783 ;; dumped terminal frame on startup.
1785 (defun tty-set-up-initial-frame-faces ()
1786 (let ((frame (selected-frame)))
1787 (frame-set-background-mode frame
)
1788 (face-set-after-frame-default frame
)))
1793 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1794 ;;; Compatiblity with 20.2
1795 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1797 ;; Update a frame's faces when we change its default font.
1799 (defalias 'frame-update-faces
'ignore
"")
1800 (make-obsolete 'frame-update-faces
"no longer necessary." "21.1")
1802 ;; Update the colors of FACE, after FRAME's own colors have been
1805 (defalias 'frame-update-face-colors
'frame-set-background-mode
)
1806 (make-obsolete 'frame-update-face-colors
'frame-set-background-mode
"21.1")
1809 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1811 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1813 (defgroup basic-faces nil
1814 "The standard faces of Emacs."
1820 "Basic default face."
1821 :group
'basic-faces
)
1825 '((((class color
) (min-colors 88))
1826 :box
(:line-width -
1 :style released-button
)
1827 :background
"grey75" :foreground
"black")
1830 "Basic mode line face for selected window."
1833 :group
'basic-faces
)
1835 (defface mode-line-inactive
1838 (((class color
) (min-colors 88) (background light
))
1840 :box
(:line-width -
1 :color
"grey75" :style nil
)
1841 :foreground
"grey20" :background
"grey90")
1842 (((class color
) (min-colors 88) (background dark
) )
1844 :box
(:line-width -
1 :color
"grey40" :style nil
)
1845 :foreground
"grey80" :background
"grey30"))
1846 "Basic mode line face for non-selected windows."
1849 :group
'basic-faces
)
1851 (defface mode-line-highlight
1852 '((((class color
) (min-colors 88) (background light
))
1853 :background
"RoyalBlue4" :foreground
"white")
1854 (((class color
) (min-colors 88) (background dark
))
1855 :background
"light sky blue" :foreground
"black")
1858 "Basic mode line face for highlighting."
1861 :group
'basic-faces
)
1863 ;; Make `modeline' an alias for `mode-line', for compatibility.
1864 (put 'modeline
'face-alias
'mode-line
)
1865 (put 'modeline-inactive
'face-alias
'mode-line-inactive
)
1866 (put 'modeline-higilight
'face-alias
'mode-line-highlight
)
1868 (defface header-line
1872 ;; This used to be `:inverse-video t', but that doesn't look very
1873 ;; good when combined with inverse-video mode-lines and multiple
1874 ;; windows. Underlining looks better, and is more consistent with
1875 ;; the window-system face variants, which deemphasize the
1876 ;; header-line in relation to the mode-line face. If a terminal
1877 ;; can't underline, then the header-line will end up without any
1878 ;; highlighting; this may be too confusing in general, although it
1879 ;; happens to look good with the only current use of header-lines,
1880 ;; the info browser. XXX
1881 :inverse-video nil
;Override the value inherited from mode-line.
1883 (((class color grayscale
) (background light
))
1884 :background
"grey90" :foreground
"grey20"
1886 (((class color grayscale
) (background dark
))
1887 :background
"grey20" :foreground
"grey90"
1889 (((class mono
) (background light
))
1890 :background
"white" :foreground
"black"
1894 (((class mono
) (background dark
))
1895 :background
"black" :foreground
"white"
1899 "Basic header-line face."
1901 :group
'basic-faces
)
1906 :box
(:line-width
1 :style released-button
)
1907 :foreground
"black")
1908 (((type x w32 mac
) (class color
))
1909 :background
"grey75")
1910 (((type x
) (class mono
))
1911 :background
"grey"))
1912 "Basic tool-bar face."
1914 :group
'basic-faces
)
1917 (defface minibuffer-prompt
'((((background dark
)) :foreground
"cyan")
1918 ;; Don't use blue because many users of
1919 ;; the MS-DOS port customize their
1920 ;; foreground color to be blue.
1921 (((type pc
)) :foreground
"magenta")
1922 (t :foreground
"dark blue"))
1923 "Face for minibuffer prompts."
1925 :group
'basic-faces
)
1927 (setq minibuffer-prompt-properties
1928 (append minibuffer-prompt-properties
(list 'face
'minibuffer-prompt
)))
1931 '((((class color
) (min-colors 88) (background dark
))
1932 :background
"blue3")
1933 (((class color
) (min-colors 88) (background light
))
1934 :background
"lightgoldenrod2")
1935 (((class color
) (min-colors 16) (background dark
))
1936 :background
"blue3")
1937 (((class color
) (min-colors 16) (background light
))
1938 :background
"lightgoldenrod2")
1939 (((class color
) (min-colors 8))
1940 :background
"blue" :foreground
"white")
1941 (((type tty
) (class mono
))
1943 (t :background
"gray"))
1944 "Basic face for highlighting the region."
1946 :group
'basic-faces
)
1950 '((((class color
) (background light
))
1951 :background
"grey95")
1952 (((class color
) (background dark
))
1953 :background
"grey10")
1955 :background
"gray"))
1956 "Basic face for the fringes to the left and right of windows under X."
1959 :group
'basic-faces
)
1962 (defface scroll-bar
'()
1963 "Basic face for the scroll bar colors under X."
1966 :group
'basic-faces
)
1976 "Basic face for the font and colors of the menu bar and popup menus."
1979 :group
'basic-faces
)
1983 "Basic face for the frame border under X."
1986 :group
'basic-faces
)
1990 "Basic face for the cursor color under X.
1991 Note: Other faces cannot inherit from the cursor face."
1994 :group
'basic-faces
)
1996 (put 'cursor
'face-no-inherit t
)
1999 "Basic face for the mouse color under X."
2002 :group
'basic-faces
)
2005 (defface bold
'((t :weight bold
))
2007 :group
'basic-faces
)
2011 '((((supports :slant italic
))
2013 (((supports :underline t
))
2016 ;; default to italic, even it doesn't appear to be supported,
2017 ;; because in some cases the display engine will do it's own
2018 ;; workaround (to `dim' on ttys)
2020 "Basic italic font."
2021 :group
'basic-faces
)
2024 (defface bold-italic
'((t :weight bold
:slant italic
))
2025 "Basic bold-italic face."
2026 :group
'basic-faces
)
2029 (defface underline
'((t :underline t
))
2030 "Basic underlined face."
2031 :group
'basic-faces
)
2035 '((((class color
) (min-colors 88) (background light
))
2036 :background
"darkseagreen2")
2037 (((class color
) (min-colors 88) (background dark
))
2038 :background
"darkolivegreen")
2039 (((class color
) (min-colors 16) (background light
))
2040 :background
"darkseagreen2")
2041 (((class color
) (min-colors 16) (background dark
))
2042 :background
"darkolivegreen")
2043 (((class color
) (min-colors 8))
2044 :background
"green" :foreground
"black")
2045 (t :inverse-video t
))
2046 "Basic face for highlighting."
2047 :group
'basic-faces
)
2050 (defface secondary-selection
2051 '((((class color
) (min-colors 88) (background light
))
2052 :background
"yellow1")
2053 (((class color
) (min-colors 88) (background dark
))
2054 :background
"SkyBlue4")
2055 (((class color
) (min-colors 16) (background light
))
2056 :background
"yellow")
2057 (((class color
) (min-colors 16) (background dark
))
2058 :background
"SkyBlue4")
2059 (((class color
) (min-colors 8))
2060 :background
"cyan" :foreground
"black")
2061 (t :inverse-video t
))
2062 "Basic face for displaying the secondary selection."
2063 :group
'basic-faces
)
2066 (defface fixed-pitch
'((t :family
"courier"))
2067 "The basic fixed-pitch face."
2068 :group
'basic-faces
)
2071 (defface variable-pitch
'((t :family
"helv"))
2072 "The basic variable-pitch face."
2073 :group
'basic-faces
)
2076 (defface trailing-whitespace
2077 '((((class color
) (background light
))
2079 (((class color
) (background dark
))
2081 (t :inverse-video t
))
2082 "Basic face for highlighting trailing whitespace."
2084 :group
'whitespace
; like `show-trailing-whitespace'
2085 :group
'basic-faces
)
2087 (defface escape-glyph
2088 '((((background dark
)) :foreground
"pink2")
2089 ;; See the comment in minibuffer-prompt for
2090 ;; the reason not to use blue on MS-DOS.
2091 (((type pc
)) :foreground
"magenta")
2092 ;; red4 is too light -- rms.
2093 (t :foreground
"blue"))
2094 "Face for characters displayed as ^-sequences or \-sequences."
2098 (defface no-break-space
2099 '((((class color
) (min-colors 88)) :inherit escape-glyph
:underline t
)
2100 (((class color
) (min-colors 8)) :background
"magenta" :foreground
)
2101 (t :inverse-video t
))
2102 "Face for non-breaking space."
2107 '((((background dark
)) :foreground
"grey70")
2108 (((background light
)) :foreground
"grey50"))
2109 "Basic face for shadowed text."
2114 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2115 ;;; Manipulating font names.
2116 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2118 ;; This is here for compatibilty with Emacs 20.2. For example,
2119 ;; international/fontset.el uses x-resolve-font-name. The following
2120 ;; functions are not used in the face implementation itself.
2122 (defvar x-font-regexp nil
)
2123 (defvar x-font-regexp-head nil
)
2124 (defvar x-font-regexp-weight nil
)
2125 (defvar x-font-regexp-slant nil
)
2127 (defconst x-font-regexp-weight-subnum
1)
2128 (defconst x-font-regexp-slant-subnum
2)
2129 (defconst x-font-regexp-swidth-subnum
3)
2130 (defconst x-font-regexp-adstyle-subnum
4)
2132 ;;; Regexps matching font names in "Host Portable Character Representation."
2137 (weight "\\(bold\\|demibold\\|medium\\)") ; 1
2138 ; (weight\? "\\(\\*\\|bold\\|demibold\\|medium\\|\\)") ; 1
2139 (weight\? "\\([^-]*\\)") ; 1
2140 (slant "\\([ior]\\)") ; 2
2141 ; (slant\? "\\([ior?*]?\\)") ; 2
2142 (slant\? "\\([^-]?\\)") ; 2
2143 ; (swidth "\\(\\*\\|normal\\|semicondensed\\|\\)") ; 3
2144 (swidth "\\([^-]*\\)") ; 3
2145 ; (adstyle "\\(\\*\\|sans\\|\\)") ; 4
2146 (adstyle "\\([^-]*\\)") ; 4
2147 (pixelsize "[0-9]+")
2148 (pointsize "[0-9][0-9]+")
2149 (resx "[0-9][0-9]+")
2150 (resy "[0-9][0-9]+")
2157 (concat "\\`\\*?[-?*]"
2158 foundry - family - weight
\? - slant
\? - swidth - adstyle -
2159 pixelsize - pointsize - resx - resy - spacing - avgwidth -
2160 registry - encoding
"\\*?\\'"
2162 (setq x-font-regexp-head
2163 (concat "\\`[-?*]" foundry - family - weight
\? - slant
\?
2164 "\\([-*?]\\|\\'\\)"))
2165 (setq x-font-regexp-slant
(concat - slant -
))
2166 (setq x-font-regexp-weight
(concat - weight -
))
2170 (defun x-resolve-font-name (pattern &optional face frame
)
2171 "Return a font name matching PATTERN.
2172 All wildcards in PATTERN are instantiated.
2173 If PATTERN is nil, return the name of the frame's base font, which never
2175 Given optional arguments FACE and FRAME, return a font which is
2176 also the same size as FACE on FRAME, or fail."
2178 (setq face
(face-name face
)))
2182 ;; Note that x-list-fonts has code to handle a face with nil as its font.
2183 (let ((fonts (x-list-fonts pattern face frame
1)))
2186 (if (string-match "\\*" pattern
)
2187 (if (null (face-font face
))
2188 (error "No matching fonts are the same height as the frame default font")
2189 (error "No matching fonts are the same height as face `%s'" face
))
2190 (if (null (face-font face
))
2191 (error "Height of font `%s' doesn't match the frame default font"
2193 (error "Height of font `%s' doesn't match face `%s'"
2195 (error "No fonts match `%s'" pattern
)))
2197 (cdr (assq 'font
(frame-parameters (selected-frame))))))
2200 (defun x-frob-font-weight (font which
)
2201 (let ((case-fold-search t
))
2202 (cond ((string-match x-font-regexp font
)
2203 (concat (substring font
0
2204 (match-beginning x-font-regexp-weight-subnum
))
2206 (substring font
(match-end x-font-regexp-weight-subnum
)
2207 (match-beginning x-font-regexp-adstyle-subnum
))
2208 ;; Replace the ADD_STYLE_NAME field with *
2209 ;; because the info in it may not be the same
2210 ;; for related fonts.
2212 (substring font
(match-end x-font-regexp-adstyle-subnum
))))
2213 ((string-match x-font-regexp-head font
)
2214 (concat (substring font
0 (match-beginning 1)) which
2215 (substring font
(match-end 1))))
2216 ((string-match x-font-regexp-weight font
)
2217 (concat (substring font
0 (match-beginning 1)) which
2218 (substring font
(match-end 1)))))))
2219 (make-obsolete 'x-frob-font-weight
'make-face-...
"21.1")
2221 (defun x-frob-font-slant (font which
)
2222 (let ((case-fold-search t
))
2223 (cond ((string-match x-font-regexp font
)
2224 (concat (substring font
0
2225 (match-beginning x-font-regexp-slant-subnum
))
2227 (substring font
(match-end x-font-regexp-slant-subnum
)
2228 (match-beginning x-font-regexp-adstyle-subnum
))
2229 ;; Replace the ADD_STYLE_NAME field with *
2230 ;; because the info in it may not be the same
2231 ;; for related fonts.
2233 (substring font
(match-end x-font-regexp-adstyle-subnum
))))
2234 ((string-match x-font-regexp-head font
)
2235 (concat (substring font
0 (match-beginning 2)) which
2236 (substring font
(match-end 2))))
2237 ((string-match x-font-regexp-slant font
)
2238 (concat (substring font
0 (match-beginning 1)) which
2239 (substring font
(match-end 1)))))))
2240 (make-obsolete 'x-frob-font-slant
'make-face-...
"21.1")
2242 ;; These aliases are here so that we don't get warnings about obsolete
2243 ;; functions from the byte compiler.
2244 (defalias 'internal-frob-font-weight
'x-frob-font-weight
)
2245 (defalias 'internal-frob-font-slant
'x-frob-font-slant
)
2247 (defun x-make-font-bold (font)
2248 "Given an X font specification, make a bold version of it.
2249 If that can't be done, return nil."
2250 (internal-frob-font-weight font
"bold"))
2251 (make-obsolete 'x-make-font-bold
'make-face-bold
"21.1")
2253 (defun x-make-font-demibold (font)
2254 "Given an X font specification, make a demibold version of it.
2255 If that can't be done, return nil."
2256 (internal-frob-font-weight font
"demibold"))
2257 (make-obsolete 'x-make-font-demibold
'make-face-bold
"21.1")
2259 (defun x-make-font-unbold (font)
2260 "Given an X font specification, make a non-bold version of it.
2261 If that can't be done, return nil."
2262 (internal-frob-font-weight font
"medium"))
2263 (make-obsolete 'x-make-font-unbold
'make-face-unbold
"21.1")
2265 (defun x-make-font-italic (font)
2266 "Given an X font specification, make an italic version of it.
2267 If that can't be done, return nil."
2268 (internal-frob-font-slant font
"i"))
2269 (make-obsolete 'x-make-font-italic
'make-face-italic
"21.1")
2271 (defun x-make-font-oblique (font) ; you say tomayto...
2272 "Given an X font specification, make an oblique version of it.
2273 If that can't be done, return nil."
2274 (internal-frob-font-slant font
"o"))
2275 (make-obsolete 'x-make-font-oblique
'make-face-italic
"21.1")
2277 (defun x-make-font-unitalic (font)
2278 "Given an X font specification, make a non-italic version of it.
2279 If that can't be done, return nil."
2280 (internal-frob-font-slant font
"r"))
2281 (make-obsolete 'x-make-font-unitalic
'make-face-unitalic
"21.1")
2283 (defun x-make-font-bold-italic (font)
2284 "Given an X font specification, make a bold and italic version of it.
2285 If that can't be done, return nil."
2286 (and (setq font
(internal-frob-font-weight font
"bold"))
2287 (internal-frob-font-slant font
"i")))
2288 (make-obsolete 'x-make-font-bold-italic
'make-face-bold-italic
"21.1")
2292 ;;; arch-tag: 19a4759f-2963-445f-b004-425b9aadd7d6
2293 ;;; faces.el ends here