(fill-find-break-point): Fix doc-string typo.
[emacs.git] / lisp / faces.el
bloba1b069e9ba6f30501f95a6692868c178a1f5d28c
1 ;;; faces.el --- Lisp faces
3 ;; Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
4 ;; 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
6 ;; Maintainer: FSF
7 ;; Keywords: internal
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 3, or (at your option)
14 ;; any later version.
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., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
26 ;;; Commentary:
28 ;;; Code:
30 (eval-when-compile
31 (require 'cl)
32 ;; Warning suppression -- can't require x-win in batch:
33 (autoload 'xw-defined-colors "x-win"))
35 (defvar help-xref-stack-item)
37 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
38 ;;; Font selection.
39 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
41 (defgroup font-selection nil
42 "Influencing face font selection."
43 :group 'faces)
46 (defcustom face-font-selection-order
47 '(:width :height :weight :slant)
48 "*A list specifying how face font selection chooses fonts.
49 Each of the four symbols `:width', `:height', `:weight', and `:slant'
50 must appear once in the list, and the list must not contain any other
51 elements. Font selection first tries to find a best matching font
52 for those face attributes that appear before in the list. For
53 example, if `:slant' appears before `:height', font selection first
54 tries to find a font with a suitable slant, even if this results in
55 a font height that isn't optimal."
56 :tag "Font selection order"
57 :type '(list symbol symbol symbol symbol)
58 :group 'font-selection
59 :set #'(lambda (symbol value)
60 (set-default symbol value)
61 (internal-set-font-selection-order value)))
64 ;; This is defined originally in xfaces.c.
65 (defcustom face-font-family-alternatives
66 '(("courier" "fixed")
67 ("helv" "helvetica" "arial" "fixed"))
68 "*Alist of alternative font family names.
69 Each element has the form (FAMILY ALTERNATIVE1 ALTERNATIVE2 ...).
70 If fonts of family FAMILY can't be loaded, try ALTERNATIVE1, then
71 ALTERNATIVE2 etc."
72 :tag "Alternative font families to try"
73 :type '(repeat (repeat string))
74 :group 'font-selection
75 :set #'(lambda (symbol value)
76 (set-default symbol value)
77 (internal-set-alternative-font-family-alist value)))
80 ;; This is defined originally in xfaces.c.
81 (defcustom face-font-registry-alternatives
82 (if (eq system-type 'windows-nt)
83 '(("iso8859-1" "ms-oemlatin")
84 ("gb2312.1980" "gb2312")
85 ("jisx0208.1990" "jisx0208.1983" "jisx0208.1978")
86 ("ksc5601.1989" "ksx1001.1992" "ksc5601.1987")
87 ("muletibetan-2" "muletibetan-0"))
88 '(("gb2312.1980" "gb2312.80&gb8565.88" "gbk*")
89 ("jisx0208.1990" "jisx0208.1983" "jisx0208.1978")
90 ("ksc5601.1989" "ksx1001.1992" "ksc5601.1987")
91 ("muletibetan-2" "muletibetan-0")))
92 "*Alist of alternative font registry names.
93 Each element has the form (REGISTRY ALTERNATIVE1 ALTERNATIVE2 ...).
94 If fonts of registry REGISTRY can be loaded, font selection
95 tries to find a best matching font among all fonts of registry
96 REGISTRY, ALTERNATIVE1, ALTERNATIVE2, and etc."
97 :tag "Alternative font registries to try"
98 :type '(repeat (repeat string))
99 :version "21.1"
100 :group 'font-selection
101 :set #'(lambda (symbol value)
102 (set-default symbol value)
103 (internal-set-alternative-font-registry-alist value)))
107 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
108 ;;; Creation, copying.
109 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
112 (defun face-list ()
113 "Return a list of all defined face names."
114 (mapcar #'car face-new-frame-defaults))
117 ;;; ### If not frame-local initialize by what X resources?
119 (defun make-face (face &optional no-init-from-resources)
120 "Define a new face with name FACE, a symbol.
121 NO-INIT-FROM-RESOURCES non-nil means don't initialize frame-local
122 variants of FACE from X resources. (X resources recognized are found
123 in the global variable `face-x-resources'.) If FACE is already known
124 as a face, leave it unmodified. Value is FACE."
125 (interactive "SMake face: ")
126 (unless (facep face)
127 ;; Make frame-local faces (this also makes the global one).
128 (dolist (frame (frame-list))
129 (internal-make-lisp-face face frame))
130 ;; Add the face to the face menu.
131 (when (fboundp 'facemenu-add-new-face)
132 (facemenu-add-new-face face))
133 ;; Define frame-local faces for all frames from X resources.
134 (unless no-init-from-resources
135 (make-face-x-resource-internal face)))
136 face)
139 (defun make-empty-face (face)
140 "Define a new, empty face with name FACE.
141 If the face already exists, it is left unmodified. Value is FACE."
142 (interactive "SMake empty face: ")
143 (make-face face 'no-init-from-resources))
146 (defun copy-face (old-face new-face &optional frame new-frame)
147 "Define a face just like OLD-FACE, with name NEW-FACE.
149 If NEW-FACE already exists as a face, it is modified to be like
150 OLD-FACE. If it doesn't already exist, it is created.
152 If the optional argument FRAME is given as a frame, NEW-FACE is
153 changed on FRAME only.
154 If FRAME is t, the frame-independent default specification for OLD-FACE
155 is copied to NEW-FACE.
156 If FRAME is nil, copying is done for the frame-independent defaults
157 and for each existing frame.
159 If the optional fourth argument NEW-FRAME is given,
160 copy the information from face OLD-FACE on frame FRAME
161 to NEW-FACE on frame NEW-FRAME. In this case, FRAME may not be nil."
162 (let ((inhibit-quit t))
163 (if (null frame)
164 (progn
165 (when new-frame
166 (error "Copying face %s from all frames to one frame"
167 old-face))
168 (make-empty-face new-face)
169 (dolist (frame (frame-list))
170 (copy-face old-face new-face frame))
171 (copy-face old-face new-face t))
172 (make-empty-face new-face)
173 (internal-copy-lisp-face old-face new-face frame new-frame))
174 new-face))
178 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
179 ;;; Obsolete functions
180 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
182 ;; The functions in this section are defined because Lisp packages use
183 ;; them, despite the prefix `internal-' suggesting that they are
184 ;; private to the face implementation.
186 (defun internal-find-face (name &optional frame)
187 "Retrieve the face named NAME.
188 Return nil if there is no such face.
189 If NAME is already a face, it is simply returned.
190 The optional argument FRAME is ignored."
191 (facep name))
192 (make-obsolete 'internal-find-face 'facep "21.1")
195 (defun internal-get-face (name &optional frame)
196 "Retrieve the face named NAME; error if there is none.
197 If NAME is already a face, it is simply returned.
198 The optional argument FRAME is ignored."
199 (or (facep name)
200 (check-face name)))
201 (make-obsolete 'internal-get-face "see `facep' and `check-face'." "21.1")
204 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
205 ;;; Predicates, type checks.
206 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
208 (defun facep (face)
209 "Return non-nil if FACE is a face name or internal face object.
210 Return nil otherwise. A face name can be a string or a symbol.
211 An internal face object is a vector of the kind used internally
212 to record face data."
213 (internal-lisp-face-p face))
216 (defun check-face (face)
217 "Signal an error if FACE doesn't name a face.
218 Value is FACE."
219 (unless (facep face)
220 (error "Not a face: %s" face))
221 face)
224 ;; The ID returned is not to be confused with the internally used IDs
225 ;; of realized faces. The ID assigned to Lisp faces is used to
226 ;; support faces in display table entries.
228 (defun face-id (face &optional frame)
229 "Return the internal ID of face with name FACE.
230 The optional argument FRAME is ignored, since the internal face ID
231 of a face name is the same for all frames."
232 (check-face face)
233 (get face 'face))
236 (defun face-equal (face1 face2 &optional frame)
237 "Non-nil if faces FACE1 and FACE2 are equal.
238 Faces are considered equal if all their attributes are equal.
239 If the optional argument FRAME is given, report on FACE1 and FACE2 in that frame.
240 If FRAME is t, report on the defaults for FACE1 and FACE2 (for new frames).
241 If FRAME is omitted or nil, use the selected frame."
242 (internal-lisp-face-equal-p face1 face2 frame))
245 (defun face-differs-from-default-p (face &optional frame)
246 "Return non-nil if FACE displays differently from the default face.
247 If the optional argument FRAME is given, report on face FACE in that frame.
248 If FRAME is t, report on the defaults for face FACE (for new frames).
249 If FRAME is omitted or nil, use the selected frame."
250 (let ((attrs
251 '(:family :width :height :weight :slant :foreground
252 :background :underline :overline :strike-through
253 :box :inverse-video))
254 (differs nil))
255 (while (and attrs (not differs))
256 (let* ((attr (pop attrs))
257 (attr-val (face-attribute face attr frame t)))
258 (when (and
259 (not (eq attr-val 'unspecified))
260 (display-supports-face-attributes-p (list attr attr-val)
261 frame))
262 (setq differs attr))))
263 differs))
266 (defun face-nontrivial-p (face &optional frame)
267 "True if face FACE has some non-nil attribute.
268 If the optional argument FRAME is given, report on face FACE in that frame.
269 If FRAME is t, report on the defaults for face FACE (for new frames).
270 If FRAME is omitted or nil, use the selected frame."
271 (not (internal-lisp-face-empty-p face frame)))
275 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
276 ;;; Setting face attributes from X resources.
277 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
279 (defcustom face-x-resources
280 '((:family (".attributeFamily" . "Face.AttributeFamily"))
281 (:width (".attributeWidth" . "Face.AttributeWidth"))
282 (:height (".attributeHeight" . "Face.AttributeHeight"))
283 (:weight (".attributeWeight" . "Face.AttributeWeight"))
284 (:slant (".attributeSlant" . "Face.AttributeSlant"))
285 (:foreground (".attributeForeground" . "Face.AttributeForeground"))
286 (:background (".attributeBackground" . "Face.AttributeBackground"))
287 (:overline (".attributeOverline" . "Face.AttributeOverline"))
288 (:strike-through (".attributeStrikeThrough" . "Face.AttributeStrikeThrough"))
289 (:box (".attributeBox" . "Face.AttributeBox"))
290 (:underline (".attributeUnderline" . "Face.AttributeUnderline"))
291 (:inverse-video (".attributeInverse" . "Face.AttributeInverse"))
292 (:stipple
293 (".attributeStipple" . "Face.AttributeStipple")
294 (".attributeBackgroundPixmap" . "Face.AttributeBackgroundPixmap"))
295 (:bold (".attributeBold" . "Face.AttributeBold"))
296 (:italic (".attributeItalic" . "Face.AttributeItalic"))
297 (:font (".attributeFont" . "Face.AttributeFont"))
298 (:inherit (".attributeInherit" . "Face.AttributeInherit")))
299 "*List of X resources and classes for face attributes.
300 Each element has the form (ATTRIBUTE ENTRY1 ENTRY2...) where ATTRIBUTE is
301 the name of a face attribute, and each ENTRY is a cons of the form
302 \(RESOURCE . CLASS) with RESOURCE being the resource and CLASS being the
303 X resource class for the attribute."
304 :type '(repeat (cons symbol (repeat (cons string string))))
305 :group 'faces)
308 (defun set-face-attribute-from-resource (face attribute resource class frame)
309 "Set FACE's ATTRIBUTE from X resource RESOURCE, class CLASS on FRAME.
310 Value is the attribute value specified by the resource, or nil
311 if not present. This function displays a message if the resource
312 specifies an invalid attribute."
313 (let* ((face-name (face-name face))
314 (value (internal-face-x-get-resource (concat face-name resource)
315 class frame)))
316 (when value
317 (condition-case ()
318 (internal-set-lisp-face-attribute-from-resource
319 face attribute (downcase value) frame)
320 (error
321 (message "Face %s, frame %s: invalid attribute %s %s from X resource"
322 face-name frame attribute value))))
323 value))
326 (defun set-face-attributes-from-resources (face frame)
327 "Set attributes of FACE from X resources for FRAME."
328 (when (memq (framep frame) '(x w32 mac))
329 (dolist (definition face-x-resources)
330 (let ((attribute (car definition)))
331 (dolist (entry (cdr definition))
332 (set-face-attribute-from-resource face attribute (car entry)
333 (cdr entry) frame))))))
336 (defun make-face-x-resource-internal (face &optional frame)
337 "Fill frame-local FACE on FRAME from X resources.
338 FRAME nil or not specified means do it for all frames."
339 (if (null frame)
340 (dolist (frame (frame-list))
341 (set-face-attributes-from-resources face frame))
342 (set-face-attributes-from-resources face frame)))
346 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
347 ;;; Retrieving face attributes.
348 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
350 (defun face-name (face)
351 "Return the name of face FACE."
352 (symbol-name (check-face face)))
355 (defun face-attribute (face attribute &optional frame inherit)
356 "Return the value of FACE's ATTRIBUTE on FRAME.
357 If the optional argument FRAME is given, report on face FACE in that frame.
358 If FRAME is t, report on the defaults for face FACE (for new frames).
359 If FRAME is omitted or nil, use the selected frame.
361 If INHERIT is nil, only attributes directly defined by FACE are considered,
362 so the return value may be `unspecified', or a relative value.
363 If INHERIT is non-nil, FACE's definition of ATTRIBUTE is merged with the
364 faces specified by its `:inherit' attribute; however the return value
365 may still be `unspecified' or relative.
366 If INHERIT is a face or a list of faces, then the result is further merged
367 with that face (or faces), until it becomes specified and absolute.
369 To ensure that the return value is always specified and absolute, use a
370 value of `default' for INHERIT; this will resolve any unspecified or
371 relative values by merging with the `default' face (which is always
372 completely specified)."
373 (let ((value (internal-get-lisp-face-attribute face attribute frame)))
374 (when (and inherit (face-attribute-relative-p attribute value))
375 ;; VALUE is relative, so merge with inherited faces
376 (let ((inh-from (face-attribute face :inherit frame)))
377 (unless (or (null inh-from) (eq inh-from 'unspecified))
378 (condition-case nil
379 (setq value
380 (face-attribute-merged-with attribute value inh-from frame))
381 ;; The `inherit' attribute may point to non existent faces.
382 (error nil)))))
383 (when (and inherit
384 (not (eq inherit t))
385 (face-attribute-relative-p attribute value))
386 ;; We should merge with INHERIT as well
387 (setq value (face-attribute-merged-with attribute value inherit frame)))
388 value))
390 (defun face-attribute-merged-with (attribute value faces &optional frame)
391 "Merges ATTRIBUTE, initially VALUE, with faces from FACES until absolute.
392 FACES may be either a single face or a list of faces.
393 \[This is an internal function.]"
394 (cond ((not (face-attribute-relative-p attribute value))
395 value)
396 ((null faces)
397 value)
398 ((consp faces)
399 (face-attribute-merged-with
400 attribute
401 (face-attribute-merged-with attribute value (car faces) frame)
402 (cdr faces)
403 frame))
405 (merge-face-attribute attribute
406 value
407 (face-attribute faces attribute frame t)))))
410 (defmacro face-attribute-specified-or (value &rest body)
411 "Return VALUE, unless it's `unspecified', in which case evaluate BODY and return the result."
412 (let ((temp (make-symbol "value")))
413 `(let ((,temp ,value))
414 (if (not (eq ,temp 'unspecified))
415 ,temp
416 ,@body))))
418 (defun face-foreground (face &optional frame inherit)
419 "Return the foreground color name of FACE, or nil if unspecified.
420 If the optional argument FRAME is given, report on face FACE in that frame.
421 If FRAME is t, report on the defaults for face FACE (for new frames).
422 If FRAME is omitted or nil, use the selected frame.
424 If INHERIT is nil, only a foreground color directly defined by FACE is
425 considered, so the return value may be nil.
426 If INHERIT is t, and FACE doesn't define a foreground color, then any
427 foreground color that FACE inherits through its `:inherit' attribute
428 is considered as well; however the return value may still be nil.
429 If INHERIT is a face or a list of faces, then it is used to try to
430 resolve an unspecified foreground color.
432 To ensure that a valid color is always returned, use a value of
433 `default' for INHERIT; this will resolve any unspecified values by
434 merging with the `default' face (which is always completely specified)."
435 (face-attribute-specified-or (face-attribute face :foreground frame inherit)
436 nil))
438 (defun face-background (face &optional frame inherit)
439 "Return the background color name of FACE, or nil if unspecified.
440 If the optional argument FRAME is given, report on face FACE in that frame.
441 If FRAME is t, report on the defaults for face FACE (for new frames).
442 If FRAME is omitted or nil, use the selected frame.
444 If INHERIT is nil, only a background color directly defined by FACE is
445 considered, so the return value may be nil.
446 If INHERIT is t, and FACE doesn't define a background color, then any
447 background color that FACE inherits through its `:inherit' attribute
448 is considered as well; however the return value may still be nil.
449 If INHERIT is a face or a list of faces, then it is used to try to
450 resolve an unspecified background color.
452 To ensure that a valid color is always returned, use a value of
453 `default' for INHERIT; this will resolve any unspecified values by
454 merging with the `default' face (which is always completely specified)."
455 (face-attribute-specified-or (face-attribute face :background frame inherit)
456 nil))
458 (defun face-stipple (face &optional frame inherit)
459 "Return the stipple pixmap name of FACE, or nil if unspecified.
460 If the optional argument FRAME is given, report on face FACE in that frame.
461 If FRAME is t, report on the defaults for face FACE (for new frames).
462 If FRAME is omitted or nil, use the selected frame.
464 If INHERIT is nil, only a stipple directly defined by FACE is
465 considered, so the return value may be nil.
466 If INHERIT is t, and FACE doesn't define a stipple, then any stipple
467 that FACE inherits through its `:inherit' attribute is considered as
468 well; however the return value may still be nil.
469 If INHERIT is a face or a list of faces, then it is used to try to
470 resolve an unspecified stipple.
472 To ensure that a valid stipple or nil is always returned, use a value of
473 `default' for INHERIT; this will resolve any unspecified values by merging
474 with the `default' face (which is always completely specified)."
475 (face-attribute-specified-or (face-attribute face :stipple frame inherit)
476 nil))
479 (defalias 'face-background-pixmap 'face-stipple)
482 (defun face-underline-p (face &optional frame)
483 "Return non-nil if FACE is underlined.
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 :underline frame) t))
490 (defun face-inverse-video-p (face &optional frame)
491 "Return non-nil if FACE is in inverse video 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 (eq (face-attribute face :inverse-video frame) t))
498 (defun face-bold-p (face &optional frame)
499 "Return non-nil if the font of FACE is bold on FRAME.
500 If the optional argument FRAME is given, report on face FACE in that frame.
501 If FRAME is t, report on the defaults for face FACE (for new frames).
502 If FRAME is omitted or nil, use the selected frame.
503 Use `face-attribute' for finer control."
504 (let ((bold (face-attribute face :weight frame)))
505 (memq bold '(semi-bold bold extra-bold ultra-bold))))
508 (defun face-italic-p (face &optional frame)
509 "Return non-nil if the font of FACE is italic on FRAME.
510 If the optional argument FRAME is given, report on face FACE in that frame.
511 If FRAME is t, report on the defaults for face FACE (for new frames).
512 If FRAME is omitted or nil, use the selected frame.
513 Use `face-attribute' for finer control."
514 (let ((italic (face-attribute face :slant frame)))
515 (memq italic '(italic oblique))))
519 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
520 ;;; Face documentation.
521 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
523 (defun face-documentation (face)
524 "Get the documentation string for FACE.
525 If FACE is a face-alias, get the documentation for the target face."
526 (let ((alias (get face 'face-alias))
527 doc)
528 (if alias
529 (progn
530 (setq doc (get alias 'face-documentation))
531 (format "%s is an alias for the face `%s'.%s" face alias
532 (if doc (format "\n%s" doc)
533 "")))
534 (get face 'face-documentation))))
537 (defun set-face-documentation (face string)
538 "Set the documentation string for FACE to STRING."
539 ;; Perhaps the text should go in DOC.
540 (put face 'face-documentation (purecopy string)))
543 (defalias 'face-doc-string 'face-documentation)
544 (defalias 'set-face-doc-string 'set-face-documentation)
548 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
549 ;; Setting face attributes.
550 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
553 (defvar inhibit-face-set-after-frame-default nil
554 "If non-nil, that tells `face-set-after-frame-default' to do nothing.")
556 (defun set-face-attribute (face frame &rest args)
557 "Set attributes of FACE on FRAME from ARGS.
559 FRAME nil means change attributes on all frames. FRAME t means change
560 the default for new frames (this is done automatically each time an
561 attribute is changed on all frames).
563 ARGS must come in pairs ATTRIBUTE VALUE. ATTRIBUTE must be a valid
564 face attribute name. All attributes can be set to `unspecified';
565 this fact is not further mentioned below.
567 The following attributes are recognized:
569 `:family'
571 VALUE must be a string specifying the font family, e.g. ``courier'',
572 or a fontset alias name. If a font family is specified, wild-cards `*'
573 and `?' are allowed.
575 `:width'
577 VALUE specifies the relative proportionate width of the font to use.
578 It must be one of the symbols `ultra-condensed', `extra-condensed',
579 `condensed', `semi-condensed', `normal', `semi-expanded', `expanded',
580 `extra-expanded', or `ultra-expanded'.
582 `:height'
584 VALUE must be either an integer specifying the height of the font to use
585 in 1/10 pt, a floating point number specifying the amount by which to
586 scale any underlying face, or a function, which is called with the old
587 height (from the underlying face), and should return the new height.
589 `:weight'
591 VALUE specifies the weight of the font to use. It must be one of the
592 symbols `ultra-bold', `extra-bold', `bold', `semi-bold', `normal',
593 `semi-light', `light', `extra-light', `ultra-light'.
595 `:slant'
597 VALUE specifies the slant of the font to use. It must be one of the
598 symbols `italic', `oblique', `normal', `reverse-italic', or
599 `reverse-oblique'.
601 `:foreground', `:background'
603 VALUE must be a color name, a string.
605 `:underline'
607 VALUE specifies whether characters in FACE should be underlined. If
608 VALUE is t, underline with foreground color of the face. If VALUE is
609 a string, underline with that color. If VALUE is nil, explicitly
610 don't underline.
612 `:overline'
614 VALUE specifies whether characters in FACE should be overlined. If
615 VALUE is t, overline with foreground color of the face. If VALUE is a
616 string, overline with that color. If VALUE is nil, explicitly don't
617 overline.
619 `:strike-through'
621 VALUE specifies whether characters in FACE should be drawn with a line
622 striking through them. If VALUE is t, use the foreground color of the
623 face. If VALUE is a string, strike-through with that color. If VALUE
624 is nil, explicitly don't strike through.
626 `:box'
628 VALUE specifies whether characters in FACE should have a box drawn
629 around them. If VALUE is nil, explicitly don't draw boxes. If
630 VALUE is t, draw a box with lines of width 1 in the foreground color
631 of the face. If VALUE is a string, the string must be a color name,
632 and the box is drawn in that color with a line width of 1. Otherwise,
633 VALUE must be a property list of the form `(:line-width WIDTH
634 :color COLOR :style STYLE)'. If a keyword/value pair is missing from
635 the property list, a default value will be used for the value, as
636 specified below. WIDTH specifies the width of the lines to draw; it
637 defaults to 1. If WIDTH is negative, the absolute value is the width
638 of the lines, and draw top/bottom lines inside the characters area,
639 not around it. COLOR is the name of the color to draw in, default is
640 the foreground color of the face for simple boxes, and the background
641 color of the face for 3D boxes. STYLE specifies whether a 3D box
642 should be draw. If STYLE is `released-button', draw a box looking
643 like a released 3D button. If STYLE is `pressed-button' draw a box
644 that appears like a pressed button. If STYLE is nil, the default if
645 the property list doesn't contain a style specification, draw a 2D
646 box.
648 `:inverse-video'
650 VALUE specifies whether characters in FACE should be displayed in
651 inverse video. VALUE must be one of t or nil.
653 `:stipple'
655 If VALUE is a string, it must be the name of a file of pixmap data.
656 The directories listed in the `x-bitmap-file-path' variable are
657 searched. Alternatively, VALUE may be a list of the form (WIDTH
658 HEIGHT DATA) where WIDTH and HEIGHT are the size in pixels, and DATA
659 is a string containing the raw bits of the bitmap. VALUE nil means
660 explicitly don't use a stipple pattern.
662 For convenience, attributes `:family', `:width', `:height', `:weight',
663 and `:slant' may also be set in one step from an X font name:
665 `:font'
667 Set font-related face attributes from VALUE. VALUE must be a valid
668 XLFD font name. If it is a font name pattern, the first matching font
669 will be used.
671 For compatibility with Emacs 20, keywords `:bold' and `:italic' can
672 be used to specify that a bold or italic font should be used. VALUE
673 must be t or nil in that case. A value of `unspecified' is not allowed.
675 `:inherit'
677 VALUE is the name of a face from which to inherit attributes, or a list
678 of face names. Attributes from inherited faces are merged into the face
679 like an underlying face would be, with higher priority than underlying faces."
680 (let ((where (if (null frame) 0 frame)))
681 (setq args (purecopy args))
682 ;; If we set the new-frame defaults, this face is modified outside Custom.
683 (if (memq where '(0 t))
684 (put (or (get face 'face-alias) face) 'face-modified t))
685 (while args
686 ;; Don't recursively set the attributes from the frame's font param
687 ;; when we update the frame's font param fro the attributes.
688 (let ((inhibit-face-set-after-frame-default t))
689 (internal-set-lisp-face-attribute face (car args)
690 (purecopy (cadr args))
691 where))
692 (setq args (cdr (cdr args))))))
695 (defun make-face-bold (face &optional frame noerror)
696 "Make the font of FACE be bold, if possible.
697 FRAME nil or not specified means change face on all frames.
698 Argument NOERROR is ignored and retained for compatibility.
699 Use `set-face-attribute' for finer control of the font weight."
700 (interactive (list (read-face-name "Make which face bold")))
701 (set-face-attribute face frame :weight 'bold))
704 (defun make-face-unbold (face &optional frame noerror)
705 "Make the font of FACE be non-bold, if possible.
706 FRAME nil or not specified means change face on all frames.
707 Argument NOERROR is ignored and retained for compatibility."
708 (interactive (list (read-face-name "Make which face non-bold")))
709 (set-face-attribute face frame :weight 'normal))
712 (defun make-face-italic (face &optional frame noerror)
713 "Make the font of FACE be italic, if possible.
714 FRAME nil or not specified means change face on all frames.
715 Argument NOERROR is ignored and retained for compatibility.
716 Use `set-face-attribute' for finer control of the font slant."
717 (interactive (list (read-face-name "Make which face italic")))
718 (set-face-attribute face frame :slant 'italic))
721 (defun make-face-unitalic (face &optional frame noerror)
722 "Make the font of FACE be non-italic, if possible.
723 FRAME nil or not specified means change face on all frames.
724 Argument NOERROR is ignored and retained for compatibility."
725 (interactive (list (read-face-name "Make which face non-italic")))
726 (set-face-attribute face frame :slant 'normal))
729 (defun make-face-bold-italic (face &optional frame noerror)
730 "Make the font of FACE be bold and italic, if possible.
731 FRAME nil or not specified means change face on all frames.
732 Argument NOERROR is ignored and retained for compatibility.
733 Use `set-face-attribute' for finer control of font weight and slant."
734 (interactive (list (read-face-name "Make which face bold-italic")))
735 (set-face-attribute face frame :weight 'bold :slant 'italic))
738 (defun set-face-font (face font &optional frame)
739 "Change font-related attributes of FACE to those of FONT (a string).
740 FRAME nil or not specified means change face on all frames.
741 This sets the attributes `:family', `:width', `:height', `:weight',
742 and `:slant'. When called interactively, prompt for the face and font."
743 (interactive (read-face-and-attribute :font))
744 (set-face-attribute face frame :font font))
747 ;; Implementation note: Emulating gray background colors with a
748 ;; stipple pattern is now part of the face realization process, and is
749 ;; done in C depending on the frame on which the face is realized.
751 (defun set-face-background (face color &optional frame)
752 "Change the background color of face FACE to COLOR (a string).
753 FRAME nil or not specified means change face on all frames.
754 COLOR can be a system-defined color name (see `list-colors-display')
755 or a hex spec of the form #RRGGBB.
756 When called interactively, prompts for the face and color."
757 (interactive (read-face-and-attribute :background))
758 (set-face-attribute face frame :background (or color 'unspecified)))
761 (defun set-face-foreground (face color &optional frame)
762 "Change the foreground color of face FACE to COLOR (a string).
763 FRAME nil or not specified means change face on all frames.
764 COLOR can be a system-defined color name (see `list-colors-display')
765 or a hex spec of the form #RRGGBB.
766 When called interactively, prompts for the face and color."
767 (interactive (read-face-and-attribute :foreground))
768 (set-face-attribute face frame :foreground (or color 'unspecified)))
771 (defun set-face-stipple (face stipple &optional frame)
772 "Change the stipple pixmap of face FACE to STIPPLE.
773 FRAME nil or not specified means change face on all frames.
774 STIPPLE should be a string, the name of a file of pixmap data.
775 The directories listed in the `x-bitmap-file-path' variable are searched.
777 Alternatively, STIPPLE may be a list of the form (WIDTH HEIGHT DATA)
778 where WIDTH and HEIGHT are the size in pixels,
779 and DATA is a string, containing the raw bits of the bitmap."
780 (interactive (read-face-and-attribute :stipple))
781 (set-face-attribute face frame :stipple (or stipple 'unspecified)))
784 (defun set-face-underline-p (face underline &optional frame)
785 "Specify whether face FACE is underlined.
786 UNDERLINE nil means FACE explicitly doesn't underline.
787 UNDERLINE non-nil means FACE explicitly does underlining
788 with the same of the foreground color.
789 If UNDERLINE is a string, underline with the color named UNDERLINE.
790 FRAME nil or not specified means change face on all frames.
791 Use `set-face-attribute' to ``unspecify'' underlining."
792 (interactive
793 (let ((list (read-face-and-attribute :underline)))
794 (list (car list) (eq (car (cdr list)) t))))
795 (set-face-attribute face frame :underline underline))
797 (define-obsolete-function-alias 'set-face-underline
798 'set-face-underline-p "22.1")
801 (defun set-face-inverse-video-p (face inverse-video-p &optional frame)
802 "Specify whether face FACE is in inverse video.
803 INVERSE-VIDEO-P non-nil means FACE displays explicitly in inverse video.
804 INVERSE-VIDEO-P nil means FACE explicitly is not in inverse video.
805 FRAME nil or not specified means change face on all frames.
806 Use `set-face-attribute' to ``unspecify'' the inverse video attribute."
807 (interactive
808 (let ((list (read-face-and-attribute :inverse-video)))
809 (list (car list) (eq (car (cdr list)) t))))
810 (set-face-attribute face frame :inverse-video inverse-video-p))
813 (defun set-face-bold-p (face bold-p &optional frame)
814 "Specify whether face FACE is bold.
815 BOLD-P non-nil means FACE should explicitly display bold.
816 BOLD-P nil means FACE should explicitly display non-bold.
817 FRAME nil or not specified means change face on all frames.
818 Use `set-face-attribute' or `modify-face' for finer control."
819 (if (null bold-p)
820 (make-face-unbold face frame)
821 (make-face-bold face frame)))
824 (defun set-face-italic-p (face italic-p &optional frame)
825 "Specify whether face FACE is italic.
826 ITALIC-P non-nil means FACE should explicitly display italic.
827 ITALIC-P nil means FACE should explicitly display non-italic.
828 FRAME nil or not specified means change face on all frames.
829 Use `set-face-attribute' or `modify-face' for finer control."
830 (if (null italic-p)
831 (make-face-unitalic face frame)
832 (make-face-italic face frame)))
835 (defalias 'set-face-background-pixmap 'set-face-stipple)
838 (defun invert-face (face &optional frame)
839 "Swap the foreground and background colors of FACE.
840 If FRAME is omitted or nil, it means change face on all frames.
841 If FACE specifies neither foreground nor background color,
842 set its foreground and background to the background and foreground
843 of the default face. Value is FACE."
844 (interactive (list (read-face-name "Invert face")))
845 (let ((fg (face-attribute face :foreground frame))
846 (bg (face-attribute face :background frame)))
847 (if (not (and (eq fg 'unspecified) (eq bg 'unspecified)))
848 (set-face-attribute face frame :foreground bg :background fg)
849 (set-face-attribute face frame
850 :foreground
851 (face-attribute 'default :background frame)
852 :background
853 (face-attribute 'default :foreground frame))))
854 face)
857 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
858 ;;; Interactively modifying faces.
859 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
861 (defun read-face-name (prompt &optional string-describing-default multiple)
862 "Read a face, defaulting to the face or faces on the char after point.
863 If it has the property `read-face-name', that overrides the `face' property.
864 PROMPT should be a string that describes what the caller will do with the face;
865 it should not end in a space.
866 STRING-DESCRIBING-DEFAULT should describe what default the caller will use if
867 the user just types RET; you can omit it.
868 If MULTIPLE is non-nil, return a list of faces (possibly only one).
869 Otherwise, return a single face."
870 (let ((faceprop (or (get-char-property (point) 'read-face-name)
871 (get-char-property (point) 'face)))
872 (aliasfaces nil)
873 (nonaliasfaces nil)
874 faces)
875 ;; Try to get a face name from the buffer.
876 (if (memq (intern-soft (thing-at-point 'symbol)) (face-list))
877 (setq faces (list (intern-soft (thing-at-point 'symbol)))))
878 ;; Add the named faces that the `face' property uses.
879 (if (and (listp faceprop)
880 ;; Don't treat an attribute spec as a list of faces.
881 (not (keywordp (car faceprop)))
882 (not (memq (car faceprop) '(foreground-color background-color))))
883 (dolist (f faceprop)
884 (if (symbolp f)
885 (push f faces)))
886 (if (symbolp faceprop)
887 (push faceprop faces)))
888 (delete-dups faces)
890 ;; Build up the completion tables.
891 (mapatoms (lambda (s)
892 (if (custom-facep s)
893 (if (get s 'face-alias)
894 (push (symbol-name s) aliasfaces)
895 (push (symbol-name s) nonaliasfaces)))))
897 ;; If we only want one, and the default is more than one,
898 ;; discard the unwanted ones now.
899 (unless multiple
900 (if faces
901 (setq faces (list (car faces)))))
902 (require 'crm)
903 (let* ((input
904 ;; Read the input.
905 (completing-read-multiple
906 (if (or faces string-describing-default)
907 (format "%s (default %s): " prompt
908 (if faces (mapconcat 'symbol-name faces ",")
909 string-describing-default))
910 (format "%s: " prompt))
911 (complete-in-turn nonaliasfaces aliasfaces)
912 nil t nil nil
913 (if faces (mapconcat 'symbol-name faces ","))))
914 ;; Canonicalize the output.
915 (output
916 (cond ((or (equal input "") (equal input '("")))
917 faces)
918 ((stringp input)
919 (mapcar 'intern (split-string input ", *" t)))
920 ((listp input)
921 (mapcar 'intern input))
922 (input))))
923 ;; Return either a list of faces or just one face.
924 (if multiple
925 output
926 (car output)))))
929 (defun face-valid-attribute-values (attribute &optional frame)
930 "Return valid values for face attribute ATTRIBUTE.
931 The optional argument FRAME is used to determine available fonts
932 and colors. If it is nil or not specified, the selected frame is
933 used. Value is an alist of (NAME . VALUE) if ATTRIBUTE expects a value
934 out of a set of discrete values. Value is `integerp' if ATTRIBUTE expects
935 an integer value."
936 (let ((valid
937 (case attribute
938 (:family
939 (if window-system
940 (mapcar #'(lambda (x) (cons (car x) (car x)))
941 (x-font-family-list))
942 ;; Only one font on TTYs.
943 (list (cons "default" "default"))))
944 ((:width :weight :slant :inverse-video)
945 (mapcar #'(lambda (x) (cons (symbol-name x) x))
946 (internal-lisp-face-attribute-values attribute)))
947 ((:underline :overline :strike-through :box)
948 (if window-system
949 (nconc (mapcar #'(lambda (x) (cons (symbol-name x) x))
950 (internal-lisp-face-attribute-values attribute))
951 (mapcar #'(lambda (c) (cons c c))
952 (defined-colors frame)))
953 (mapcar #'(lambda (x) (cons (symbol-name x) x))
954 (internal-lisp-face-attribute-values attribute))))
955 ((:foreground :background)
956 (mapcar #'(lambda (c) (cons c c))
957 (defined-colors frame)))
958 ((:height)
959 'integerp)
960 (:stipple
961 (and (memq window-system '(x w32 mac))
962 (mapcar #'list
963 (apply #'nconc
964 (mapcar (lambda (dir)
965 (and (file-readable-p dir)
966 (file-directory-p dir)
967 (directory-files dir)))
968 x-bitmap-file-path)))))
969 (:inherit
970 (cons '("none" . nil)
971 (mapcar #'(lambda (c) (cons (symbol-name c) c))
972 (face-list))))
974 (error "Internal error")))))
975 (if (and (listp valid) (not (memq attribute '(:inherit))))
976 (nconc (list (cons "unspecified" 'unspecified)) valid)
977 valid)))
980 (defvar face-attribute-name-alist
981 '((:family . "font family")
982 (:width . "character set width")
983 (:height . "height in 1/10 pt")
984 (:weight . "weight")
985 (:slant . "slant")
986 (:underline . "underline")
987 (:overline . "overline")
988 (:strike-through . "strike-through")
989 (:box . "box")
990 (:inverse-video . "inverse-video display")
991 (:foreground . "foreground color")
992 (:background . "background color")
993 (:stipple . "background stipple")
994 (:inherit . "inheritance"))
995 "An alist of descriptive names for face attributes.
996 Each element has the form (ATTRIBUTE-NAME . DESCRIPTION) where
997 ATTRIBUTE-NAME is a face attribute name (a keyword symbol), and
998 DESCRIPTION is a descriptive name for ATTRIBUTE-NAME.")
1001 (defun face-descriptive-attribute-name (attribute)
1002 "Return a descriptive name for ATTRIBUTE."
1003 (cdr (assq attribute face-attribute-name-alist)))
1006 (defun face-read-string (face default name &optional completion-alist)
1007 "Interactively read a face attribute string value.
1008 FACE is the face whose attribute is read. If non-nil, DEFAULT is the
1009 default string to return if no new value is entered. NAME is a
1010 descriptive name of the attribute for prompting. COMPLETION-ALIST is an
1011 alist of valid values, if non-nil.
1013 Entering nothing accepts the default string DEFAULT.
1014 Value is the new attribute value."
1015 ;; Capitalize NAME (we don't use `capitalize' because that capitalizes
1016 ;; each word in a string separately).
1017 (setq name (concat (upcase (substring name 0 1)) (substring name 1)))
1018 (let* ((completion-ignore-case t)
1019 (value (completing-read
1020 (if default
1021 (format "%s for face `%s' (default %s): "
1022 name face default)
1023 (format "%s for face `%s': " name face))
1024 completion-alist nil nil nil nil default)))
1025 (if (equal value "") default value)))
1028 (defun face-read-integer (face default name)
1029 "Interactively read an integer face attribute value.
1030 FACE is the face whose attribute is read. DEFAULT is the default
1031 value to return if no new value is entered. NAME is a descriptive
1032 name of the attribute for prompting. Value is the new attribute value."
1033 (let ((new-value
1034 (face-read-string face
1035 (format "%s" default)
1036 name
1037 (list (cons "unspecified" 'unspecified)))))
1038 (cond ((equal new-value "unspecified")
1039 'unspecified)
1040 ((member new-value '("unspecified-fg" "unspecified-bg"))
1041 new-value)
1043 (string-to-number new-value)))))
1046 (defun read-face-attribute (face attribute &optional frame)
1047 "Interactively read a new value for FACE's ATTRIBUTE.
1048 Optional argument FRAME nil or unspecified means read an attribute value
1049 of a global face. Value is the new attribute value."
1050 (let* ((old-value (face-attribute face attribute frame))
1051 (attribute-name (face-descriptive-attribute-name attribute))
1052 (valid (face-valid-attribute-values attribute frame))
1053 new-value)
1054 ;; Represent complex attribute values as strings by printing them
1055 ;; out. Stipple can be a vector; (WIDTH HEIGHT DATA). Box can be
1056 ;; a list `(:width WIDTH :color COLOR)' or `(:width WIDTH :shadow
1057 ;; SHADOW)'.
1058 (when (and (or (eq attribute :stipple)
1059 (eq attribute :box))
1060 (or (consp old-value)
1061 (vectorp old-value)))
1062 (setq old-value (prin1-to-string old-value)))
1063 (cond ((listp valid)
1064 (let ((default
1065 (or (car (rassoc old-value valid))
1066 (format "%s" old-value))))
1067 (setq new-value
1068 (face-read-string face default attribute-name valid))
1069 (if (equal new-value default)
1070 ;; Nothing changed, so don't bother with all the stuff
1071 ;; below. In particular, this avoids a non-tty color
1072 ;; from being canonicalized for a tty when the user
1073 ;; just uses the default.
1074 (setq new-value old-value)
1075 ;; Terminal frames can support colors that don't appear
1076 ;; explicitly in VALID, using color approximation code
1077 ;; in tty-colors.el.
1078 (when (and (memq attribute '(:foreground :background))
1079 (not (memq window-system '(x w32 mac)))
1080 (not (member new-value
1081 '("unspecified"
1082 "unspecified-fg" "unspecified-bg"))))
1083 (setq new-value (car (tty-color-desc new-value frame))))
1084 (when (assoc new-value valid)
1085 (setq new-value (cdr (assoc new-value valid)))))))
1086 ((eq valid 'integerp)
1087 (setq new-value (face-read-integer face old-value attribute-name)))
1088 (t (error "Internal error")))
1089 ;; Convert stipple and box value text we read back to a list or
1090 ;; vector if it looks like one. This makes the assumption that a
1091 ;; pixmap file name won't start with an open-paren.
1092 (when (and (or (eq attribute :stipple)
1093 (eq attribute :box))
1094 (stringp new-value)
1095 (string-match "^[[(]" new-value))
1096 (setq new-value (read new-value)))
1097 new-value))
1100 (defun read-face-font (face &optional frame)
1101 "Read the name of a font for FACE on FRAME.
1102 If optional argument FRAME is nil or omitted, use the selected frame."
1103 (let ((completion-ignore-case t))
1104 (completing-read (format "Set font attributes of face `%s' from font: " face)
1105 (x-list-fonts "*" nil frame))))
1108 (defun read-all-face-attributes (face &optional frame)
1109 "Interactively read all attributes for FACE.
1110 If optional argument FRAME is nil or omitted, use the selected frame.
1111 Value is a property list of attribute names and new values."
1112 (let (result)
1113 (dolist (attribute face-attribute-name-alist result)
1114 (setq result (cons (car attribute)
1115 (cons (read-face-attribute face (car attribute) frame)
1116 result))))))
1118 (defun modify-face (&optional face foreground background stipple
1119 bold-p italic-p underline inverse-p frame)
1120 "Modify attributes of faces interactively.
1121 If optional argument FRAME is nil or omitted, modify the face used
1122 for newly created frame, i.e. the global face.
1123 For non-interactive use, `set-face-attribute' is preferred.
1124 When called from Lisp, if FACE is nil, all arguments but FRAME are ignored
1125 and the face and its settings are obtained by querying the user."
1126 (interactive)
1127 (if face
1128 (set-face-attribute face frame
1129 :foreground (or foreground 'unspecified)
1130 :background (or background 'unspecified)
1131 :stipple stipple
1132 :bold bold-p
1133 :italic italic-p
1134 :underline underline
1135 :inverse-video inverse-p)
1136 (setq face (read-face-name "Modify face"))
1137 (apply #'set-face-attribute face frame
1138 (read-all-face-attributes face frame))))
1140 (defun read-face-and-attribute (attribute &optional frame)
1141 "Read face name and face attribute value.
1142 ATTRIBUTE is the attribute whose new value is read.
1143 FRAME nil or unspecified means read attribute value of global face.
1144 Value is a list (FACE NEW-VALUE) where FACE is the face read
1145 \(a symbol), and NEW-VALUE is value read."
1146 (cond ((eq attribute :font)
1147 (let* ((prompt "Set font-related attributes of face")
1148 (face (read-face-name prompt))
1149 (font (read-face-font face frame)))
1150 (list face font)))
1152 (let* ((attribute-name (face-descriptive-attribute-name attribute))
1153 (prompt (format "Set %s of face" attribute-name))
1154 (face (read-face-name prompt))
1155 (new-value (read-face-attribute face attribute frame)))
1156 (list face new-value)))))
1160 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1161 ;;; Listing faces.
1162 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1164 (defvar list-faces-sample-text
1165 "abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ"
1166 "*Text string to display as the sample text for `list-faces-display'.")
1169 ;; The name list-faces would be more consistent, but let's avoid a
1170 ;; conflict with Lucid, which uses that name differently.
1172 (defvar help-xref-stack)
1173 (defun list-faces-display (&optional regexp)
1174 "List all faces, using the same sample text in each.
1175 The sample text is a string that comes from the variable
1176 `list-faces-sample-text'.
1178 If REGEXP is non-nil, list only those faces with names matching
1179 this regular expression. When called interactively with a prefix
1180 arg, prompt for a regular expression."
1181 (interactive (list (and current-prefix-arg
1182 (read-string "List faces matching regexp: "))))
1183 (let ((all-faces (zerop (length regexp)))
1184 (frame (selected-frame))
1185 (max-length 0)
1186 faces line-format
1187 disp-frame window face-name)
1188 ;; We filter and take the max length in one pass
1189 (setq faces
1190 (delq nil
1191 (mapcar (lambda (f)
1192 (let ((s (symbol-name f)))
1193 (when (or all-faces (string-match regexp s))
1194 (setq max-length (max (length s) max-length))
1195 f)))
1196 (sort (face-list) #'string-lessp))))
1197 (unless faces
1198 (error "No faces matching \"%s\"" regexp))
1199 (setq max-length (1+ max-length)
1200 line-format (format "%%-%ds" max-length))
1201 (with-output-to-temp-buffer "*Faces*"
1202 (save-excursion
1203 (set-buffer standard-output)
1204 (setq truncate-lines t)
1205 (insert
1206 (substitute-command-keys
1207 (concat
1208 "Use "
1209 (if (display-mouse-p) "\\[help-follow-mouse] or ")
1210 "\\[help-follow] on a face name to customize it\n"
1211 "or on its sample text for a description of the face.\n\n")))
1212 (setq help-xref-stack nil)
1213 (dolist (face faces)
1214 (setq face-name (symbol-name face))
1215 (insert (format line-format face-name))
1216 ;; Hyperlink to a customization buffer for the face. Using
1217 ;; the help xref mechanism may not be the best way.
1218 (save-excursion
1219 (save-match-data
1220 (search-backward face-name)
1221 (setq help-xref-stack-item `(list-faces-display ,regexp))
1222 (help-xref-button 0 'help-customize-face face)))
1223 (let ((beg (point))
1224 (line-beg (line-beginning-position)))
1225 (insert list-faces-sample-text)
1226 ;; Hyperlink to a help buffer for the face.
1227 (save-excursion
1228 (save-match-data
1229 (search-backward list-faces-sample-text)
1230 (help-xref-button 0 'help-face face)))
1231 (insert "\n")
1232 (put-text-property beg (1- (point)) 'face face)
1233 ;; Make all face commands default to the proper face
1234 ;; anywhere in the line.
1235 (put-text-property line-beg (1- (point)) 'read-face-name face)
1236 ;; If the sample text has multiple lines, line up all of them.
1237 (goto-char beg)
1238 (forward-line 1)
1239 (while (not (eobp))
1240 (insert-char ?\s max-length)
1241 (forward-line 1))))
1242 (goto-char (point-min)))
1243 (print-help-return-message))
1244 ;; If the *Faces* buffer appears in a different frame,
1245 ;; copy all the face definitions from FRAME,
1246 ;; so that the display will reflect the frame that was selected.
1247 (setq window (get-buffer-window (get-buffer "*Faces*") t))
1248 (setq disp-frame (if window (window-frame window)
1249 (car (frame-list))))
1250 (or (eq frame disp-frame)
1251 (let ((faces (face-list)))
1252 (while faces
1253 (copy-face (car faces) (car faces) frame disp-frame)
1254 (setq faces (cdr faces)))))))
1257 (defun describe-face (face &optional frame)
1258 "Display the properties of face FACE on FRAME.
1259 Interactively, FACE defaults to the faces of the character after point
1260 and FRAME defaults to the selected frame.
1262 If the optional argument FRAME is given, report on face FACE in that frame.
1263 If FRAME is t, report on the defaults for face FACE (for new frames).
1264 If FRAME is omitted or nil, use the selected frame."
1265 (interactive (list (read-face-name "Describe face" "= `default' face" t)))
1266 (let* ((attrs '((:family . "Family")
1267 (:width . "Width")
1268 (:height . "Height")
1269 (:weight . "Weight")
1270 (:slant . "Slant")
1271 (:foreground . "Foreground")
1272 (:background . "Background")
1273 (:underline . "Underline")
1274 (:overline . "Overline")
1275 (:strike-through . "Strike-through")
1276 (:box . "Box")
1277 (:inverse-video . "Inverse")
1278 (:stipple . "Stipple")
1279 (:font . "Font or fontset")
1280 (:inherit . "Inherit")))
1281 (max-width (apply #'max (mapcar #'(lambda (x) (length (cdr x)))
1282 attrs))))
1283 (help-setup-xref (list #'describe-face face) (interactive-p))
1284 (unless face
1285 (setq face 'default))
1286 (if (not (listp face))
1287 (setq face (list face)))
1288 (with-output-to-temp-buffer (help-buffer)
1289 (save-excursion
1290 (set-buffer standard-output)
1291 (dolist (f face)
1292 (insert "Face: " (symbol-name f))
1293 (if (not (facep f))
1294 (insert " undefined face.\n")
1295 (let ((customize-label "customize this face")
1296 file-name)
1297 (insert (concat " (" (propertize "sample" 'font-lock-face f) ")"))
1298 (princ (concat " (" customize-label ")\n"))
1299 (insert "Documentation: "
1300 (or (face-documentation f)
1301 "Not documented as a face.")
1302 "\n")
1303 (with-current-buffer standard-output
1304 (save-excursion
1305 (re-search-backward
1306 (concat "\\(" customize-label "\\)") nil t)
1307 (help-xref-button 1 'help-customize-face f)))
1308 ;; The next 4 sexps are copied from describe-function-1
1309 ;; and simplified.
1310 (setq file-name (symbol-file f 'defface))
1311 (setq file-name (describe-simplify-lib-file-name file-name))
1312 (when file-name
1313 (princ "Defined in `")
1314 (princ file-name)
1315 (princ "'")
1316 ;; Make a hyperlink to the library.
1317 (save-excursion
1318 (re-search-backward "`\\([^`']+\\)'" nil t)
1319 (help-xref-button 1 'help-face-def f file-name))
1320 (princ ".")
1321 (terpri)
1322 (terpri))
1323 (dolist (a attrs)
1324 (let ((attr (face-attribute f (car a) frame)))
1325 (insert (make-string (- max-width (length (cdr a))) ?\s)
1326 (cdr a) ": " (format "%s" attr))
1327 (if (and (eq (car a) :inherit)
1328 (not (eq attr 'unspecified)))
1329 ;; Make a hyperlink to the parent face.
1330 (save-excursion
1331 (re-search-backward ": \\([^:]+\\)" nil t)
1332 (help-xref-button 1 'help-face attr)))
1333 (insert "\n")))))
1334 (terpri)))
1335 (print-help-return-message))))
1338 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1339 ;;; Face specifications (defface).
1340 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1342 ;; Parameter FRAME Is kept for call compatibility to with previous
1343 ;; face implementation.
1345 (defun face-attr-construct (face &optional frame)
1346 "Return a `defface'-style attribute list for FACE on FRAME.
1347 Value is a property list of pairs ATTRIBUTE VALUE for all specified
1348 face attributes of FACE where ATTRIBUTE is the attribute name and
1349 VALUE is the specified value of that attribute."
1350 (let (result)
1351 (dolist (entry face-attribute-name-alist result)
1352 (let* ((attribute (car entry))
1353 (value (face-attribute face attribute)))
1354 (unless (eq value 'unspecified)
1355 (setq result (nconc (list attribute value) result)))))))
1358 (defun face-spec-set-match-display (display frame)
1359 "Non-nil if DISPLAY matches FRAME.
1360 DISPLAY is part of a spec such as can be used in `defface'.
1361 If FRAME is nil, the current FRAME is used."
1362 (let* ((conjuncts display)
1363 conjunct req options
1364 ;; t means we have succeeded against all the conjuncts in
1365 ;; DISPLAY that have been tested so far.
1366 (match t))
1367 (if (eq conjuncts t)
1368 (setq conjuncts nil))
1369 (while (and conjuncts match)
1370 (setq conjunct (car conjuncts)
1371 conjuncts (cdr conjuncts)
1372 req (car conjunct)
1373 options (cdr conjunct)
1374 match (cond ((eq req 'type)
1375 (or (memq window-system options)
1376 ;; FIXME: This should be revisited to use
1377 ;; display-graphic-p, provided that the
1378 ;; color selection depends on the number
1379 ;; of supported colors, and all defface's
1380 ;; are changed to look at number of colors
1381 ;; instead of (type graphic) etc.
1382 (and (null window-system)
1383 (memq 'tty options))
1384 (and (memq 'motif options)
1385 (featurep 'motif))
1386 (and (memq 'gtk options)
1387 (featurep 'gtk))
1388 (and (memq 'lucid options)
1389 (featurep 'x-toolkit)
1390 (not (featurep 'motif))
1391 (not (featurep 'gtk)))
1392 (and (memq 'x-toolkit options)
1393 (featurep 'x-toolkit))))
1394 ((eq req 'min-colors)
1395 (>= (display-color-cells frame) (car options)))
1396 ((eq req 'class)
1397 (memq (frame-parameter frame 'display-type) options))
1398 ((eq req 'background)
1399 (memq (frame-parameter frame 'background-mode)
1400 options))
1401 ((eq req 'supports)
1402 (display-supports-face-attributes-p options frame))
1403 (t (error "Unknown req `%S' with options `%S'"
1404 req options)))))
1405 match))
1408 (defun face-spec-choose (spec &optional frame)
1409 "Choose the proper attributes for FRAME, out of SPEC.
1410 If SPEC is nil, return nil."
1411 (unless frame
1412 (setq frame (selected-frame)))
1413 (let ((tail spec)
1414 result defaults)
1415 (while tail
1416 (let* ((entry (pop tail))
1417 (display (car entry))
1418 (attrs (cdr entry))
1419 thisval)
1420 ;; Get the attributes as actually specified by this alternative.
1421 (setq thisval
1422 (if (null (cdr attrs)) ;; was (listp (car attrs))
1423 ;; Old-style entry, the attribute list is the
1424 ;; first element.
1425 (car attrs)
1426 attrs))
1428 ;; If the condition is `default', that sets the default
1429 ;; for following conditions.
1430 (if (eq display 'default)
1431 (setq defaults thisval)
1432 ;; Otherwise, if it matches, use it.
1433 (when (face-spec-set-match-display display frame)
1434 (setq result thisval)
1435 (setq tail nil)))))
1436 (if defaults (append result defaults) result)))
1439 (defun face-spec-reset-face (face &optional frame)
1440 "Reset all attributes of FACE on FRAME to unspecified."
1441 (let ((attrs face-attribute-name-alist))
1442 (while attrs
1443 (let ((attr-and-name (car attrs)))
1444 (set-face-attribute face frame (car attr-and-name) 'unspecified))
1445 (setq attrs (cdr attrs)))))
1448 (defun face-spec-set (face spec &optional frame)
1449 "Set FACE's attributes according to the first matching entry in SPEC.
1450 FRAME is the frame whose frame-local face is set. FRAME nil means
1451 do it on all frames. See `defface' for information about SPEC.
1452 If SPEC is nil, do nothing."
1453 (let ((attrs (face-spec-choose spec frame)))
1454 (when spec
1455 (face-spec-reset-face face frame))
1456 (while attrs
1457 (let ((attribute (car attrs))
1458 (value (car (cdr attrs))))
1459 ;; Support some old-style attribute names and values.
1460 (case attribute
1461 (:bold (setq attribute :weight value (if value 'bold 'normal)))
1462 (:italic (setq attribute :slant value (if value 'italic 'normal)))
1463 ((:foreground :background)
1464 ;; Compatibility with 20.x. Some bogus face specs seem to
1465 ;; exist containing things like `:foreground nil'.
1466 (if (null value) (setq value 'unspecified)))
1467 (t (unless (assq attribute face-x-resources)
1468 (setq attribute nil))))
1469 (when attribute
1470 (set-face-attribute face frame attribute value)))
1471 (setq attrs (cdr (cdr attrs)))))
1472 ;; When we reset the face based on its spec, then it is unmodified
1473 ;; as far as Custom is concerned.
1474 (if (null frame)
1475 (put (or (get face 'face-alias) face) 'face-modified nil)))
1478 (defun face-attr-match-p (face attrs &optional frame)
1479 "Return t if attributes of FACE match values in plist ATTRS.
1480 Optional parameter FRAME is the frame whose definition of FACE
1481 is used. If nil or omitted, use the selected frame."
1482 (unless frame
1483 (setq frame (selected-frame)))
1484 (let ((list face-attribute-name-alist)
1485 (match t))
1486 (while (and match (not (null list)))
1487 (let* ((attr (car (car list)))
1488 (specified-value
1489 (if (plist-member attrs attr)
1490 (plist-get attrs attr)
1491 'unspecified))
1492 (value-now (face-attribute face attr frame)))
1493 (setq match (equal specified-value value-now))
1494 (setq list (cdr list))))
1495 match))
1497 (defun face-spec-match-p (face spec &optional frame)
1498 "Return t if FACE, on FRAME, matches what SPEC says it should look like."
1499 (face-attr-match-p face (face-spec-choose spec frame) frame))
1501 (defsubst face-default-spec (face)
1502 "Return the default face-spec for FACE, ignoring any user customization.
1503 If there is no default for FACE, return nil."
1504 (get face 'face-defface-spec))
1506 (defsubst face-user-default-spec (face)
1507 "Return the user's customized face-spec for FACE, or the default if none.
1508 If there is neither a user setting nor a default for FACE, return nil."
1509 (or (get face 'customized-face)
1510 (get face 'saved-face)
1511 (face-default-spec face)))
1514 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1515 ;;; Frame-type independent color support.
1516 ;;; We keep the old x-* names as aliases for back-compatibility.
1517 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1519 (defun defined-colors (&optional frame)
1520 "Return a list of colors supported for a particular frame.
1521 The argument FRAME specifies which frame to try.
1522 The value may be different for frames on different display types.
1523 If FRAME doesn't support colors, the value is nil.
1524 If FRAME is nil, that stands for the selected frame."
1525 (if (memq (framep (or frame (selected-frame))) '(x w32 mac))
1526 (xw-defined-colors frame)
1527 (mapcar 'car (tty-color-alist frame))))
1528 (defalias 'x-defined-colors 'defined-colors)
1530 (defun color-defined-p (color &optional frame)
1531 "Return non-nil if color COLOR is supported on frame FRAME.
1532 If FRAME is omitted or nil, use the selected frame.
1533 If COLOR is the symbol `unspecified' or one of the strings
1534 \"unspecified-fg\" or \"unspecified-bg\", the value is nil."
1535 (if (member color '(unspecified "unspecified-bg" "unspecified-fg"))
1537 (if (member (framep (or frame (selected-frame))) '(x w32 mac))
1538 (xw-color-defined-p color frame)
1539 (numberp (tty-color-translate color frame)))))
1540 (defalias 'x-color-defined-p 'color-defined-p)
1542 (defun color-values (color &optional frame)
1543 "Return a description of the color named COLOR on frame FRAME.
1544 The value is a list of integer RGB values--(RED GREEN BLUE).
1545 These values appear to range from 0 to 65280 or 65535, depending
1546 on the system; white is \(65280 65280 65280\) or \(65535 65535 65535\).
1547 If FRAME is omitted or nil, use the selected frame.
1548 If FRAME cannot display COLOR, the value is nil.
1549 If COLOR is the symbol `unspecified' or one of the strings
1550 \"unspecified-fg\" or \"unspecified-bg\", the value is nil."
1551 (if (member color '(unspecified "unspecified-fg" "unspecified-bg"))
1553 (if (memq (framep (or frame (selected-frame))) '(x w32 mac))
1554 (xw-color-values color frame)
1555 (tty-color-values color frame))))
1556 (defalias 'x-color-values 'color-values)
1558 (defun display-color-p (&optional display)
1559 "Return t if DISPLAY supports color.
1560 The optional argument DISPLAY specifies which display to ask about.
1561 DISPLAY should be either a frame or a display name (a string).
1562 If omitted or nil, that stands for the selected frame's display."
1563 (if (memq (framep-on-display display) '(x w32 mac))
1564 (xw-display-color-p display)
1565 (tty-display-color-p display)))
1566 (defalias 'x-display-color-p 'display-color-p)
1568 (defun display-grayscale-p (&optional display)
1569 "Return non-nil if frames on DISPLAY can display shades of gray."
1570 (let ((frame-type (framep-on-display display)))
1571 (cond
1572 ((memq frame-type '(x w32 mac))
1573 (x-display-grayscale-p display))
1575 (> (tty-color-gray-shades display) 2)))))
1578 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1579 ;;; Background mode.
1580 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1582 (defcustom frame-background-mode nil
1583 "*The brightness of the background.
1584 Set this to the symbol `dark' if your background color is dark,
1585 `light' if your background is light, or nil (automatic by default)
1586 if you want Emacs to examine the brightness for you. Don't set this
1587 variable with `setq'; this won't have the expected effect."
1588 :group 'faces
1589 :set #'(lambda (var value)
1590 (set-default var value)
1591 (mapc 'frame-set-background-mode (frame-list)))
1592 :initialize 'custom-initialize-changed
1593 :type '(choice (const dark)
1594 (const light)
1595 (const :tag "automatic" nil)))
1597 (defvar default-frame-background-mode nil
1598 "Internal variable for the default brightness of the background.
1599 Emacs sets it automatically depending on the terminal type.
1600 The value `nil' means `dark'. If Emacs runs in non-windowed
1601 mode from `xterm' or a similar terminal emulator, the value is
1602 `light'. On rxvt terminals, the value depends on the environment
1603 variable COLORFGBG.")
1605 (defun frame-set-background-mode (frame)
1606 "Set up display-dependent faces on FRAME.
1607 Display-dependent faces are those which have different definitions
1608 according to the `background-mode' and `display-type' frame parameters."
1609 (let* ((bg-resource
1610 (and window-system
1611 (x-get-resource "backgroundMode" "BackgroundMode")))
1612 (bg-color (frame-parameter frame 'background-color))
1613 (bg-mode
1614 (cond (frame-background-mode)
1615 (bg-resource
1616 (intern (downcase bg-resource)))
1617 ((and (null window-system) (null bg-color))
1618 ;; No way to determine this automatically (?).
1619 (or default-frame-background-mode 'dark))
1620 ;; Unspecified frame background color can only happen
1621 ;; on tty's.
1622 ((member bg-color '(unspecified "unspecified-bg"))
1623 (or default-frame-background-mode 'dark))
1624 ((equal bg-color "unspecified-fg") ; inverted colors
1625 (if (eq default-frame-background-mode 'light) 'dark 'light))
1626 ((>= (apply '+ (color-values bg-color frame))
1627 ;; Just looking at the screen, colors whose
1628 ;; values add up to .6 of the white total
1629 ;; still look dark to me.
1630 (* (apply '+ (color-values "white" frame)) .6))
1631 'light)
1632 (t 'dark)))
1633 (display-type
1634 (cond ((null window-system)
1635 (if (tty-display-color-p frame) 'color 'mono))
1636 ((display-color-p frame)
1637 'color)
1638 ((x-display-grayscale-p frame)
1639 'grayscale)
1640 (t 'mono)))
1641 (old-bg-mode
1642 (frame-parameter frame 'background-mode))
1643 (old-display-type
1644 (frame-parameter frame 'display-type)))
1646 (unless (and (eq bg-mode old-bg-mode) (eq display-type old-display-type))
1647 (let ((locally-modified-faces nil))
1648 ;; Before modifying the frame parameters, we collect a list of
1649 ;; faces that don't match what their face-spec says they should
1650 ;; look like; we then avoid changing these faces below. A
1651 ;; negative list is used on the assumption that most faces will
1652 ;; be unmodified, so we can avoid consing in the common case.
1653 (dolist (face (face-list))
1654 (when (not (face-spec-match-p face
1655 (face-user-default-spec face)
1656 (selected-frame)))
1657 (push face locally-modified-faces)))
1658 ;; Now change to the new frame parameters
1659 (modify-frame-parameters frame
1660 (list (cons 'background-mode bg-mode)
1661 (cons 'display-type display-type)))
1662 ;; For all named faces, choose face specs matching the new frame
1663 ;; parameters, unless they have been locally modified.
1664 (dolist (face (face-list))
1665 (unless (memq face locally-modified-faces)
1666 (face-spec-set face (face-user-default-spec face) frame)))))))
1669 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1670 ;;; Frame creation.
1671 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1673 (defun x-handle-named-frame-geometry (parameters)
1674 "Add geometry parameters for a named frame to parameter list PARAMETERS.
1675 Value is the new parameter list."
1676 (let* ((name (or (cdr (assq 'name parameters))
1677 (cdr (assq 'name default-frame-alist))))
1678 (x-resource-name name)
1679 (res-geometry (if name (x-get-resource "geometry" "Geometry"))))
1680 (when res-geometry
1681 (let ((parsed (x-parse-geometry res-geometry)))
1682 ;; If the resource specifies a position, call the position
1683 ;; and size "user-specified".
1684 (when (or (assq 'top parsed)
1685 (assq 'left parsed))
1686 (setq parsed (append '((user-position . t) (user-size . t)) parsed)))
1687 ;; Put the geometry parameters at the end. Copy
1688 ;; default-frame-alist so that they go after it.
1689 (setq parameters (append parameters default-frame-alist parsed))))
1690 parameters))
1693 (defun x-handle-reverse-video (frame parameters)
1694 "Handle the reverse-video frame parameter and X resource.
1695 `x-create-frame' does not handle this one."
1696 (when (cdr (or (assq 'reverse parameters)
1697 (assq 'reverse default-frame-alist)
1698 (let ((resource (x-get-resource "reverseVideo"
1699 "ReverseVideo")))
1700 (if resource
1701 (cons nil (member (downcase resource)
1702 '("on" "true")))))))
1703 (let* ((params (frame-parameters frame))
1704 (bg (cdr (assq 'foreground-color params)))
1705 (fg (cdr (assq 'background-color params))))
1706 (modify-frame-parameters frame
1707 (list (cons 'foreground-color fg)
1708 (cons 'background-color bg)))
1709 (if (equal bg (cdr (assq 'border-color params)))
1710 (modify-frame-parameters frame
1711 (list (cons 'border-color fg))))
1712 (if (equal bg (cdr (assq 'mouse-color params)))
1713 (modify-frame-parameters frame
1714 (list (cons 'mouse-color fg))))
1715 (if (equal bg (cdr (assq 'cursor-color params)))
1716 (modify-frame-parameters frame
1717 (list (cons 'cursor-color fg)))))))
1720 (defun x-create-frame-with-faces (&optional parameters)
1721 "Create a frame from optional frame parameters PARAMETERS.
1722 Parameters not specified by PARAMETERS are taken from
1723 `default-frame-alist'. If PARAMETERS specify a frame name,
1724 handle X geometry resources for that name. If either PARAMETERS
1725 or `default-frame-alist' contains a `reverse' parameter, or
1726 the X resource ``reverseVideo'' is present, handle that.
1727 Value is the new frame created."
1728 (setq parameters (x-handle-named-frame-geometry parameters))
1729 (let ((visibility-spec (assq 'visibility parameters))
1730 (frame-list (frame-list))
1731 (frame (x-create-frame (cons '(visibility . nil) parameters)))
1732 success)
1733 (unwind-protect
1734 (progn
1735 (x-handle-reverse-video frame parameters)
1736 (frame-set-background-mode frame)
1737 (face-set-after-frame-default frame)
1738 (if (or (null frame-list) (null visibility-spec))
1739 (make-frame-visible frame)
1740 (modify-frame-parameters frame (list visibility-spec)))
1741 (setq success t))
1742 (unless success
1743 (delete-frame frame)))
1744 frame))
1746 (defun face-set-after-frame-default (frame)
1747 "Set frame-local faces of FRAME from face specs and resources.
1748 Initialize colors of certain faces from frame parameters."
1749 (unless inhibit-face-set-after-frame-default
1750 (if (face-attribute 'default :font t)
1751 (set-face-attribute 'default frame :font
1752 (face-attribute 'default :font t))
1753 (set-face-attribute 'default frame :family
1754 (face-attribute 'default :family t))
1755 (set-face-attribute 'default frame :height
1756 (face-attribute 'default :height t))
1757 (set-face-attribute 'default frame :slant
1758 (face-attribute 'default :slant t))
1759 (set-face-attribute 'default frame :weight
1760 (face-attribute 'default :weight t))
1761 (set-face-attribute 'default frame :width
1762 (face-attribute 'default :width t))))
1763 ;; Find attributes that should be initialized from frame parameters.
1764 (let ((face-params '((foreground-color default :foreground)
1765 (background-color default :background)
1766 (border-color border :background)
1767 (cursor-color cursor :background)
1768 (scroll-bar-foreground scroll-bar :foreground)
1769 (scroll-bar-background scroll-bar :background)
1770 (mouse-color mouse :background)))
1771 apply-params)
1772 (dolist (param face-params)
1773 (let* ((value (frame-parameter frame (nth 0 param)))
1774 (face (nth 1 param))
1775 (attr (nth 2 param))
1776 (default-value (face-attribute face attr t)))
1777 ;; Compile a list of face attributes to set, but don't set
1778 ;; them yet. The call to make-face-x-resource-internal,
1779 ;; below, can change frame parameters, and the final set of
1780 ;; frame parameters should be the ones acquired at this step.
1781 (if (eq default-value 'unspecified)
1782 ;; The face spec does not specify a new-frame value for
1783 ;; this attribute. Check if the existing frame parameter
1784 ;; specifies it.
1785 (if value
1786 (push (list face frame attr value) apply-params))
1787 ;; The face spec specifies a value for this attribute, to be
1788 ;; applied to the face on all new frames.
1789 (push (list face frame attr default-value) apply-params))))
1790 ;; Initialize faces from face specs and X resources. The
1791 ;; condition-case prevents invalid specs from causing frame
1792 ;; creation to fail.
1793 (dolist (face (delq 'default (face-list)))
1794 (condition-case ()
1795 (progn
1796 (face-spec-set face (face-user-default-spec face) frame)
1797 (if (memq window-system '(x w32 mac))
1798 (make-face-x-resource-internal face frame))
1799 (internal-merge-in-global-face face frame))
1800 (error nil)))
1801 ;; Apply the attributes specified by frame parameters. This
1802 ;; rewrites parameters changed by make-face-x-resource-internal
1803 (dolist (param apply-params)
1804 (apply 'set-face-attribute param))))
1806 (defun tty-handle-reverse-video (frame parameters)
1807 "Handle the reverse-video frame parameter for terminal frames."
1808 (when (cdr (or (assq 'reverse parameters)
1809 (assq 'reverse default-frame-alist)))
1810 (let* ((params (frame-parameters frame))
1811 (bg (cdr (assq 'foreground-color params)))
1812 (fg (cdr (assq 'background-color params))))
1813 (modify-frame-parameters frame
1814 (list (cons 'foreground-color fg)
1815 (cons 'background-color bg)))
1816 (if (equal bg (cdr (assq 'mouse-color params)))
1817 (modify-frame-parameters frame
1818 (list (cons 'mouse-color fg))))
1819 (if (equal bg (cdr (assq 'cursor-color params)))
1820 (modify-frame-parameters frame
1821 (list (cons 'cursor-color fg)))))))
1824 (defun tty-create-frame-with-faces (&optional parameters)
1825 "Create a frame from optional frame parameters PARAMETERS.
1826 Parameters not specified by PARAMETERS are taken from
1827 `default-frame-alist'. If either PARAMETERS or `default-frame-alist'
1828 contains a `reverse' parameter, handle that. Value is the new frame
1829 created."
1830 (let ((frame (make-terminal-frame parameters))
1831 success)
1832 (unwind-protect
1833 (progn
1834 (tty-handle-reverse-video frame (frame-parameters frame))
1835 (frame-set-background-mode frame)
1836 (face-set-after-frame-default frame)
1837 (setq success t))
1838 (unless success
1839 (delete-frame frame)))
1840 frame))
1843 ;; Called from C function init_display to initialize faces of the
1844 ;; dumped terminal frame on startup.
1846 (defun tty-set-up-initial-frame-faces ()
1847 (let ((frame (selected-frame)))
1848 (frame-set-background-mode frame)
1849 (face-set-after-frame-default frame)))
1854 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1855 ;;; Compatiblity with 20.2
1856 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1858 ;; Update a frame's faces when we change its default font.
1860 (defalias 'frame-update-faces 'ignore "")
1861 (make-obsolete 'frame-update-faces "no longer necessary." "21.1")
1863 ;; Update the colors of FACE, after FRAME's own colors have been
1864 ;; changed.
1866 (define-obsolete-function-alias 'frame-update-face-colors
1867 'frame-set-background-mode "21.1")
1870 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1871 ;;; Standard faces.
1872 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1874 (defgroup basic-faces nil
1875 "The standard faces of Emacs."
1876 :group 'faces)
1878 (defface default
1879 '((t nil))
1880 "Basic default face."
1881 :group 'basic-faces)
1883 (defface bold
1884 '((t :weight bold))
1885 "Basic bold face."
1886 :group 'basic-faces)
1888 (defface italic
1889 '((((supports :slant italic))
1890 :slant italic)
1891 (((supports :underline t))
1892 :underline t)
1894 ;; default to italic, even it doesn't appear to be supported,
1895 ;; because in some cases the display engine will do it's own
1896 ;; workaround (to `dim' on ttys)
1897 :slant italic))
1898 "Basic italic face."
1899 :group 'basic-faces)
1901 (defface bold-italic
1902 '((t :weight bold :slant italic))
1903 "Basic bold-italic face."
1904 :group 'basic-faces)
1906 (defface underline
1907 '((((supports :underline t))
1908 :underline t)
1909 (((supports :weight bold))
1910 :weight bold)
1911 (t :underline t))
1912 "Basic underlined face."
1913 :group 'basic-faces)
1915 (defface fixed-pitch
1916 '((t :family "courier"))
1917 "The basic fixed-pitch face."
1918 :group 'basic-faces)
1920 (defface variable-pitch
1921 '((t :family "helv"))
1922 "The basic variable-pitch face."
1923 :group 'basic-faces)
1925 (defface shadow
1926 '((((class color grayscale) (min-colors 88) (background light))
1927 :foreground "grey50")
1928 (((class color grayscale) (min-colors 88) (background dark))
1929 :foreground "grey70")
1930 (((class color) (min-colors 8) (background light))
1931 :foreground "green")
1932 (((class color) (min-colors 8) (background dark))
1933 :foreground "yellow"))
1934 "Basic face for shadowed text."
1935 :group 'basic-faces
1936 :version "22.1")
1938 (defface link
1939 '((((class color) (min-colors 88) (background light))
1940 :foreground "blue1" :underline t)
1941 (((class color) (background light))
1942 :foreground "blue" :underline t)
1943 (((class color) (min-colors 88) (background dark))
1944 :foreground "cyan1" :underline t)
1945 (((class color) (background dark))
1946 :foreground "cyan" :underline t)
1947 (t :inherit underline))
1948 "Basic face for unvisited links."
1949 :group 'basic-faces
1950 :version "22.1")
1952 (defface link-visited
1953 '((default :inherit link)
1954 (((class color) (background light)) :foreground "magenta4")
1955 (((class color) (background dark)) :foreground "violet"))
1956 "Basic face for visited links."
1957 :group 'basic-faces
1958 :version "22.1")
1960 (defface highlight
1961 '((((class color) (min-colors 88) (background light))
1962 :background "darkseagreen2")
1963 (((class color) (min-colors 88) (background dark))
1964 :background "darkolivegreen")
1965 (((class color) (min-colors 16) (background light))
1966 :background "darkseagreen2")
1967 (((class color) (min-colors 16) (background dark))
1968 :background "darkolivegreen")
1969 (((class color) (min-colors 8))
1970 :background "green" :foreground "black")
1971 (t :inverse-video t))
1972 "Basic face for highlighting."
1973 :group 'basic-faces)
1975 (defface region
1976 '((((class color) (min-colors 88) (background dark))
1977 :background "blue3")
1978 (((class color) (min-colors 88) (background light))
1979 :background "lightgoldenrod2")
1980 (((class color) (min-colors 16) (background dark))
1981 :background "blue3")
1982 (((class color) (min-colors 16) (background light))
1983 :background "lightgoldenrod2")
1984 (((class color) (min-colors 8))
1985 :background "blue" :foreground "white")
1986 (((type tty) (class mono))
1987 :inverse-video t)
1988 (t :background "gray"))
1989 "Basic face for highlighting the region."
1990 :version "21.1"
1991 :group 'basic-faces)
1993 (defface secondary-selection
1994 '((((class color) (min-colors 88) (background light))
1995 :background "yellow1")
1996 (((class color) (min-colors 88) (background dark))
1997 :background "SkyBlue4")
1998 (((class color) (min-colors 16) (background light))
1999 :background "yellow")
2000 (((class color) (min-colors 16) (background dark))
2001 :background "SkyBlue4")
2002 (((class color) (min-colors 8))
2003 :background "cyan" :foreground "black")
2004 (t :inverse-video t))
2005 "Basic face for displaying the secondary selection."
2006 :group 'basic-faces)
2008 (defface trailing-whitespace
2009 '((((class color) (background light))
2010 :background "red1")
2011 (((class color) (background dark))
2012 :background "red1")
2013 (t :inverse-video t))
2014 "Basic face for highlighting trailing whitespace."
2015 :version "21.1"
2016 :group 'whitespace-faces ; like `show-trailing-whitespace'
2017 :group 'basic-faces)
2019 (defface escape-glyph
2020 '((((background dark)) :foreground "cyan")
2021 ;; See the comment in minibuffer-prompt for
2022 ;; the reason not to use blue on MS-DOS.
2023 (((type pc)) :foreground "magenta")
2024 ;; red4 is too dark, but some say blue is too loud.
2025 ;; brown seems to work ok. -- rms.
2026 (t :foreground "brown"))
2027 "Face for characters displayed as sequences using `^' or `\\'."
2028 :group 'basic-faces
2029 :version "22.1")
2031 (defface nobreak-space
2032 '((((class color) (min-colors 88)) :inherit escape-glyph :underline t)
2033 (((class color) (min-colors 8)) :background "magenta")
2034 (t :inverse-video t))
2035 "Face for displaying nobreak space."
2036 :group 'basic-faces
2037 :version "22.1")
2039 (defgroup mode-line-faces nil
2040 "Faces used in the mode line."
2041 :group 'mode-line
2042 :group 'faces
2043 :version "22.1")
2045 (defface mode-line
2046 '((((class color) (min-colors 88))
2047 :box (:line-width -1 :style released-button)
2048 :background "grey75" :foreground "black")
2050 :inverse-video t))
2051 "Basic mode line face for selected window."
2052 :version "21.1"
2053 :group 'mode-line-faces
2054 :group 'basic-faces)
2056 (defface mode-line-inactive
2057 '((default
2058 :inherit mode-line)
2059 (((class color) (min-colors 88) (background light))
2060 :weight light
2061 :box (:line-width -1 :color "grey75" :style nil)
2062 :foreground "grey20" :background "grey90")
2063 (((class color) (min-colors 88) (background dark) )
2064 :weight light
2065 :box (:line-width -1 :color "grey40" :style nil)
2066 :foreground "grey80" :background "grey30"))
2067 "Basic mode line face for non-selected windows."
2068 :version "22.1"
2069 :group 'mode-line-faces
2070 :group 'basic-faces)
2072 (defface mode-line-highlight
2073 '((((class color) (min-colors 88))
2074 :box (:line-width 2 :color "grey40" :style released-button))
2076 :inherit highlight))
2077 "Basic mode line face for highlighting."
2078 :version "22.1"
2079 :group 'mode-line-faces
2080 :group 'basic-faces)
2082 (defface mode-line-buffer-id
2083 '((t (:weight bold)))
2084 "Face used for buffer identification parts of the mode line."
2085 :version "22.1"
2086 :group 'mode-line-faces
2087 :group 'basic-faces)
2089 ;; Make `modeline' an alias for `mode-line', for compatibility.
2090 (put 'modeline 'face-alias 'mode-line)
2091 (put 'modeline-inactive 'face-alias 'mode-line-inactive)
2092 (put 'modeline-highlight 'face-alias 'mode-line-highlight)
2093 (put 'modeline-buffer-id 'face-alias 'mode-line-buffer-id)
2095 (defface header-line
2096 '((default
2097 :inherit mode-line)
2098 (((type tty))
2099 ;; This used to be `:inverse-video t', but that doesn't look very
2100 ;; good when combined with inverse-video mode-lines and multiple
2101 ;; windows. Underlining looks better, and is more consistent with
2102 ;; the window-system face variants, which deemphasize the
2103 ;; header-line in relation to the mode-line face. If a terminal
2104 ;; can't underline, then the header-line will end up without any
2105 ;; highlighting; this may be too confusing in general, although it
2106 ;; happens to look good with the only current use of header-lines,
2107 ;; the info browser. XXX
2108 :inverse-video nil ;Override the value inherited from mode-line.
2109 :underline t)
2110 (((class color grayscale) (background light))
2111 :background "grey90" :foreground "grey20"
2112 :box nil)
2113 (((class color grayscale) (background dark))
2114 :background "grey20" :foreground "grey90"
2115 :box nil)
2116 (((class mono) (background light))
2117 :background "white" :foreground "black"
2118 :inverse-video nil
2119 :box nil
2120 :underline t)
2121 (((class mono) (background dark))
2122 :background "black" :foreground "white"
2123 :inverse-video nil
2124 :box nil
2125 :underline t))
2126 "Basic header-line face."
2127 :version "21.1"
2128 :group 'basic-faces)
2130 (defface vertical-border
2131 '((((type tty)) :inherit mode-line-inactive))
2132 "Face used for vertical window dividers on ttys."
2133 :version "22.1"
2134 :group 'basic-faces)
2136 (defface minibuffer-prompt
2137 '((((background dark)) :foreground "cyan")
2138 ;; Don't use blue because many users of the MS-DOS port customize
2139 ;; their foreground color to be blue.
2140 (((type pc)) :foreground "magenta")
2141 (t :foreground "medium blue"))
2142 "Face for minibuffer prompts.
2143 By default, Emacs automatically adds this face to the value of
2144 `minibuffer-prompt-properties', which is a list of text properties
2145 used to display the prompt text."
2146 :version "22.1"
2147 :group 'basic-faces)
2149 (setq minibuffer-prompt-properties
2150 (append minibuffer-prompt-properties (list 'face 'minibuffer-prompt)))
2152 (defface fringe
2153 '((((class color) (background light))
2154 :background "grey95")
2155 (((class color) (background dark))
2156 :background "grey10")
2158 :background "gray"))
2159 "Basic face for the fringes to the left and right of windows under X."
2160 :version "21.1"
2161 :group 'frames
2162 :group 'basic-faces)
2164 (defface scroll-bar '((t nil))
2165 "Basic face for the scroll bar colors under X."
2166 :version "21.1"
2167 :group 'frames
2168 :group 'basic-faces)
2170 (defface border '((t nil))
2171 "Basic face for the frame border under X."
2172 :version "21.1"
2173 :group 'frames
2174 :group 'basic-faces)
2176 (defface cursor '((t nil))
2177 "Basic face for the cursor color under X.
2178 Note: Other faces cannot inherit from the cursor face."
2179 :version "21.1"
2180 :group 'cursor
2181 :group 'basic-faces)
2183 (put 'cursor 'face-no-inherit t)
2185 (defface mouse '((t nil))
2186 "Basic face for the mouse color under X."
2187 :version "21.1"
2188 :group 'mouse
2189 :group 'basic-faces)
2191 (defface tool-bar
2192 '((default
2193 :box (:line-width 1 :style released-button)
2194 :foreground "black")
2195 (((type x w32 mac) (class color))
2196 :background "grey75")
2197 (((type x) (class mono))
2198 :background "grey"))
2199 "Basic tool-bar face."
2200 :version "21.1"
2201 :group 'basic-faces)
2203 (defface menu
2204 '((((type tty))
2205 :inverse-video t)
2206 (((type x-toolkit))
2209 :inverse-video t))
2210 "Basic face for the font and colors of the menu bar and popup menus."
2211 :version "21.1"
2212 :group 'menu
2213 :group 'basic-faces)
2216 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2217 ;;; Manipulating font names.
2218 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2220 ;; This is here for compatibilty with Emacs 20.2. For example,
2221 ;; international/fontset.el uses x-resolve-font-name. The following
2222 ;; functions are not used in the face implementation itself.
2224 (defvar x-font-regexp nil)
2225 (defvar x-font-regexp-head nil)
2226 (defvar x-font-regexp-weight nil)
2227 (defvar x-font-regexp-slant nil)
2229 (defconst x-font-regexp-weight-subnum 1)
2230 (defconst x-font-regexp-slant-subnum 2)
2231 (defconst x-font-regexp-swidth-subnum 3)
2232 (defconst x-font-regexp-adstyle-subnum 4)
2234 ;;; Regexps matching font names in "Host Portable Character Representation."
2236 (let ((- "[-?]")
2237 (foundry "[^-]+")
2238 (family "[^-]+")
2239 (weight "\\(bold\\|demibold\\|medium\\)") ; 1
2240 ; (weight\? "\\(\\*\\|bold\\|demibold\\|medium\\|\\)") ; 1
2241 (weight\? "\\([^-]*\\)") ; 1
2242 (slant "\\([ior]\\)") ; 2
2243 ; (slant\? "\\([ior?*]?\\)") ; 2
2244 (slant\? "\\([^-]?\\)") ; 2
2245 ; (swidth "\\(\\*\\|normal\\|semicondensed\\|\\)") ; 3
2246 (swidth "\\([^-]*\\)") ; 3
2247 ; (adstyle "\\(\\*\\|sans\\|\\)") ; 4
2248 (adstyle "\\([^-]*\\)") ; 4
2249 (pixelsize "[0-9]+")
2250 (pointsize "[0-9][0-9]+")
2251 (resx "[0-9][0-9]+")
2252 (resy "[0-9][0-9]+")
2253 (spacing "[cmp?*]")
2254 (avgwidth "[0-9]+")
2255 (registry "[^-]+")
2256 (encoding "[^-]+")
2258 (setq x-font-regexp
2259 (concat "\\`\\*?[-?*]"
2260 foundry - family - weight\? - slant\? - swidth - adstyle -
2261 pixelsize - pointsize - resx - resy - spacing - avgwidth -
2262 registry - encoding "\\*?\\'"
2264 (setq x-font-regexp-head
2265 (concat "\\`[-?*]" foundry - family - weight\? - slant\?
2266 "\\([-*?]\\|\\'\\)"))
2267 (setq x-font-regexp-slant (concat - slant -))
2268 (setq x-font-regexp-weight (concat - weight -))
2269 nil)
2272 (defun x-resolve-font-name (pattern &optional face frame)
2273 "Return a font name matching PATTERN.
2274 All wildcards in PATTERN are instantiated.
2275 If PATTERN is nil, return the name of the frame's base font, which never
2276 contains wildcards.
2277 Given optional arguments FACE and FRAME, return a font which is
2278 also the same size as FACE on FRAME, or fail."
2279 (or (symbolp face)
2280 (setq face (face-name face)))
2281 (and (eq frame t)
2282 (setq frame nil))
2283 (if pattern
2284 ;; Note that x-list-fonts has code to handle a face with nil as its font.
2285 (let ((fonts (x-list-fonts pattern face frame 1)))
2286 (or fonts
2287 (if face
2288 (if (string-match "\\*" pattern)
2289 (if (null (face-font face))
2290 (error "No matching fonts are the same height as the frame default font")
2291 (error "No matching fonts are the same height as face `%s'" face))
2292 (if (null (face-font face))
2293 (error "Height of font `%s' doesn't match the frame default font"
2294 pattern)
2295 (error "Height of font `%s' doesn't match face `%s'"
2296 pattern face)))
2297 (error "No fonts match `%s'" pattern)))
2298 (car fonts))
2299 (cdr (assq 'font (frame-parameters (selected-frame))))))
2302 (defun x-frob-font-weight (font which)
2303 (let ((case-fold-search t))
2304 (cond ((string-match x-font-regexp font)
2305 (concat (substring font 0
2306 (match-beginning x-font-regexp-weight-subnum))
2307 which
2308 (substring font (match-end x-font-regexp-weight-subnum)
2309 (match-beginning x-font-regexp-adstyle-subnum))
2310 ;; Replace the ADD_STYLE_NAME field with *
2311 ;; because the info in it may not be the same
2312 ;; for related fonts.
2314 (substring font (match-end x-font-regexp-adstyle-subnum))))
2315 ((string-match x-font-regexp-head font)
2316 (concat (substring font 0 (match-beginning 1)) which
2317 (substring font (match-end 1))))
2318 ((string-match x-font-regexp-weight font)
2319 (concat (substring font 0 (match-beginning 1)) which
2320 (substring font (match-end 1)))))))
2321 (make-obsolete 'x-frob-font-weight 'make-face-... "21.1")
2323 (defun x-frob-font-slant (font which)
2324 (let ((case-fold-search t))
2325 (cond ((string-match x-font-regexp font)
2326 (concat (substring font 0
2327 (match-beginning x-font-regexp-slant-subnum))
2328 which
2329 (substring font (match-end x-font-regexp-slant-subnum)
2330 (match-beginning x-font-regexp-adstyle-subnum))
2331 ;; Replace the ADD_STYLE_NAME field with *
2332 ;; because the info in it may not be the same
2333 ;; for related fonts.
2335 (substring font (match-end x-font-regexp-adstyle-subnum))))
2336 ((string-match x-font-regexp-head font)
2337 (concat (substring font 0 (match-beginning 2)) which
2338 (substring font (match-end 2))))
2339 ((string-match x-font-regexp-slant font)
2340 (concat (substring font 0 (match-beginning 1)) which
2341 (substring font (match-end 1)))))))
2342 (make-obsolete 'x-frob-font-slant 'make-face-... "21.1")
2344 ;; These aliases are here so that we don't get warnings about obsolete
2345 ;; functions from the byte compiler.
2346 (defalias 'internal-frob-font-weight 'x-frob-font-weight)
2347 (defalias 'internal-frob-font-slant 'x-frob-font-slant)
2349 (defun x-make-font-bold (font)
2350 "Given an X font specification, make a bold version of it.
2351 If that can't be done, return nil."
2352 (internal-frob-font-weight font "bold"))
2353 (make-obsolete 'x-make-font-bold 'make-face-bold "21.1")
2355 (defun x-make-font-demibold (font)
2356 "Given an X font specification, make a demibold version of it.
2357 If that can't be done, return nil."
2358 (internal-frob-font-weight font "demibold"))
2359 (make-obsolete 'x-make-font-demibold 'make-face-bold "21.1")
2361 (defun x-make-font-unbold (font)
2362 "Given an X font specification, make a non-bold version of it.
2363 If that can't be done, return nil."
2364 (internal-frob-font-weight font "medium"))
2365 (make-obsolete 'x-make-font-unbold 'make-face-unbold "21.1")
2367 (defun x-make-font-italic (font)
2368 "Given an X font specification, make an italic version of it.
2369 If that can't be done, return nil."
2370 (internal-frob-font-slant font "i"))
2371 (make-obsolete 'x-make-font-italic 'make-face-italic "21.1")
2373 (defun x-make-font-oblique (font) ; you say tomayto...
2374 "Given an X font specification, make an oblique version of it.
2375 If that can't be done, return nil."
2376 (internal-frob-font-slant font "o"))
2377 (make-obsolete 'x-make-font-oblique 'make-face-italic "21.1")
2379 (defun x-make-font-unitalic (font)
2380 "Given an X font specification, make a non-italic version of it.
2381 If that can't be done, return nil."
2382 (internal-frob-font-slant font "r"))
2383 (make-obsolete 'x-make-font-unitalic 'make-face-unitalic "21.1")
2385 (defun x-make-font-bold-italic (font)
2386 "Given an X font specification, make a bold and italic version of it.
2387 If that can't be done, return nil."
2388 (and (setq font (internal-frob-font-weight font "bold"))
2389 (internal-frob-font-slant font "i")))
2390 (make-obsolete 'x-make-font-bold-italic 'make-face-bold-italic "21.1")
2392 (provide 'faces)
2394 ;; arch-tag: 19a4759f-2963-445f-b004-425b9aadd7d6
2395 ;;; faces.el ends here