(replace_buffer_in_all_windows):
[bpt/emacs.git] / lisp / faces.el
CommitLineData
465fceed
ER
1;;; faces.el --- Lisp interface to the c "face" structure
2
b578f267 3;; Copyright (C) 1992, 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
465fceed
ER
4
5;; This file is part of GNU Emacs.
6
7;; GNU Emacs is free software; you can redistribute it and/or modify
8;; it under the terms of the GNU General Public License as published by
9;; the Free Software Foundation; either version 2, or (at your option)
10;; any later version.
11
12;; GNU Emacs is distributed in the hope that it will be useful,
13;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15;; GNU General Public License for more details.
16
17;; You should have received a copy of the GNU General Public License
b578f267
EN
18;; along with GNU Emacs; see the file COPYING. If not, write to the
19;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20;; Boston, MA 02111-1307, USA.
465fceed
ER
21
22;;; Commentary:
23
24;; Mostly derived from Lucid.
25
26;;; Code:
27
39b3b754
RS
28(eval-when-compile
29 ;; These used to be defsubsts, now they're subrs. Avoid losing if we're
30 ;; being compiled with an old Emacs that still has defsubrs in it.
31 (put 'face-name 'byte-optimizer nil)
32 (put 'face-id 'byte-optimizer nil)
33 (put 'face-font 'byte-optimizer nil)
87b6ab4c 34 (put 'face-font-explicit 'byte-optimizer nil)
39b3b754
RS
35 (put 'face-foreground 'byte-optimizer nil)
36 (put 'face-background 'byte-optimizer nil)
37 (put 'face-stipple 'byte-optimizer nil)
38 (put 'face-underline-p 'byte-optimizer nil)
39 (put 'set-face-font 'byte-optimizer nil)
87b6ab4c 40 (put 'set-face-font-auto 'byte-optimizer nil)
39b3b754
RS
41 (put 'set-face-foreground 'byte-optimizer nil)
42 (put 'set-face-background 'byte-optimizer nil)
ca58b3ec 43 (put 'set-face-stipple 'byte-optimizer nil)
39b3b754 44 (put 'set-face-underline-p 'byte-optimizer nil))
bdda3754
JB
45\f
46;;;; Functions for manipulating face vectors.
47
48;;; A face vector is a vector of the form:
d343b6f1
RS
49;;; [face NAME ID FONT FOREGROUND BACKGROUND STIPPLE
50;;; UNDERLINE-P INVERSE-VIDEO-P FONT-EXPLICIT-P BOLD-P ITALIC-P]
bdda3754
JB
51
52;;; Type checkers.
465fceed 53(defsubst internal-facep (x)
1bcb155c 54 (and (vectorp x) (= (length x) 12) (eq (aref x 0) 'face)))
465fceed 55
962a60aa
RS
56(defun facep (x)
57 "Return t if X is a face name or an internal face vector."
58 (and (or (internal-facep x)
59 (and (symbolp x) (assq x global-face-data)))
60 t))
61
465fceed 62(defmacro internal-check-face (face)
962a60aa
RS
63 (` (or (internal-facep (, face))
64 (signal 'wrong-type-argument (list 'internal-facep (, face))))))
465fceed 65
bdda3754 66;;; Accessors.
feaad827 67(defun face-name (face)
465fceed
ER
68 "Return the name of face FACE."
69 (aref (internal-get-face face) 1))
70
feaad827 71(defun face-id (face)
465fceed
ER
72 "Return the internal ID number of face FACE."
73 (aref (internal-get-face face) 2))
74
feaad827 75(defun face-font (face &optional frame)
465fceed
ER
76 "Return the font name of face FACE, or nil if it is unspecified.
77If the optional argument FRAME is given, report on face FACE in that frame.
f3f31ccf
RS
78If FRAME is t, report on the defaults for face FACE (for new frames).
79 The font default for a face is either nil, or a list
80 of the form (bold), (italic) or (bold italic).
81If FRAME is omitted or nil, use the selected frame."
465fceed
ER
82 (aref (internal-get-face face frame) 3))
83
feaad827 84(defun face-foreground (face &optional frame)
465fceed
ER
85 "Return the foreground color name of face FACE, or nil if unspecified.
86If the optional argument FRAME is given, report on face FACE in that frame.
f3f31ccf
RS
87If FRAME is t, report on the defaults for face FACE (for new frames).
88If FRAME is omitted or nil, use the selected frame."
465fceed
ER
89 (aref (internal-get-face face frame) 4))
90
feaad827 91(defun face-background (face &optional frame)
465fceed
ER
92 "Return the background color name of face FACE, or nil if unspecified.
93If the optional argument FRAME is given, report on face FACE in that frame.
f3f31ccf
RS
94If FRAME is t, report on the defaults for face FACE (for new frames).
95If FRAME is omitted or nil, use the selected frame."
465fceed
ER
96 (aref (internal-get-face face frame) 5))
97
feaad827 98(defun face-stipple (face &optional frame)
72418504
RS
99 "Return the stipple pixmap name of face FACE, or nil if unspecified.
100If the optional argument FRAME is given, report on face FACE in that frame.
101If FRAME is t, report on the defaults for face FACE (for new frames).
102If FRAME is omitted or nil, use the selected frame."
103 (aref (internal-get-face face frame) 6))
104
105(defalias 'face-background-pixmap 'face-stipple)
465fceed 106
feaad827 107(defun face-underline-p (face &optional frame)
465fceed
ER
108 "Return t if face FACE is underlined.
109If the optional argument FRAME is given, report on face FACE in that frame.
f3f31ccf
RS
110If FRAME is t, report on the defaults for face FACE (for new frames).
111If FRAME is omitted or nil, use the selected frame."
465fceed
ER
112 (aref (internal-get-face face frame) 7))
113
e8e4cda0
RS
114(defun face-inverse-video-p (face &optional frame)
115 "Return t if face FACE is in inverse video.
116If the optional argument FRAME is given, report on face FACE in that frame.
117If FRAME is t, report on the defaults for face FACE (for new frames).
118If FRAME is omitted or nil, use the selected frame."
119 (aref (internal-get-face face frame) 8))
120
1bcb155c
RS
121(defun face-font-explicit (face &optional frame)
122 "Return non-nil if this face's font was explicitly specified."
123 (aref (internal-get-face face frame) 9))
124
d11fba25
RS
125(defun face-bold-p (face &optional frame)
126 "Return non-nil if the font of FACE is bold.
127If the optional argument FRAME is given, report on face FACE in that frame.
128If FRAME is t, report on the defaults for face FACE (for new frames).
d11fba25 129If FRAME is omitted or nil, use the selected frame."
1bcb155c 130 (aref (internal-get-face face frame) 10))
d11fba25
RS
131
132(defun face-italic-p (face &optional frame)
133 "Return non-nil if the font of FACE is italic.
134If the optional argument FRAME is given, report on face FACE in that frame.
135If FRAME is t, report on the defaults for face FACE (for new frames).
d11fba25 136If FRAME is omitted or nil, use the selected frame."
1bcb155c 137 (aref (internal-get-face face frame) 11))
d11fba25 138
02e0989b
RS
139(defalias 'face-doc-string 'face-documentation)
140(defun face-documentation (face)
d11fba25
RS
141 "Get the documentation string for FACE."
142 (get face 'face-documentation))
bdda3754
JB
143\f
144;;; Mutators.
465fceed 145
feaad827 146(defun set-face-font (face font &optional frame)
465fceed
ER
147 "Change the font of face FACE to FONT (a string).
148If the optional FRAME argument is provided, change only
87b6ab4c
RS
149in that frame; otherwise change each frame."
150 (interactive (internal-face-interactive "font"))
151 (if (stringp font)
152 (setq font (or (query-fontset font)
153 (x-resolve-font-name font 'default frame))))
154 (internal-set-face-1 face 'font font 3 frame)
155 ;; Record that this face's font was set explicitly, not automatically,
156 ;; unless we are setting it to nil.
157 (internal-set-face-1 face nil (not (null font)) 9 frame))
158
159(defun set-face-font-auto (face font &optional frame)
160 "Change the font of face FACE to FONT (a string), for an automatic change.
161An automatic change means that we don't change the \"explicit\" flag;
162if the font was derived from the frame font before, it is now.
163If the optional FRAME argument is provided, change only
465fceed
ER
164in that frame; otherwise change each frame."
165 (interactive (internal-face-interactive "font"))
3aa3a18c 166 (if (stringp font)
b9f33f36
KH
167 (setq font (or (and (fontset-name-p font)
168 (or (query-fontset font)
27430190 169 (instantiate-fontset font)))
3aa3a18c 170 (x-resolve-font-name font 'default frame))))
10d89673 171 (internal-set-face-1 face 'font font 3 frame))
465fceed 172
87b6ab4c
RS
173(defun set-face-font-explicit (face flag &optional frame)
174 "Set the explicit-font flag of face FACE to FLAG.
175If the optional FRAME argument is provided, change only
176in that frame; otherwise change each frame."
e9e59456 177 (internal-set-face-1 face nil flag 9 frame))
87b6ab4c 178
feaad827 179(defun set-face-foreground (face color &optional frame)
465fceed
ER
180 "Change the foreground color of face FACE to COLOR (a string).
181If the optional FRAME argument is provided, change only
182in that frame; otherwise change each frame."
f60a629a 183 (interactive (internal-face-interactive "foreground" 'color))
f0138172 184 (internal-set-face-1 face 'foreground color 4 frame))
465fceed 185
ef436392
KH
186(defvar face-default-stipple "gray3"
187 "Default stipple pattern used on monochrome displays.
188This stipple pattern is used on monochrome displays
189instead of shades of gray for a face background color.
190See `set-face-stipple' for possible values for this variable.")
191
192(defun face-color-gray-p (color &optional frame)
193 "Return t if COLOR is a shade of gray (or white or black).
194FRAME specifies the frame and thus the display for interpreting COLOR."
195 (let* ((values (x-color-values color frame))
196 (r (nth 0 values))
197 (g (nth 1 values))
198 (b (nth 2 values)))
25ae394e
RS
199 (and values
200 (< (abs (- r g)) (/ (max 1 (abs r) (abs g)) 20))
ef436392
KH
201 (< (abs (- g b)) (/ (max 1 (abs g) (abs b)) 20))
202 (< (abs (- b r)) (/ (max 1 (abs b) (abs r)) 20)))))
203
feaad827 204(defun set-face-background (face color &optional frame)
465fceed
ER
205 "Change the background color of face FACE to COLOR (a string).
206If the optional FRAME argument is provided, change only
207in that frame; otherwise change each frame."
f60a629a 208 (interactive (internal-face-interactive "background" 'color))
ee09252a
RS
209 ;; For a specific frame, use gray stipple instead of gray color
210 ;; if the display does not support a gray color.
21ef90ee 211 (if (and frame (not (eq frame t)) color
a7acbbe4 212 ;; Check for support for foreground, not for background!
f1d71b2f
RS
213 ;; face-color-supported-p is smart enough to know
214 ;; that grays are "supported" as background
215 ;; because we are supposed to use stipple for them!
216 (not (face-color-supported-p frame color nil)))
ef436392 217 (set-face-stipple face face-default-stipple frame)
d0672e0d
RS
218 (if (null frame)
219 (let ((frames (frame-list)))
220 (while frames
221 (set-face-background (face-name face) color (car frames))
222 (setq frames (cdr frames)))
223 (set-face-background face color t)
224 color)
225 (internal-set-face-1 face 'background color 5 frame))))
465fceed 226
ef436392 227(defun set-face-stipple (face pixmap &optional frame)
72418504
RS
228 "Change the stipple pixmap of face FACE to PIXMAP.
229PIXMAP should be a string, the name of a file of pixmap data.
230The directories listed in the `x-bitmap-file-path' variable are searched.
465fceed 231
72418504
RS
232Alternatively, PIXMAP may be a list of the form (WIDTH HEIGHT DATA)
233where WIDTH and HEIGHT are the size in pixels,
234and DATA is a string, containing the raw bits of the bitmap.
465fceed 235
72418504
RS
236If the optional FRAME argument is provided, change only
237in that frame; otherwise change each frame."
3c5ddb48 238 (interactive (internal-face-interactive-stipple "stipple"))
ef436392 239 (internal-set-face-1 face 'background-pixmap pixmap 6 frame))
72418504
RS
240
241(defalias 'set-face-background-pixmap 'set-face-stipple)
465fceed 242
feaad827 243(defun set-face-underline-p (face underline-p &optional frame)
465fceed
ER
244 "Specify whether face FACE is underlined. (Yes if UNDERLINE-P is non-nil.)
245If the optional FRAME argument is provided, change only
246in that frame; otherwise change each frame."
247 (interactive (internal-face-interactive "underline-p" "underlined"))
f0138172 248 (internal-set-face-1 face 'underline underline-p 7 frame))
d11fba25 249
e8e4cda0
RS
250(defun set-face-inverse-video-p (face inverse-video-p &optional frame)
251 "Specify whether face FACE is in inverse video.
252\(Yes if INVERSE-VIDEO-P is non-nil.)
253If the optional FRAME argument is provided, change only
254in that frame; otherwise change each frame."
255 (interactive (internal-face-interactive "inverse-video-p" "inverse-video"))
256 (internal-set-face-1 face 'inverse-video inverse-video-p 8 frame))
257
d11fba25
RS
258(defun set-face-bold-p (face bold-p &optional frame)
259 "Specify whether face FACE is bold. (Yes if BOLD-P is non-nil.)
260If the optional FRAME argument is provided, change only
261in that frame; otherwise change each frame."
262 (cond ((eq bold-p nil) (make-face-unbold face frame t))
263 (t (make-face-bold face frame t))))
264
265(defun set-face-italic-p (face italic-p &optional frame)
266 "Specify whether face FACE is italic. (Yes if ITALIC-P is non-nil.)
267If the optional FRAME argument is provided, change only
268in that frame; otherwise change each frame."
269 (cond ((eq italic-p nil) (make-face-unitalic face frame t))
270 (t (make-face-italic face frame t))))
271
e42537fe 272(defalias 'set-face-doc-string 'set-face-documentation)
02e0989b 273(defun set-face-documentation (face string)
d11fba25
RS
274 "Set the documentation string for FACE to STRING."
275 (put face 'face-documentation string))
1c0a8710 276\f
2b979e14 277(defun modify-face-read-string (face default name alist)
6ffb01c4
RS
278 (let ((value
279 (completing-read
280 (if default
281 (format "Set face %s %s (default %s): "
282 face name (downcase default))
283 (format "Set face %s %s: " face name))
284 alist)))
285 (cond ((equal value "none")
286 nil)
287 ((equal value "")
288 default)
289 (t value))))
290
291(defun modify-face (face foreground background stipple
d343b6f1 292 bold-p italic-p underline-p &optional inverse-p frame)
1c0a8710 293 "Change the display attributes for face FACE.
905cf8f2
SM
294If the optional FRAME argument is provided, change only
295in that frame; otherwise change each frame.
296
297FOREGROUND and BACKGROUND should be a colour name string (or list of strings to
298try) or nil. STIPPLE should be a stipple pattern name string or nil.
299If nil, means do not change the display attribute corresponding to that arg.
300
d343b6f1
RS
301BOLD-P, ITALIC-P, UNDERLINE-P, and INVERSE-P specify whether
302the face should be set bold, italic, underlined or in inverse-video,
303respectively. If one of these arguments is neither nil or t, it means do not
304change the display attribute corresponding to that argument.
905cf8f2
SM
305
306If called interactively, prompts for a face name and face attributes."
1c0a8710
RS
307 (interactive
308 (let* ((completion-ignore-case t)
905cf8f2
SM
309 (face (symbol-name (read-face-name "Modify face: ")))
310 (colors (mapcar 'list x-colors))
311 (stipples (mapcar 'list (apply 'nconc
312 (mapcar 'directory-files
313 x-bitmap-file-path))))
314 (foreground (modify-face-read-string
315 face (face-foreground (intern face))
316 "foreground" colors))
317 (background (modify-face-read-string
318 face (face-background (intern face))
319 "background" colors))
e5de0238
RS
320 ;; If the stipple value is a list (WIDTH HEIGHT DATA),
321 ;; represent that as a string by printing it out.
322 (old-stipple-string
323 (if (stringp (face-stipple (intern face)))
324 (face-stipple (intern face))
3c5ddb48
RS
325 (if (face-stipple (intern face))
326 (prin1-to-string (face-stipple (intern face))))))
e5de0238
RS
327 (new-stipple-string
328 (modify-face-read-string
329 face old-stipple-string
330 "stipple" stipples))
331 ;; Convert the stipple value text we read
332 ;; back to a list if it looks like one.
333 ;; This makes the assumption that a pixmap file name
334 ;; won't start with an open-paren.
335 (stipple
3c5ddb48
RS
336 (and new-stipple-string
337 (if (string-match "^(" new-stipple-string)
338 (read new-stipple-string)
339 new-stipple-string)))
340 (bold-p (y-or-n-p (concat "Should face " face " be bold ")))
341 (italic-p (y-or-n-p (concat "Should face " face " be italic ")))
342 (underline-p (y-or-n-p (concat "Should face " face " be underlined ")))
d343b6f1 343 (inverse-p (y-or-n-p (concat "Should face " face " be inverse-video ")))
905cf8f2 344 (all-frames-p (y-or-n-p (concat "Modify face " face " in all frames "))))
1c0a8710
RS
345 (message "Face %s: %s" face
346 (mapconcat 'identity
347 (delq nil
348 (list (and foreground (concat (downcase foreground) " foreground"))
349 (and background (concat (downcase background) " background"))
e5de0238 350 (and stipple (concat (downcase new-stipple-string) " stipple"))
1c0a8710 351 (and bold-p "bold") (and italic-p "italic")
d343b6f1 352 (and inverse-p "inverse")
1c0a8710 353 (and underline-p "underline"))) ", "))
6ffb01c4 354 (list (intern face) foreground background stipple
d343b6f1 355 bold-p italic-p underline-p inverse-p
905cf8f2 356 (if all-frames-p nil (selected-frame)))))
d343b6f1
RS
357 ;; Clear this before we install the new foreground and background;
358 ;; otherwise, clearing it after would swap them!
359 (when (and (or foreground background) (face-inverse-video-p face))
573d18cb 360 (set-face-inverse-video-p face nil frame)
d343b6f1
RS
361 ;; Arrange to restore it after, if we are not setting it now.
362 (or (memq inverse-p '(t nil))
363 (setq inverse-p t)))
905cf8f2
SM
364 (condition-case nil
365 (face-try-color-list 'set-face-foreground face foreground frame)
366 (error nil))
367 (condition-case nil
368 (face-try-color-list 'set-face-background face background frame)
369 (error nil))
370 (condition-case nil
371 (set-face-stipple face stipple frame)
372 (error nil))
d343b6f1
RS
373 ;; Now that we have the new colors,
374 (if (memq inverse-p '(nil t))
375 (set-face-inverse-video-p face inverse-p frame))
e8e4cda0
RS
376 (cond ((eq bold-p nil)
377 (if (face-font face frame)
378 (make-face-unbold face frame t)))
379 ((eq bold-p t)
380 (make-face-bold face frame t)))
381 (cond ((eq italic-p nil)
382 (if (face-font face frame)
383 (make-face-unitalic face frame t)))
905cf8f2
SM
384 ((eq italic-p t) (make-face-italic face frame t)))
385 (if (memq underline-p '(nil t))
386 (set-face-underline-p face underline-p frame))
1c0a8710 387 (and (interactive-p) (redraw-display)))
bdda3754
JB
388\f
389;;;; Associating face names (symbols) with their face vectors.
390
66a5c2c6
JB
391(defvar global-face-data nil
392 "Internal data for face support functions. Not for external use.
393This is an alist associating face names with the default values for
394their parameters. Newly created frames get their data from here.")
395
bdda3754
JB
396(defun face-list ()
397 "Returns a list of all defined face names."
398 (mapcar 'car global-face-data))
399
400(defun internal-find-face (name &optional frame)
401 "Retrieve the face named NAME. Return nil if there is no such face.
402If the optional argument FRAME is given, this gets the face NAME for
403that frame; otherwise, it uses the selected frame.
404If FRAME is the symbol t, then the global, non-frame face is returned.
405If NAME is already a face, it is simply returned."
406 (if (and (eq frame t) (not (symbolp name)))
407 (setq name (face-name name)))
408 (if (symbolp name)
409 (cdr (assq name
410 (if (eq frame t)
411 global-face-data
412 (frame-face-alist (or frame (selected-frame))))))
413 (internal-check-face name)
414 name))
415
416(defun internal-get-face (name &optional frame)
417 "Retrieve the face named NAME; error if there is none.
418If the optional argument FRAME is given, this gets the face NAME for
419that frame; otherwise, it uses the selected frame.
420If FRAME is the symbol t, then the global, non-frame face is returned.
421If NAME is already a face, it is simply returned."
422 (or (internal-find-face name frame)
423 (internal-check-face name)))
424
425
426(defun internal-set-face-1 (face name value index frame)
427 (let ((inhibit-quit t))
428 (if (null frame)
429 (let ((frames (frame-list)))
430 (while frames
431 (internal-set-face-1 (face-name face) name value index (car frames))
432 (setq frames (cdr frames)))
433 (aset (internal-get-face (if (symbolp face) face (face-name face)) t)
434 index value)
435 value)
e8e4cda0
RS
436 (let ((internal-face (internal-get-face face frame)))
437 (or (eq frame t)
438 (if (eq name 'inverse-video)
439 (or (eq value (aref internal-face index))
440 (invert-face face frame))
87b6ab4c
RS
441 (and name (fboundp 'set-face-attribute-internal)
442 (set-face-attribute-internal (face-id face)
443 name value frame))))
e8e4cda0 444 (aset internal-face index value)))))
bdda3754
JB
445
446
447(defun read-face-name (prompt)
448 (let (face)
449 (while (= (length face) 0)
450 (setq face (completing-read prompt
451 (mapcar '(lambda (x) (list (symbol-name x)))
452 (face-list))
453 nil t)))
454 (intern face)))
455
456(defun internal-face-interactive (what &optional bool)
457 (let* ((fn (intern (concat "face-" what)))
458 (prompt (concat "Set " what " of face"))
459 (face (read-face-name (concat prompt ": ")))
460 (default (if (fboundp fn)
461 (or (funcall fn face (selected-frame))
462 (funcall fn 'default (selected-frame)))))
f60a629a
RS
463 value)
464 (setq value
465 (cond ((eq bool 'color)
466 (completing-read (concat prompt " " (symbol-name face) " to: ")
467 (mapcar (function (lambda (color)
468 (cons color color)))
469 x-colors)
470 nil nil nil nil default))
471 (bool
472 (y-or-n-p (concat "Should face " (symbol-name face)
473 " be " bool "? ")))
474 (t
475 (read-string (concat prompt " " (symbol-name face) " to: ")
476 nil nil default))))
bdda3754
JB
477 (list face (if (equal value "") nil value))))
478
3c5ddb48
RS
479(defun internal-face-interactive-stipple (what)
480 (let* ((fn (intern (concat "face-" what)))
481 (prompt (concat "Set " what " of face"))
482 (face (read-face-name (concat prompt ": ")))
483 (default (if (fboundp fn)
484 (or (funcall fn face (selected-frame))
485 (funcall fn 'default (selected-frame)))))
486 ;; If the stipple value is a list (WIDTH HEIGHT DATA),
487 ;; represent that as a string by printing it out.
488 (old-stipple-string
489 (if (stringp (face-stipple face))
490 (face-stipple face)
491 (if (null (face-stipple face))
492 nil
493 (prin1-to-string (face-stipple face)))))
494 (new-stipple-string
495 (read-string
496 (concat prompt " " (symbol-name face) " to: ")
497 old-stipple-string))
498 ;; Convert the stipple value text we read
499 ;; back to a list if it looks like one.
500 ;; This makes the assumption that a pixmap file name
501 ;; won't start with an open-paren.
502 (stipple
503 (if (string-match "^(" new-stipple-string)
504 (read new-stipple-string)
505 new-stipple-string)))
506 (list face (if (equal stipple "") nil stipple))))
465fceed 507
17b3a11b 508(defun make-face (name &optional no-resources)
465fceed
ER
509 "Define a new FACE on all frames.
510You can modify the font, color, etc of this face with the set-face- functions.
17b3a11b
RS
511If NO-RESOURCES is non-nil, then we ignore X resources
512and always make a face whose attributes are all nil.
513
465fceed 514If the face already exists, it is unmodified."
19fac299 515 (interactive "SMake face: ")
465fceed 516 (or (internal-find-face name)
1bcb155c 517 (let ((face (make-vector 12 nil)))
465fceed
ER
518 (aset face 0 'face)
519 (aset face 1 name)
520 (let* ((frames (frame-list))
521 (inhibit-quit t)
522 (id (internal-next-face-id)))
60a719b0
RS
523 (if (fboundp 'make-face-internal)
524 (make-face-internal id))
465fceed
ER
525 (aset face 2 id)
526 (while frames
527 (set-frame-face-alist (car frames)
528 (cons (cons name (copy-sequence face))
529 (frame-face-alist (car frames))))
530 (setq frames (cdr frames)))
531 (setq global-face-data (cons (cons name face) global-face-data)))
17b3a11b
RS
532 ;; When making a face after frames already exist
533 (or no-resources
534 (if (memq window-system '(x w32))
535 (make-face-x-resource-internal face)))
536 ;; Add to menu of faces.
33af44e8
BG
537 (if (fboundp 'facemenu-add-new-face)
538 (facemenu-add-new-face name))
7ee29ed8
RS
539 face))
540 name)
465fceed 541
17b3a11b
RS
542(defun make-empty-face (face)
543 "Define a new FACE on all frames, which initially reflects the defaults.
544You can modify the font, color, etc of this face with the set-face- functions.
545If the face already exists, it is unmodified."
546 (interactive "SMake empty face: ")
547 (make-face face t))
548
465fceed
ER
549;; Fill in a face by default based on X resources, for all existing frames.
550;; This has to be done when a new face is made.
551(defun make-face-x-resource-internal (face &optional frame set-anyway)
552 (cond ((null frame)
553 (let ((frames (frame-list)))
554 (while frames
b86b9918 555 (if (memq (framep (car frames)) '(x w32))
586ab698
RS
556 (make-face-x-resource-internal (face-name face)
557 (car frames) set-anyway))
465fceed
ER
558 (setq frames (cdr frames)))))
559 (t
560 (setq face (internal-get-face (face-name face) frame))
561 ;;
562 ;; These are things like "attributeForeground" instead of simply
563 ;; "foreground" because people tend to do things like "*foreground",
564 ;; which would cause all faces to be fully qualified, making faces
565 ;; inherit attributes in a non-useful way. So we've made them slightly
566 ;; less obvious to specify in order to make them work correctly in
567 ;; more random environments.
568 ;;
569 ;; I think these should be called "face.faceForeground" instead of
570 ;; "face.attributeForeground", but they're the way they are for
571 ;; hysterical reasons.
572 ;;
573 (let* ((name (symbol-name (face-name face)))
574 (fn (or (x-get-resource (concat name ".attributeFont")
575 "Face.AttributeFont")
576 (and set-anyway (face-font face))))
577 (fg (or (x-get-resource (concat name ".attributeForeground")
578 "Face.AttributeForeground")
579 (and set-anyway (face-foreground face))))
580 (bg (or (x-get-resource (concat name ".attributeBackground")
581 "Face.AttributeBackground")
582 (and set-anyway (face-background face))))
72418504
RS
583 (bgp (or (x-get-resource (concat name ".attributeStipple")
584 "Face.AttributeStipple")
585 (x-get-resource (concat name ".attributeBackgroundPixmap")
586 "Face.AttributeBackgroundPixmap")
587 (and set-anyway (face-stipple face))))
69718e9d
RS
588 (ulp (let ((resource (x-get-resource
589 (concat name ".attributeUnderline")
590 "Face.AttributeUnderline")))
591 (if resource
592 (member (downcase resource) '("on" "true"))
593 (and set-anyway (face-underline-p face)))))
465fceed
ER
594 )
595 (if fn
596 (condition-case ()
19deb21e
RS
597 (cond ((string= fn "italic")
598 (make-face-italic face))
599 ((string= fn "bold")
600 (make-face-bold face))
601 ((string= fn "bold-italic")
602 (make-face-bold-italic face))
603 (t
604 (set-face-font face fn frame)))
605 (error
606 (if (member fn '("italic" "bold" "bold-italic"))
607 (message "no %s version found for face `%s'" fn name)
608 (message "font `%s' not found for face `%s'" fn name)))))
465fceed
ER
609 (if fg
610 (condition-case ()
611 (set-face-foreground face fg frame)
612 (error (message "color `%s' not allocated for face `%s'" fg name))))
613 (if bg
614 (condition-case ()
615 (set-face-background face bg frame)
616 (error (message "color `%s' not allocated for face `%s'" bg name))))
72418504
RS
617 (if bgp
618 (condition-case ()
619 (set-face-stipple face bgp frame)
620 (error (message "pixmap `%s' not found for face `%s'" bgp name))))
465fceed
ER
621 (if (or ulp set-anyway)
622 (set-face-underline-p face ulp frame))
623 )))
624 face)
625
2f2ddd1e
RS
626(defun copy-face (old-face new-face &optional frame new-frame)
627 "Define a face just like OLD-FACE, with name NEW-FACE.
628If NEW-FACE already exists as a face, it is modified to be like OLD-FACE.
629If it doesn't already exist, it is created.
630
631If the optional argument FRAME is given as a frame,
632NEW-FACE is changed on FRAME only.
633If FRAME is t, the frame-independent default specification for OLD-FACE
634is copied to NEW-FACE.
635If FRAME is nil, copying is done for the frame-independent defaults
636and for each existing frame.
710e7005
RS
637If the optional fourth argument NEW-FRAME is given,
638copy the information from face OLD-FACE on frame FRAME
2f2ddd1e 639to NEW-FACE on frame NEW-FRAME."
710e7005 640 (or new-frame (setq new-frame frame))
da41135a 641 (let ((inhibit-quit t))
465fceed
ER
642 (if (null frame)
643 (let ((frames (frame-list)))
644 (while frames
2f2ddd1e 645 (copy-face old-face new-face (car frames))
465fceed 646 (setq frames (cdr frames)))
2f2ddd1e 647 (copy-face old-face new-face t))
da41135a
KH
648 (setq old-face (internal-get-face old-face frame))
649 (setq new-face (or (internal-find-face new-face new-frame)
650 (make-face new-face)))
52267b56
RS
651 (condition-case nil
652 ;; A face that has a global symbolic font modifier such as `bold'
653 ;; might legitimately get an error here.
654 ;; Use the frame's default font in that case.
655 (set-face-font new-face (face-font old-face frame) new-frame)
656 (error
657 (set-face-font new-face nil new-frame)))
87b6ab4c
RS
658 (set-face-font-explicit new-face (face-font-explicit old-face frame)
659 new-frame)
710e7005
RS
660 (set-face-foreground new-face (face-foreground old-face frame) new-frame)
661 (set-face-background new-face (face-background old-face frame) new-frame)
72418504
RS
662 (set-face-stipple new-face
663 (face-stipple old-face frame)
664 new-frame)
465fceed 665 (set-face-underline-p new-face (face-underline-p old-face frame)
710e7005 666 new-frame))
465fceed
ER
667 new-face))
668
669(defun face-equal (face1 face2 &optional frame)
ade516a1 670 "True if the faces FACE1 and FACE2 display in the same way."
465fceed
ER
671 (setq face1 (internal-get-face face1 frame)
672 face2 (internal-get-face face2 frame))
673 (and (equal (face-foreground face1 frame) (face-foreground face2 frame))
674 (equal (face-background face1 frame) (face-background face2 frame))
675 (equal (face-font face1 frame) (face-font face2 frame))
ae0249df 676 (eq (face-underline-p face1 frame) (face-underline-p face2 frame))
72418504
RS
677 (equal (face-stipple face1 frame)
678 (face-stipple face2 frame))))
465fceed
ER
679
680(defun face-differs-from-default-p (face &optional frame)
681 "True if face FACE displays differently from the default face, on FRAME.
682A face is considered to be ``the same'' as the default face if it is
683actually specified in the same way (equivalent fonts, etc) or if it is
684fully unspecified, and thus inherits the attributes of any face it
93d6fcef
RS
685is displayed on top of.
686
687The optional argument FRAME specifies which frame to test;
688if FRAME is t, test the default for new frames.
689If FRAME is nil or omitted, test the selected frame."
465fceed
ER
690 (let ((default (internal-get-face 'default frame)))
691 (setq face (internal-get-face face frame))
692 (not (and (or (equal (face-foreground default frame)
693 (face-foreground face frame))
694 (null (face-foreground face frame)))
695 (or (equal (face-background default frame)
696 (face-background face frame))
697 (null (face-background face frame)))
fbd44116
SM
698 (or (null (face-font face frame))
699 (equal (face-font face frame)
700 (or (face-font default frame)
701 (downcase
702 (cdr (assq 'font (frame-parameters frame)))))))
72418504
RS
703 (or (equal (face-stipple default frame)
704 (face-stipple face frame))
705 (null (face-stipple face frame)))
465fceed
ER
706 (equal (face-underline-p default frame)
707 (face-underline-p face frame))
708 ))))
709
93d6fcef
RS
710(defun face-nontrivial-p (face &optional frame)
711 "True if face FACE has some non-nil attribute.
712The optional argument FRAME specifies which frame to test;
713if FRAME is t, test the default for new frames.
714If FRAME is nil or omitted, test the selected frame."
715 (setq face (internal-get-face face frame))
716 (or (face-foreground face frame)
717 (face-background face frame)
718 (face-font face frame)
719 (face-stipple face frame)
720 (face-underline-p face frame)))
721
465fceed
ER
722
723(defun invert-face (face &optional frame)
724 "Swap the foreground and background colors of face FACE.
725If the face doesn't specify both foreground and background, then
8494bbf1 726set its foreground and background to the default background and foreground."
465fceed
ER
727 (interactive (list (read-face-name "Invert face: ")))
728 (setq face (internal-get-face face frame))
729 (let ((fg (face-foreground face frame))
730 (bg (face-background face frame)))
731 (if (or fg bg)
732 (progn
733 (set-face-foreground face bg frame)
734 (set-face-background face fg frame))
c5f0b2d4
RS
735 (let* ((frame-bg (cdr (assq 'background-color (frame-parameters frame))))
736 (default-bg (or (face-background 'default frame)
737 frame-bg))
738 (frame-fg (cdr (assq 'foreground-color (frame-parameters frame))))
739 (default-fg (or (face-foreground 'default frame)
740 frame-fg)))
741 (set-face-foreground face default-bg frame)
742 (set-face-background face default-fg frame))))
465fceed
ER
743 face)
744
745
746(defun internal-try-face-font (face font &optional frame)
747 "Like set-face-font, but returns nil on failure instead of an error."
748 (condition-case ()
87b6ab4c 749 (set-face-font-auto face font frame)
465fceed 750 (error nil)))
465fceed
ER
751\f
752;; Manipulating font names.
753
d7fa5aa2
RS
754(defvar x-font-regexp nil)
755(defvar x-font-regexp-head nil)
756(defvar x-font-regexp-weight nil)
757(defvar x-font-regexp-slant nil)
465fceed 758
021ca129
KH
759(defconst x-font-regexp-weight-subnum 1)
760(defconst x-font-regexp-slant-subnum 2)
761(defconst x-font-regexp-swidth-subnum 3)
762(defconst x-font-regexp-adstyle-subnum 4)
763
465fceed
ER
764;;; Regexps matching font names in "Host Portable Character Representation."
765;;;
766(let ((- "[-?]")
767 (foundry "[^-]+")
768 (family "[^-]+")
769 (weight "\\(bold\\|demibold\\|medium\\)") ; 1
770; (weight\? "\\(\\*\\|bold\\|demibold\\|medium\\|\\)") ; 1
771 (weight\? "\\([^-]*\\)") ; 1
772 (slant "\\([ior]\\)") ; 2
773; (slant\? "\\([ior?*]?\\)") ; 2
774 (slant\? "\\([^-]?\\)") ; 2
775; (swidth "\\(\\*\\|normal\\|semicondensed\\|\\)") ; 3
776 (swidth "\\([^-]*\\)") ; 3
777; (adstyle "\\(\\*\\|sans\\|\\)") ; 4
c8787b81 778 (adstyle "\\([^-]*\\)") ; 4
465fceed
ER
779 (pixelsize "[0-9]+")
780 (pointsize "[0-9][0-9]+")
781 (resx "[0-9][0-9]+")
782 (resy "[0-9][0-9]+")
783 (spacing "[cmp?*]")
784 (avgwidth "[0-9]+")
785 (registry "[^-]+")
786 (encoding "[^-]+")
787 )
788 (setq x-font-regexp
789 (concat "\\`\\*?[-?*]"
790 foundry - family - weight\? - slant\? - swidth - adstyle -
e20d641f
RS
791 pixelsize - pointsize - resx - resy - spacing - avgwidth -
792 registry - encoding "\\*?\\'"
465fceed
ER
793 ))
794 (setq x-font-regexp-head
795 (concat "\\`[-?*]" foundry - family - weight\? - slant\?
796 "\\([-*?]\\|\\'\\)"))
797 (setq x-font-regexp-slant (concat - slant -))
798 (setq x-font-regexp-weight (concat - weight -))
799 nil)
800
281dc1c2
JB
801(defun x-resolve-font-name (pattern &optional face frame)
802 "Return a font name matching PATTERN.
803All wildcards in PATTERN become substantiated.
10d89673
JB
804If PATTERN is nil, return the name of the frame's base font, which never
805contains wildcards.
e17dbede
RS
806Given optional arguments FACE and FRAME, return a font which is
807also the same size as FACE on FRAME, or fail."
14e6867c
RS
808 (or (symbolp face)
809 (setq face (face-name face)))
810 (and (eq frame t)
811 (setq frame nil))
10d89673 812 (if pattern
8db93e45 813 ;; Note that x-list-fonts has code to handle a face with nil as its font.
abd89b80 814 (let ((fonts (x-list-fonts pattern face frame 1)))
10d89673
JB
815 (or fonts
816 (if face
962a60aa
RS
817 (if (string-match "\\*" pattern)
818 (if (null (face-font face))
819 (error "No matching fonts are the same height as the frame default font")
820 (error "No matching fonts are the same height as face `%s'" face))
821 (if (null (face-font face))
822 (error "Height of font `%s' doesn't match the frame default font"
823 pattern)
824 (error "Height of font `%s' doesn't match face `%s'"
825 pattern face)))
7cf6fac1 826 (error "No fonts match `%s'" pattern)))
10d89673
JB
827 (car fonts))
828 (cdr (assq 'font (frame-parameters (selected-frame))))))
281dc1c2 829
465fceed 830(defun x-frob-font-weight (font which)
b7ffee5f
SM
831 (let ((case-fold-search t))
832 (cond ((string-match x-font-regexp font)
833 (concat (substring font 0
834 (match-beginning x-font-regexp-weight-subnum))
835 which
836 (substring font (match-end x-font-regexp-weight-subnum)
837 (match-beginning x-font-regexp-adstyle-subnum))
838 ;; Replace the ADD_STYLE_NAME field with *
839 ;; because the info in it may not be the same
840 ;; for related fonts.
841 "*"
842 (substring font (match-end x-font-regexp-adstyle-subnum))))
528fbf51
RS
843 ((string-match x-font-regexp-head font)
844 (concat (substring font 0 (match-beginning 1)) which
845 (substring font (match-end 1))))
846 ((string-match x-font-regexp-weight font)
b7ffee5f
SM
847 (concat (substring font 0 (match-beginning 1)) which
848 (substring font (match-end 1)))))))
465fceed
ER
849
850(defun x-frob-font-slant (font which)
b7ffee5f
SM
851 (let ((case-fold-search t))
852 (cond ((string-match x-font-regexp font)
853 (concat (substring font 0
854 (match-beginning x-font-regexp-slant-subnum))
855 which
856 (substring font (match-end x-font-regexp-slant-subnum)
857 (match-beginning x-font-regexp-adstyle-subnum))
858 ;; Replace the ADD_STYLE_NAME field with *
859 ;; because the info in it may not be the same
860 ;; for related fonts.
861 "*"
862 (substring font (match-end x-font-regexp-adstyle-subnum))))
528fbf51
RS
863 ((string-match x-font-regexp-head font)
864 (concat (substring font 0 (match-beginning 2)) which
865 (substring font (match-end 2))))
866 ((string-match x-font-regexp-slant font)
b7ffee5f
SM
867 (concat (substring font 0 (match-beginning 1)) which
868 (substring font (match-end 1)))))))
465fceed
ER
869
870(defun x-make-font-bold (font)
f3f31ccf
RS
871 "Given an X font specification, make a bold version of it.
872If that can't be done, return nil."
465fceed
ER
873 (x-frob-font-weight font "bold"))
874
875(defun x-make-font-demibold (font)
f3f31ccf
RS
876 "Given an X font specification, make a demibold version of it.
877If that can't be done, return nil."
465fceed
ER
878 (x-frob-font-weight font "demibold"))
879
880(defun x-make-font-unbold (font)
f3f31ccf
RS
881 "Given an X font specification, make a non-bold version of it.
882If that can't be done, return nil."
465fceed
ER
883 (x-frob-font-weight font "medium"))
884
885(defun x-make-font-italic (font)
f3f31ccf
RS
886 "Given an X font specification, make an italic version of it.
887If that can't be done, return nil."
465fceed
ER
888 (x-frob-font-slant font "i"))
889
890(defun x-make-font-oblique (font) ; you say tomayto...
f3f31ccf
RS
891 "Given an X font specification, make an oblique version of it.
892If that can't be done, return nil."
465fceed
ER
893 (x-frob-font-slant font "o"))
894
895(defun x-make-font-unitalic (font)
f3f31ccf
RS
896 "Given an X font specification, make a non-italic version of it.
897If that can't be done, return nil."
465fceed 898 (x-frob-font-slant font "r"))
b7d7285c
KH
899
900(defun x-make-font-bold-italic (font)
901 "Given an X font specification, make a bold and italic version of it.
902If that can't be done, return nil."
903 (and (setq font (x-make-font-bold font))
904 (x-make-font-italic font)))
465fceed
ER
905\f
906;;; non-X-specific interface
907
bb9a81fc 908(defun make-face-bold (face &optional frame noerror)
465fceed 909 "Make the font of the given face be bold, if possible.
bb9a81fc 910If NOERROR is non-nil, return nil on failure."
465fceed 911 (interactive (list (read-face-name "Make which face bold: ")))
1bcb155c
RS
912 ;; Set the bold-p flag, first of all.
913 (internal-set-face-1 face nil t 10 frame)
534dbc97 914 (if (and (eq frame t) (listp (face-font face t)))
f3f31ccf
RS
915 (set-face-font face (if (memq 'italic (face-font face t))
916 '(bold italic) '(bold))
917 t)
488bedff 918 (let (font)
f3f31ccf
RS
919 (if (null frame)
920 (let ((frames (frame-list)))
921 ;; Make this face bold in global-face-data.
922 (make-face-bold face t noerror)
923 ;; Make this face bold in each frame.
924 (while frames
925 (make-face-bold face (car frames) noerror)
926 (setq frames (cdr frames))))
927 (setq face (internal-get-face face frame))
928 (setq font (or (face-font face frame)
929 (face-font face t)))
930 (if (listp font)
931 (setq font nil))
932 (setq font (or font
933 (face-font 'default frame)
934 (cdr (assq 'font (frame-parameters frame)))))
488bedff
RS
935 (or (and font (make-face-bold-internal face frame font))
936 ;; We failed to find a bold version of the font.
937 noerror
938 (error "No bold version of %S" font))))))
f3f31ccf 939
4b3203d9
RS
940(defun make-face-bold-internal (face frame font)
941 (let (f2)
942 (or (and (setq f2 (x-make-font-bold font))
943 (internal-try-face-font face f2 frame))
944 (and (setq f2 (x-make-font-demibold font))
945 (internal-try-face-font face f2 frame)))))
bb9a81fc
JB
946
947(defun make-face-italic (face &optional frame noerror)
465fceed 948 "Make the font of the given face be italic, if possible.
bb9a81fc 949If NOERROR is non-nil, return nil on failure."
465fceed 950 (interactive (list (read-face-name "Make which face italic: ")))
1bcb155c
RS
951 ;; Set the italic-p flag, first of all.
952 (internal-set-face-1 face nil t 11 frame)
534dbc97 953 (if (and (eq frame t) (listp (face-font face t)))
f3f31ccf
RS
954 (set-face-font face (if (memq 'bold (face-font face t))
955 '(bold italic) '(italic))
956 t)
488bedff 957 (let (font)
f3f31ccf
RS
958 (if (null frame)
959 (let ((frames (frame-list)))
960 ;; Make this face italic in global-face-data.
961 (make-face-italic face t noerror)
962 ;; Make this face italic in each frame.
963 (while frames
964 (make-face-italic face (car frames) noerror)
965 (setq frames (cdr frames))))
966 (setq face (internal-get-face face frame))
967 (setq font (or (face-font face frame)
968 (face-font face t)))
969 (if (listp font)
970 (setq font nil))
971 (setq font (or font
972 (face-font 'default frame)
973 (cdr (assq 'font (frame-parameters frame)))))
488bedff
RS
974 (or (and font (make-face-italic-internal face frame font))
975 ;; We failed to find an italic version of the font.
976 noerror
977 (error "No italic version of %S" font))))))
f3f31ccf 978
4b3203d9
RS
979(defun make-face-italic-internal (face frame font)
980 (let (f2)
981 (or (and (setq f2 (x-make-font-italic font))
982 (internal-try-face-font face f2 frame))
983 (and (setq f2 (x-make-font-oblique font))
984 (internal-try-face-font face f2 frame)))))
bb9a81fc
JB
985
986(defun make-face-bold-italic (face &optional frame noerror)
465fceed 987 "Make the font of the given face be bold and italic, if possible.
bb9a81fc 988If NOERROR is non-nil, return nil on failure."
465fceed 989 (interactive (list (read-face-name "Make which face bold-italic: ")))
1bcb155c
RS
990 ;; Set the bold-p and italic-p flags, first of all.
991 (internal-set-face-1 face nil t 10 frame)
992 (internal-set-face-1 face nil t 11 frame)
534dbc97 993 (if (and (eq frame t) (listp (face-font face t)))
f3f31ccf 994 (set-face-font face '(bold italic) t)
488bedff 995 (let (font)
f3f31ccf
RS
996 (if (null frame)
997 (let ((frames (frame-list)))
998 ;; Make this face bold-italic in global-face-data.
999 (make-face-bold-italic face t noerror)
1000 ;; Make this face bold in each frame.
1001 (while frames
1002 (make-face-bold-italic face (car frames) noerror)
1003 (setq frames (cdr frames))))
1004 (setq face (internal-get-face face frame))
1005 (setq font (or (face-font face frame)
1006 (face-font face t)))
1007 (if (listp font)
1008 (setq font nil))
1009 (setq font (or font
1010 (face-font 'default frame)
1011 (cdr (assq 'font (frame-parameters frame)))))
488bedff
RS
1012 (or (and font (make-face-bold-italic-internal face frame font))
1013 ;; We failed to find a bold italic version.
1014 noerror
1015 (error "No bold italic version of %S" font))))))
f3f31ccf 1016
4b3203d9 1017(defun make-face-bold-italic-internal (face frame font)
f3f31ccf
RS
1018 (let (f2 f3)
1019 (or (and (setq f2 (x-make-font-italic font))
1020 (not (equal font f2))
1021 (setq f3 (x-make-font-bold f2))
1022 (not (equal f2 f3))
1023 (internal-try-face-font face f3 frame))
1024 (and (setq f2 (x-make-font-oblique font))
1025 (not (equal font f2))
1026 (setq f3 (x-make-font-bold f2))
1027 (not (equal f2 f3))
1028 (internal-try-face-font face f3 frame))
1029 (and (setq f2 (x-make-font-italic font))
1030 (not (equal font f2))
1031 (setq f3 (x-make-font-demibold f2))
1032 (not (equal f2 f3))
1033 (internal-try-face-font face f3 frame))
1034 (and (setq f2 (x-make-font-oblique font))
1035 (not (equal font f2))
1036 (setq f3 (x-make-font-demibold f2))
1037 (not (equal f2 f3))
1038 (internal-try-face-font face f3 frame)))))
bb9a81fc
JB
1039
1040(defun make-face-unbold (face &optional frame noerror)
465fceed 1041 "Make the font of the given face be non-bold, if possible.
bb9a81fc 1042If NOERROR is non-nil, return nil on failure."
465fceed 1043 (interactive (list (read-face-name "Make which face non-bold: ")))
1bcb155c
RS
1044 ;; Clear the bold-p flag, first of all.
1045 (internal-set-face-1 face nil nil 10 frame)
534dbc97 1046 (if (and (eq frame t) (listp (face-font face t)))
f3f31ccf
RS
1047 (set-face-font face (if (memq 'italic (face-font face t))
1048 '(italic) nil)
1049 t)
488bedff 1050 (let (font font1)
f3f31ccf
RS
1051 (if (null frame)
1052 (let ((frames (frame-list)))
1053 ;; Make this face unbold in global-face-data.
1054 (make-face-unbold face t noerror)
1055 ;; Make this face unbold in each frame.
1056 (while frames
1057 (make-face-unbold face (car frames) noerror)
1058 (setq frames (cdr frames))))
1059 (setq face (internal-get-face face frame))
1060 (setq font1 (or (face-font face frame)
1061 (face-font face t)))
1062 (if (listp font1)
1063 (setq font1 nil))
1064 (setq font1 (or font1
1065 (face-font 'default frame)
1066 (cdr (assq 'font (frame-parameters frame)))))
96616c04 1067 (setq font (and font1 (x-make-font-unbold font1)))
488bedff
RS
1068 (or (if font (internal-try-face-font face font frame))
1069 noerror
1070 (error "No unbold version of %S" font1))))))
bb9a81fc
JB
1071
1072(defun make-face-unitalic (face &optional frame noerror)
465fceed 1073 "Make the font of the given face be non-italic, if possible.
bb9a81fc 1074If NOERROR is non-nil, return nil on failure."
465fceed 1075 (interactive (list (read-face-name "Make which face non-italic: ")))
1bcb155c
RS
1076 ;; Clear the italic-p flag, first of all.
1077 (internal-set-face-1 face nil nil 11 frame)
534dbc97 1078 (if (and (eq frame t) (listp (face-font face t)))
f3f31ccf
RS
1079 (set-face-font face (if (memq 'bold (face-font face t))
1080 '(bold) nil)
1081 t)
488bedff 1082 (let (font font1)
f3f31ccf
RS
1083 (if (null frame)
1084 (let ((frames (frame-list)))
1085 ;; Make this face unitalic in global-face-data.
1086 (make-face-unitalic face t noerror)
1087 ;; Make this face unitalic in each frame.
1088 (while frames
1089 (make-face-unitalic face (car frames) noerror)
1090 (setq frames (cdr frames))))
1091 (setq face (internal-get-face face frame))
1092 (setq font1 (or (face-font face frame)
1093 (face-font face t)))
1094 (if (listp font1)
1095 (setq font1 nil))
1096 (setq font1 (or font1
1097 (face-font 'default frame)
1098 (cdr (assq 'font (frame-parameters frame)))))
96616c04 1099 (setq font (and font1 (x-make-font-unitalic font1)))
488bedff
RS
1100 (or (if font (internal-try-face-font face font frame))
1101 noerror
1102 (error "No unitalic version of %S" font1))))))
465fceed 1103\f
710e7005
RS
1104(defvar list-faces-sample-text
1105 "abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ"
1106 "*Text string to display as the sample text for `list-faces-display'.")
1107
1108;; The name list-faces would be more consistent, but let's avoid a conflict
1109;; with Lucid, which uses that name differently.
1110(defun list-faces-display ()
1111 "List all faces, using the same sample text in each.
1112The sample text is a string that comes from the variable
1113`list-faces-sample-text'.
1114
1115It is possible to give a particular face name different appearances in
1116different frames. This command shows the appearance in the
1117selected frame."
1118 (interactive)
1119 (let ((faces (sort (face-list) (function string-lessp)))
1120 (face nil)
1121 (frame (selected-frame))
1122 disp-frame window)
1123 (with-output-to-temp-buffer "*Faces*"
1124 (save-excursion
1125 (set-buffer standard-output)
1126 (setq truncate-lines t)
1127 (while faces
1128 (setq face (car faces))
1129 (setq faces (cdr faces))
1130 (insert (format "%25s " (symbol-name face)))
1131 (let ((beg (point)))
1132 (insert list-faces-sample-text)
1133 (insert "\n")
23b04eac
RS
1134 (put-text-property beg (1- (point)) 'face face)
1135 ;; If the sample text has multiple lines, line up all of them.
1136 (goto-char beg)
1137 (forward-line 1)
1138 (while (not (eobp))
1139 (insert " ")
1140 (forward-line 1))))
710e7005
RS
1141 (goto-char (point-min))))
1142 ;; If the *Faces* buffer appears in a different frame,
1143 ;; copy all the face definitions from FRAME,
1144 ;; so that the display will reflect the frame that was selected.
1145 (setq window (get-buffer-window (get-buffer "*Faces*") t))
1146 (setq disp-frame (if window (window-frame window)
1147 (car (frame-list))))
1148 (or (eq frame disp-frame)
1149 (let ((faces (face-list)))
1150 (while faces
1151 (copy-face (car faces) (car faces) frame disp-frame)
1152 (setq faces (cdr faces)))))))
19deb21e
RS
1153
1154(defun describe-face (face)
1155 "Display the properties of face FACE."
1156 (interactive (list (read-face-name "Describe face: ")))
1157 (with-output-to-temp-buffer "*Help*"
1158 (princ "Properties of face `")
1159 (princ (face-name face))
1160 (princ "':") (terpri)
1161 (princ "Foreground: ") (princ (face-foreground face)) (terpri)
1162 (princ "Background: ") (princ (face-background face)) (terpri)
1163 (princ " Font: ") (princ (face-font face)) (terpri)
1164 (princ "Underlined: ") (princ (if (face-underline-p face) "yes" "no")) (terpri)
64b26d5c
RS
1165 (princ " Stipple: ") (princ (or (face-stipple face) "none")) (terpri)
1166 (terpri)
1167 (princ "Documentation:") (terpri)
02e0989b 1168 (let ((doc (face-documentation face)))
64b26d5c
RS
1169 (if doc
1170 (princ doc)
1171 (princ "not documented as a face.")))))
710e7005 1172\f
d11fba25
RS
1173;;; Setting a face based on a SPEC.
1174
95c7d3d3
RS
1175(defun face-attr-match-p (face attrs &optional frame)
1176 (or frame (setq frame (selected-frame)))
1177 (and (face-attr-match-1 face frame attrs ':inverse-video
1178 'face-inverse-video-p)
1179 (if (face-inverse-video-p face frame)
1180 (and
1181 (face-attr-match-1 face frame attrs
1182 ':foreground 'face-background
1183 (cdr (assq 'foreground-color
1184 (frame-parameters frame))))
1185 (face-attr-match-1 face frame attrs
1186 ':background 'face-foreground
1187 (cdr (assq 'background-color
1188 (frame-parameters frame)))))
1189 (and
1190 (face-attr-match-1 face frame attrs ':foreground 'face-foreground)
1191 (face-attr-match-1 face frame attrs ':background 'face-background)))
1192 (face-attr-match-1 face frame attrs ':stipple 'face-stipple)
1193 (face-attr-match-1 face frame attrs ':bold 'face-bold-p)
1194 (face-attr-match-1 face frame attrs ':italic 'face-italic-p)
1195 (face-attr-match-1 face frame attrs ':underline 'face-underline-p)
1196))
1197
1198(defun face-attr-match-1 (face frame plist property function
1199 &optional defaultval)
1200 (while (and plist (not (eq (car plist) property)))
1201 (setq plist (cdr (cdr plist))))
1202 (eq (funcall function face frame)
1203 (if plist
1204 (nth 1 plist)
1205 (or defaultval
1206 (funcall function 'default frame)))))
1207
1208(defun face-spec-match-p (face spec &optional frame)
1209 "Return t if FACE, on FRAME, matches what SPEC says it should look like."
1210 (face-attr-match-p face (face-spec-choose spec frame) frame))
1211
1212(defun face-attr-construct (face &optional frame)
1213 "Return a defface-style attribute list for FACE, as it exists on FRAME."
1214 (let (result)
1215 (if (face-inverse-video-p face frame)
1216 (progn
1217 (setq result (cons ':inverse-video (cons t result)))
1218 (or (face-attr-match-1 face frame nil
1219 ':foreground 'face-background
1220 (cdr (assq 'foreground-color
1221 (frame-parameters frame))))
1222 (setq result (cons ':foreground
1223 (cons (face-foreground face frame) result))))
1224 (or (face-attr-match-1 face frame nil
1225 ':background 'face-foreground
1226 (cdr (assq 'background-color
1227 (frame-parameters frame))))
1228 (setq result (cons ':background
1229 (cons (face-background face frame) result)))))
1230 (if (face-foreground face frame)
1231 (setq result (cons ':foreground
1232 (cons (face-foreground face frame) result))))
1233 (if (face-background face frame)
1234 (setq result (cons ':background
1235 (cons (face-background face frame) result)))))
1236 (if (face-stipple face frame)
1237 (setq result (cons ':stipple
1238 (cons (face-stipple face frame) result))))
1239 (if (face-bold-p face frame)
1240 (setq result (cons ':bold
1241 (cons (face-bold-p face frame) result))))
1242 (if (face-italic-p face frame)
1243 (setq result (cons ':italic
1244 (cons (face-italic-p face frame) result))))
1245 (if (face-underline-p face frame)
1246 (setq result (cons ':underline
1247 (cons (face-underline-p face frame) result))))
1248 result))
1249
1250;; Choose the proper attributes for FRAME, out of SPEC.
1251(defun face-spec-choose (spec &optional frame)
1252 (or frame (setq frame (selected-frame)))
1253 (let ((tail spec)
1254 result)
1255 (while tail
d11fba25
RS
1256 (let* ((entry (car tail))
1257 (display (nth 0 entry))
1258 (attrs (nth 1 entry)))
1259 (setq tail (cdr tail))
d11fba25 1260 (when (face-spec-set-match-display display frame)
95c7d3d3
RS
1261 (setq result attrs tail nil))))
1262 result))
1263
1264(defun face-spec-set (face spec &optional frame)
1265 "Set FACE's face attributes according to the first matching entry in SPEC.
1266If optional FRAME is non-nil, set it for that frame only.
1267If it is nil, then apply SPEC to each frame individually.
1268See `defface' for information about SPEC."
1269 (if frame
1270 (let ((attrs (face-spec-choose spec frame)))
1271 (when attrs
1272 ;; If the font was set automatically, clear it out
1273 ;; to allow it to be set it again.
1274 (unless (face-font-explicit face frame)
1275 (set-face-font face nil frame))
d343b6f1 1276 (modify-face face '(nil) '(nil) nil nil nil nil nil frame)
d11fba25
RS
1277 (face-spec-set-1 face frame attrs ':foreground 'set-face-foreground)
1278 (face-spec-set-1 face frame attrs ':background 'set-face-background)
1279 (face-spec-set-1 face frame attrs ':stipple 'set-face-stipple)
1280 (face-spec-set-1 face frame attrs ':bold 'set-face-bold-p)
1281 (face-spec-set-1 face frame attrs ':italic 'set-face-italic-p)
1282 (face-spec-set-1 face frame attrs ':underline 'set-face-underline-p)
e8e4cda0 1283 (face-spec-set-1 face frame attrs ':inverse-video
95c7d3d3
RS
1284 'set-face-inverse-video-p)))
1285 (let ((frames (frame-list))
1286 frame)
1287 (while frames
1288 (setq frame (car frames)
1289 frames (cdr frames))
1290 (face-spec-set face (or (get face 'saved-face)
1291 (get face 'face-defface-spec))
1292 frame)
1293 (face-spec-set face spec frame)))))
d11fba25
RS
1294
1295(defun face-spec-set-1 (face frame plist property function)
1296 (while (and plist (not (eq (car plist) property)))
1297 (setq plist (cdr (cdr plist))))
1298 (if plist
1299 (funcall function face (nth 1 plist) frame)))
1300
1301(defun face-spec-set-match-display (display frame)
1302 "Non-nil iff DISPLAY matches FRAME.
1303DISPLAY is part of a spec such as can be used in `defface'.
1304If FRAME is nil, the current FRAME is used."
1305 (let* ((conjuncts display)
1306 conjunct req options
1307 ;; t means we have succeeded against all
1308 ;; the conjunts in DISPLAY that have been tested so far.
1309 (match t))
1310 (if (eq conjuncts t)
1311 (setq conjuncts nil))
1312 (while (and conjuncts match)
1313 (setq conjunct (car conjuncts)
1314 conjuncts (cdr conjuncts)
1315 req (car conjunct)
1316 options (cdr conjunct)
1317 match (cond ((eq req 'type)
1318 (memq window-system options))
1319 ((eq req 'class)
1320 (memq (frame-parameter frame 'display-type) options))
1321 ((eq req 'background)
1322 (memq (frame-parameter frame 'background-mode)
1323 options))
1324 (t
1325 (error "Unknown req `%S' with options `%S'"
1326 req options)))))
1327 match))
465fceed 1328\f
465fceed
ER
1329;; Like x-create-frame but also set up the faces.
1330
1331(defun x-create-frame-with-faces (&optional parameters)
6e4aafdc
KH
1332 ;; Read this frame's geometry resource, if it has an explicit name,
1333 ;; and put the specs into PARAMETERS.
1334 (let* ((name (or (cdr (assq 'name parameters))
313b841c 1335 (cdr (assq 'name default-frame-alist))))
6e4aafdc 1336 (x-resource-name name)
28ceec49 1337 (res-geometry (if name (x-get-resource "geometry" "Geometry"))))
6e4aafdc 1338 (if res-geometry
28ceec49 1339 (let ((parsed (x-parse-geometry res-geometry)))
6e4aafdc
KH
1340 ;; If the resource specifies a position,
1341 ;; call the position and size "user-specified".
1342 (if (or (assq 'top parsed) (assq 'left parsed))
28ceec49
SM
1343 (setq parsed (append '((user-position . t) (user-size . t))
1344 parsed)))
313b841c
KH
1345 ;; Put the geometry parameters at the end.
1346 ;; Copy default-frame-alist so that they go after it.
28ceec49 1347 (setq parameters (append parameters default-frame-alist parsed)))))
ef436392
KH
1348 (let (frame)
1349 (if (null global-face-data)
d11fba25
RS
1350 (progn
1351 (setq frame (x-create-frame parameters))
1352 (frame-set-background-mode frame))
ef436392 1353 (let* ((visibility-spec (assq 'visibility parameters))
d11fba25 1354 success faces rest)
ef436392
KH
1355 (setq frame (x-create-frame (cons '(visibility . nil) parameters)))
1356 (unwind-protect
1357 (progn
d11fba25
RS
1358 ;; Copy the face alist, copying the face vectors
1359 ;; and emptying out their attributes.
1360 (setq faces
1361 (mapcar '(lambda (elt)
1362 (cons (car elt)
1363 (vector 'face
1364 (face-name (cdr elt))
1365 (face-id (cdr elt))
1bcb155c
RS
1366 nil
1367 nil nil nil nil
1368 nil nil nil nil)))
d11fba25 1369 global-face-data))
ef436392
KH
1370 (set-frame-face-alist frame faces)
1371
d11fba25
RS
1372 ;; Handle the reverse-video frame parameter
1373 ;; and X resource. x-create-frame does not handle this one.
ef436392
KH
1374 (if (cdr (or (assq 'reverse parameters)
1375 (assq 'reverse default-frame-alist)
1376 (let ((resource (x-get-resource "reverseVideo"
1377 "ReverseVideo")))
1378 (if resource
1379 (cons nil (member (downcase resource)
1380 '("on" "true")))))))
1381 (let* ((params (frame-parameters frame))
1382 (bg (cdr (assq 'foreground-color params)))
1383 (fg (cdr (assq 'background-color params))))
1384 (modify-frame-parameters frame
1385 (list (cons 'foreground-color fg)
1386 (cons 'background-color bg)))
1387 (if (equal bg (cdr (assq 'border-color params)))
1388 (modify-frame-parameters frame
1389 (list (cons 'border-color fg))))
1390 (if (equal bg (cdr (assq 'mouse-color params)))
1391 (modify-frame-parameters frame
1392 (list (cons 'mouse-color fg))))
1393 (if (equal bg (cdr (assq 'cursor-color params)))
1394 (modify-frame-parameters frame
1395 (list (cons 'cursor-color fg))))))
d11fba25 1396
f0201260
RS
1397 (frame-set-background-mode frame)
1398
b1eb5e6a 1399 (face-set-after-frame-default frame)
d11fba25
RS
1400
1401 ;; Make the frame visible, if desired.
ef436392
KH
1402 (if (null visibility-spec)
1403 (make-frame-visible frame)
1404 (modify-frame-parameters frame (list visibility-spec)))
1405 (setq success t))
1406 (or success
1407 (delete-frame frame)))))
ef436392 1408 frame))
e09c52a8 1409
b1eb5e6a
RS
1410;; Update a frame's faces after the frame font changes.
1411;; This is called from modify-frame-parameters
1412;; as well as from elsewhere in this file.
1413(defun face-set-after-frame-default (frame)
1414 (let ((rest (frame-face-alist frame)))
1415 (while rest
1416 ;; Set up each face, first from the defface information,
1417 ;; then the global face data, and then the X resources.
1418 (let* ((face (car (car rest)))
1419 (spec (or (get face 'saved-face)
1420 (get face 'face-defface-spec)))
1421 (global (cdr (assq face global-face-data)))
1422 (local (cdr (car rest))))
87b6ab4c 1423 (when spec
b1eb5e6a
RS
1424 (face-spec-set face spec frame))
1425 (face-fill-in face global frame)
1426 (make-face-x-resource-internal local frame))
1427 (setq rest (cdr rest)))))
1428
d11fba25
RS
1429(defcustom frame-background-mode nil
1430 "*The brightness of the background.
1431Set this to the symbol dark if your background color is dark, light if
1432your background is light, or nil (default) if you want Emacs to
1433examine the brightness for you."
1434 :group 'faces
1435 :type '(choice (choice-item dark)
1436 (choice-item light)
1437 (choice-item :tag "default" nil)))
1438
1439(defun frame-set-background-mode (frame)
1440 "Set up the `background-mode' and `display-type' frame parameters for FRAME."
1441 (let ((bg-resource (x-get-resource ".backgroundMode"
1442 "BackgroundMode"))
1443 (params (frame-parameters frame))
1444 (bg-mode))
1445 (setq bg-mode
1446 (cond (frame-background-mode)
1447 (bg-resource (intern (downcase bg-resource)))
1448 ((< (apply '+ (x-color-values
1449 (cdr (assq 'background-color params))
1450 frame))
1451 ;; Just looking at the screen,
1452 ;; colors whose values add up to .6 of the white total
1453 ;; still look dark to me.
1454 (* (apply '+ (x-color-values "white" frame)) .6))
1455 'dark)
1456 (t 'light)))
1457 (modify-frame-parameters frame
1458 (list (cons 'background-mode bg-mode)
1459 (cons 'display-type
1460 (cond ((x-display-color-p frame)
1461 'color)
1462 ((x-display-grayscale-p frame)
1463 'grayscale)
1464 (t 'mono)))))))
1465
9d52c8d3 1466;; Update a frame's faces when we change its default font.
b1eb5e6a 1467(defun frame-update-faces (frame) nil)
9d52c8d3 1468
f16c38ae
RS
1469;; Update the colors of FACE, after FRAME's own colors have been changed.
1470;; This applies only to faces with global color specifications
1471;; that are not simple constants.
1472(defun frame-update-face-colors (frame)
1473 (let ((faces global-face-data))
1474 (while faces
1475 (condition-case nil
1476 (let* ((data (cdr (car faces)))
1477 (face (car (car faces)))
1478 (foreground (face-foreground data))
1479 (background (face-background data)))
1480 ;; If the global spec is a specific color,
1481 ;; which doesn't depend on the frame's attributes,
1482 ;; we don't need to recalculate it now.
1483 (or (listp foreground)
1484 (setq foreground nil))
1485 (or (listp background)
1486 (setq background nil))
1487 ;; If we are going to frob this face at all,
1488 ;; reinitialize it first.
1489 (if (or foreground background)
1490 (progn (set-face-foreground face nil frame)
1491 (set-face-background face nil frame)))
1492 (if foreground
1493 (face-try-color-list 'set-face-foreground
1494 face foreground frame))
1495 (if background
1496 (face-try-color-list 'set-face-background
1497 face background frame)))
1498 (error nil))
1499 (setq faces (cdr faces)))))
1500
19ae9866
RS
1501;; Fill in the face FACE from frame-independent face data DATA.
1502;; DATA should be the non-frame-specific ("global") face vector
1503;; for the face. FACE should be a face name or face object.
1504;; FRAME is the frame to act on; it must be an actual frame, not nil or t.
1505(defun face-fill-in (face data frame)
1506 (condition-case nil
1507 (let ((foreground (face-foreground data))
1508 (background (face-background data))
ca58b3ec
KH
1509 (font (face-font data))
1510 (stipple (face-stipple data)))
e8e4cda0
RS
1511 (if (face-underline-p data)
1512 (set-face-underline-p face (face-underline-p data) frame))
19ae9866
RS
1513 (if foreground
1514 (face-try-color-list 'set-face-foreground
1515 face foreground frame))
1516 (if background
1517 (face-try-color-list 'set-face-background
1518 face background frame))
1519 (if (listp font)
1520 (let ((bold (memq 'bold font))
1521 (italic (memq 'italic font)))
1522 (cond ((and bold italic)
1523 (make-face-bold-italic face frame))
1524 (bold
1525 (make-face-bold face frame))
1526 (italic
1527 (make-face-italic face frame))))
1528 (if font
ca58b3ec
KH
1529 (set-face-font face font frame)))
1530 (if stipple
1531 (set-face-stipple face stipple frame)))
19ae9866 1532 (error nil)))
e09c52a8 1533
4099a32d
RS
1534;; Assuming COLOR is a valid color name,
1535;; return t if it can be displayed on FRAME.
1536(defun face-color-supported-p (frame color background-p)
055ff5a6
RS
1537 (and window-system
1538 (or (x-display-color-p frame)
1539 ;; A black-and-white display can implement these.
1540 (member color '("black" "white"))
1541 ;; A black-and-white display can fake gray for background.
1542 (and background-p
1543 (face-color-gray-p color frame))
1544 ;; A grayscale display can implement colors that are gray (more or less).
1545 (and (x-display-grayscale-p frame)
1546 (face-color-gray-p color frame)))))
4099a32d 1547
19ae9866
RS
1548;; Use FUNCTION to store a color in FACE on FRAME.
1549;; COLORS is either a single color or a list of colors.
1550;; If it is a list, try the colors one by one until one of them
1551;; succeeds. We signal an error only if all the colors failed.
1552;; t as COLORS or as an element of COLORS means to invert the face.
1553;; That can't fail, so any subsequent elements after the t are ignored.
1554(defun face-try-color-list (function face colors frame)
1555 (if (stringp colors)
4099a32d
RS
1556 (if (face-color-supported-p frame colors
1557 (eq function 'set-face-background))
1558 (funcall function face colors frame))
19ae9866 1559 (if (eq colors t)
e8e4cda0 1560 (set-face-inverse-video-p face t frame)
19ae9866
RS
1561 (let (done)
1562 (while (and colors (not done))
de52827f 1563 (if (or (memq (car colors) '(t underline))
4099a32d
RS
1564 (face-color-supported-p frame (car colors)
1565 (eq function 'set-face-background)))
1566 (if (cdr colors)
1567 ;; If there are more colors to try, catch errors
1568 ;; and set `done' if we succeed.
1569 (condition-case nil
1570 (progn
1571 (cond ((eq (car colors) t)
e8e4cda0 1572 (set-face-inverse-video-p face t frame))
4099a32d
RS
1573 ((eq (car colors) 'underline)
1574 (set-face-underline-p face t frame))
1575 (t
1576 (funcall function face (car colors) frame)))
1577 (setq done t))
1578 (error nil))
1579 ;; If this is the last color, let the error get out if it fails.
1580 ;; If it succeeds, we will exit anyway after this iteration.
1581 (cond ((eq (car colors) t)
e8e4cda0 1582 (set-face-inverse-video-p face t frame))
4099a32d
RS
1583 ((eq (car colors) 'underline)
1584 (set-face-underline-p face t frame))
1585 (t
1586 (funcall function face (car colors) frame)))))
19ae9866 1587 (setq colors (cdr colors)))))))
e09c52a8 1588
55893d25
RS
1589;;; Make the standard faces.
1590;;; The C code knows the default and modeline faces as faces 0 and 1,
1591;;; so they must be the first two faces made.
1592(make-face 'default)
1593(make-face 'modeline)
1594(make-face 'highlight)
1595
1596;; These aren't really special in any way, but they're nice to have around.
1597
1598(make-face 'bold)
1599(make-face 'italic)
1600(make-face 'bold-italic)
1601(make-face 'region)
1602(make-face 'secondary-selection)
1603(make-face 'underline)
1604
1605(setq region-face (face-id 'region))
1606
1607;; Specify how these faces look, and their documentation.
1608(let ((all '((bold "Use bold font." ((t (:bold t))))
1609 (bold-italic "Use bold italic font." ((t (:bold t :italic t))))
1610 (italic "Use italic font." ((t (:italic t))))
1611 (underline "Underline text." ((t (:underline t))))
1612 (default "Used for text not covered by other faces." ((t nil)))
1613 (highlight "Highlight text in some way."
1c1e0fe5
RS
1614 ((((class color) (background light))
1615 (:background "darkseagreen2"))
1616 (((class color) (background dark))
1617 (:background "darkolivegreen"))
55893d25
RS
1618 (t (:inverse-video t))))
1619 (modeline "Used for displaying the modeline."
1620 ((t (:inverse-video t))))
1621 (region "Used for displaying the region."
1c1e0fe5
RS
1622 ((((class color) (background dark))
1623 (:background "blue"))
1624 (t (:background "gray"))))
55893d25
RS
1625 (secondary-selection
1626 "Used for displaying the secondary selection."
1c1e0fe5
RS
1627 ((((class color) (background light))
1628 (:background "paleturquoise"))
1629 (((class color) (background dark))
1630 (:background "darkslateblue"))
55893d25
RS
1631 (t (:inverse-video t))))))
1632 entry symbol doc spec)
1633 (while all
1634 (setq entry (car all)
1635 all (cdr all)
1636 symbol (nth 0 entry)
1637 doc (nth 1 entry)
1638 spec (nth 2 entry))
1639 (put symbol 'face-documentation doc)
1640 (put symbol 'face-defface-spec spec)))
465fceed 1641
f0138172
JB
1642(provide 'faces)
1643
465fceed 1644;;; faces.el ends here