annotate lisp/faces.el @ 6926:027b7de8a571

(debug, debugger-eval-expression): Preserve match-data.
author Karl Heuer <kwzh@gnu.org>
date Sat, 16 Apr 1994 07:18:26 +0000
parents 086e14489073
children 74edb669a7e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1 ;;; faces.el --- Lisp interface to the c "face" structure
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2
5929
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
3 ;; Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc.
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
4
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
5 ;; This file is part of GNU Emacs.
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
6
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
7 ;; GNU Emacs is free software; you can redistribute it and/or modify
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
8 ;; it under the terms of the GNU General Public License as published by
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
9 ;; the Free Software Foundation; either version 2, or (at your option)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
10 ;; any later version.
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
11
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
12 ;; GNU Emacs is distributed in the hope that it will be useful,
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
15 ;; GNU General Public License for more details.
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
16
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
17 ;; You should have received a copy of the GNU General Public License
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
18 ;; along with GNU Emacs; see the file COPYING. If not, write to
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
19 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
20
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
21 ;;; Commentary:
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
22
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
23 ;; Mostly derived from Lucid.
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
24
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
25 ;;; Code:
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
26
2744
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
27
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
28 ;;;; Functions for manipulating face vectors.
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
29
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
30 ;;; A face vector is a vector of the form:
5929
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
31 ;;; [face NAME ID FONT FOREGROUND BACKGROUND BACKGROUND-PIXMAP UNDERLINE]
2744
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
32
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
33 ;;; Type checkers.
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
34 (defsubst internal-facep (x)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
35 (and (vectorp x) (= (length x) 8) (eq (aref x 0) 'face)))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
36
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
37 (defmacro internal-check-face (face)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
38 (` (while (not (internal-facep (, face)))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
39 (setq (, face) (signal 'wrong-type-argument (list 'internal-facep (, face)))))))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
40
2744
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
41 ;;; Accessors.
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
42 (defsubst face-name (face)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
43 "Return the name of face FACE."
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
44 (aref (internal-get-face face) 1))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
45
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
46 (defsubst face-id (face)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
47 "Return the internal ID number of face FACE."
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
48 (aref (internal-get-face face) 2))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
49
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
50 (defsubst face-font (face &optional frame)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
51 "Return the font name of face FACE, or nil if it is unspecified.
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
52 If the optional argument FRAME is given, report on face FACE in that frame.
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
53 If FRAME is t, report on the defaults for face FACE (for new frames).
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
54 The font default for a face is either nil, or a list
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
55 of the form (bold), (italic) or (bold italic).
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
56 If FRAME is omitted or nil, use the selected frame."
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
57 (aref (internal-get-face face frame) 3))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
58
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
59 (defsubst face-foreground (face &optional frame)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
60 "Return the foreground color name of face FACE, or nil if unspecified.
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
61 If the optional argument FRAME is given, report on face FACE in that frame.
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
62 If FRAME is t, report on the defaults for face FACE (for new frames).
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
63 If FRAME is omitted or nil, use the selected frame."
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
64 (aref (internal-get-face face frame) 4))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
65
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
66 (defsubst face-background (face &optional frame)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
67 "Return the background color name of face FACE, or nil if unspecified.
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
68 If the optional argument FRAME is given, report on face FACE in that frame.
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
69 If FRAME is t, report on the defaults for face FACE (for new frames).
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
70 If FRAME is omitted or nil, use the selected frame."
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
71 (aref (internal-get-face face frame) 5))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
72
3812
0bc757649dd7 (set-face-background-pixmap, face-background-pixmap): Functions commented out.
Richard M. Stallman <rms@gnu.org>
parents: 3555
diff changeset
73 ;;(defsubst face-background-pixmap (face &optional frame)
0bc757649dd7 (set-face-background-pixmap, face-background-pixmap): Functions commented out.
Richard M. Stallman <rms@gnu.org>
parents: 3555
diff changeset
74 ;; "Return the background pixmap name of face FACE, or nil if unspecified.
0bc757649dd7 (set-face-background-pixmap, face-background-pixmap): Functions commented out.
Richard M. Stallman <rms@gnu.org>
parents: 3555
diff changeset
75 ;;If the optional argument FRAME is given, report on face FACE in that frame.
0bc757649dd7 (set-face-background-pixmap, face-background-pixmap): Functions commented out.
Richard M. Stallman <rms@gnu.org>
parents: 3555
diff changeset
76 ;;Otherwise report on the defaults for face FACE (for new frames)."
0bc757649dd7 (set-face-background-pixmap, face-background-pixmap): Functions commented out.
Richard M. Stallman <rms@gnu.org>
parents: 3555
diff changeset
77 ;; (aref (internal-get-face face frame) 6))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
78
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
79 (defsubst face-underline-p (face &optional frame)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
80 "Return t if face FACE is underlined.
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
81 If the optional argument FRAME is given, report on face FACE in that frame.
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
82 If FRAME is t, report on the defaults for face FACE (for new frames).
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
83 If FRAME is omitted or nil, use the selected frame."
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
84 (aref (internal-get-face face frame) 7))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
85
2744
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
86
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
87 ;;; Mutators.
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
88
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
89 (defsubst set-face-font (face font &optional frame)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
90 "Change the font of face FACE to FONT (a string).
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
91 If the optional FRAME argument is provided, change only
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
92 in that frame; otherwise change each frame."
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
93 (interactive (internal-face-interactive "font"))
3130
82c29bacb6b3 * faces.el (x-resolve-font-name): If PATTERN is nil, return the
Jim Blandy <jimb@redhat.com>
parents: 3071
diff changeset
94 (if (stringp font) (setq font (x-resolve-font-name font face frame)))
82c29bacb6b3 * faces.el (x-resolve-font-name): If PATTERN is nil, return the
Jim Blandy <jimb@redhat.com>
parents: 3071
diff changeset
95 (internal-set-face-1 face 'font font 3 frame))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
96
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
97 (defsubst set-face-foreground (face color &optional frame)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
98 "Change the foreground color of face FACE to COLOR (a string).
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
99 If the optional FRAME argument is provided, change only
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
100 in that frame; otherwise change each frame."
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
101 (interactive (internal-face-interactive "foreground"))
2715
9caee9338229 * faces.el: Call internal-set-face-1, not internat-set-face-1.
Jim Blandy <jimb@redhat.com>
parents: 2714
diff changeset
102 (internal-set-face-1 face 'foreground color 4 frame))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
103
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
104 (defsubst set-face-background (face color &optional frame)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
105 "Change the background color of face FACE to COLOR (a string).
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
106 If the optional FRAME argument is provided, change only
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
107 in that frame; otherwise change each frame."
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
108 (interactive (internal-face-interactive "background"))
2715
9caee9338229 * faces.el: Call internal-set-face-1, not internat-set-face-1.
Jim Blandy <jimb@redhat.com>
parents: 2714
diff changeset
109 (internal-set-face-1 face 'background color 5 frame))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
110
3812
0bc757649dd7 (set-face-background-pixmap, face-background-pixmap): Functions commented out.
Richard M. Stallman <rms@gnu.org>
parents: 3555
diff changeset
111 ;;(defsubst set-face-background-pixmap (face name &optional frame)
0bc757649dd7 (set-face-background-pixmap, face-background-pixmap): Functions commented out.
Richard M. Stallman <rms@gnu.org>
parents: 3555
diff changeset
112 ;; "Change the background pixmap of face FACE to PIXMAP.
0bc757649dd7 (set-face-background-pixmap, face-background-pixmap): Functions commented out.
Richard M. Stallman <rms@gnu.org>
parents: 3555
diff changeset
113 ;;PIXMAP should be a string, the name of a file of pixmap data.
0bc757649dd7 (set-face-background-pixmap, face-background-pixmap): Functions commented out.
Richard M. Stallman <rms@gnu.org>
parents: 3555
diff changeset
114 ;;The directories listed in the `x-bitmap-file-path' variable are searched.
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
115
3812
0bc757649dd7 (set-face-background-pixmap, face-background-pixmap): Functions commented out.
Richard M. Stallman <rms@gnu.org>
parents: 3555
diff changeset
116 ;;Alternatively, PIXMAP may be a list of the form (WIDTH HEIGHT DATA)
0bc757649dd7 (set-face-background-pixmap, face-background-pixmap): Functions commented out.
Richard M. Stallman <rms@gnu.org>
parents: 3555
diff changeset
117 ;;where WIDTH and HEIGHT are the size in pixels,
0bc757649dd7 (set-face-background-pixmap, face-background-pixmap): Functions commented out.
Richard M. Stallman <rms@gnu.org>
parents: 3555
diff changeset
118 ;;and DATA is a string, containing the raw bits of the bitmap.
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
119
3812
0bc757649dd7 (set-face-background-pixmap, face-background-pixmap): Functions commented out.
Richard M. Stallman <rms@gnu.org>
parents: 3555
diff changeset
120 ;;If the optional FRAME argument is provided, change only
0bc757649dd7 (set-face-background-pixmap, face-background-pixmap): Functions commented out.
Richard M. Stallman <rms@gnu.org>
parents: 3555
diff changeset
121 ;;in that frame; otherwise change each frame."
0bc757649dd7 (set-face-background-pixmap, face-background-pixmap): Functions commented out.
Richard M. Stallman <rms@gnu.org>
parents: 3555
diff changeset
122 ;; (interactive (internal-face-interactive "background-pixmap"))
0bc757649dd7 (set-face-background-pixmap, face-background-pixmap): Functions commented out.
Richard M. Stallman <rms@gnu.org>
parents: 3555
diff changeset
123 ;; (internal-set-face-1 face 'background-pixmap name 6 frame))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
124
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
125 (defsubst set-face-underline-p (face underline-p &optional frame)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
126 "Specify whether face FACE is underlined. (Yes if UNDERLINE-P is non-nil.)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
127 If the optional FRAME argument is provided, change only
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
128 in that frame; otherwise change each frame."
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
129 (interactive (internal-face-interactive "underline-p" "underlined"))
2715
9caee9338229 * faces.el: Call internal-set-face-1, not internat-set-face-1.
Jim Blandy <jimb@redhat.com>
parents: 2714
diff changeset
130 (internal-set-face-1 face 'underline underline-p 7 frame))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
131
2744
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
132
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
133 ;;;; Associating face names (symbols) with their face vectors.
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
134
3925
f286657c098e * faces.el (global-face-data): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 3911
diff changeset
135 (defvar global-face-data nil
f286657c098e * faces.el (global-face-data): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 3911
diff changeset
136 "Internal data for face support functions. Not for external use.
f286657c098e * faces.el (global-face-data): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 3911
diff changeset
137 This is an alist associating face names with the default values for
f286657c098e * faces.el (global-face-data): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 3911
diff changeset
138 their parameters. Newly created frames get their data from here.")
f286657c098e * faces.el (global-face-data): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 3911
diff changeset
139
2744
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
140 (defun face-list ()
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
141 "Returns a list of all defined face names."
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
142 (mapcar 'car global-face-data))
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
143
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
144 (defun internal-find-face (name &optional frame)
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
145 "Retrieve the face named NAME. Return nil if there is no such face.
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
146 If the optional argument FRAME is given, this gets the face NAME for
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
147 that frame; otherwise, it uses the selected frame.
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
148 If FRAME is the symbol t, then the global, non-frame face is returned.
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
149 If NAME is already a face, it is simply returned."
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
150 (if (and (eq frame t) (not (symbolp name)))
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
151 (setq name (face-name name)))
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
152 (if (symbolp name)
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
153 (cdr (assq name
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
154 (if (eq frame t)
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
155 global-face-data
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
156 (frame-face-alist (or frame (selected-frame))))))
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
157 (internal-check-face name)
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
158 name))
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
159
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
160 (defun internal-get-face (name &optional frame)
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
161 "Retrieve the face named NAME; error if there is none.
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
162 If the optional argument FRAME is given, this gets the face NAME for
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
163 that frame; otherwise, it uses the selected frame.
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
164 If FRAME is the symbol t, then the global, non-frame face is returned.
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
165 If NAME is already a face, it is simply returned."
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
166 (or (internal-find-face name frame)
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
167 (internal-check-face name)))
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
168
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
169
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
170 (defun internal-set-face-1 (face name value index frame)
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
171 (let ((inhibit-quit t))
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
172 (if (null frame)
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
173 (let ((frames (frame-list)))
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
174 (while frames
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
175 (internal-set-face-1 (face-name face) name value index (car frames))
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
176 (setq frames (cdr frames)))
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
177 (aset (internal-get-face (if (symbolp face) face (face-name face)) t)
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
178 index value)
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
179 value)
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
180 (or (eq frame t)
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
181 (set-face-attribute-internal (face-id face) name value frame))
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
182 (aset (internal-get-face face frame) index value))))
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
183
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
184
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
185 (defun read-face-name (prompt)
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
186 (let (face)
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
187 (while (= (length face) 0)
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
188 (setq face (completing-read prompt
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
189 (mapcar '(lambda (x) (list (symbol-name x)))
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
190 (face-list))
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
191 nil t)))
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
192 (intern face)))
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
193
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
194 (defun internal-face-interactive (what &optional bool)
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
195 (let* ((fn (intern (concat "face-" what)))
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
196 (prompt (concat "Set " what " of face"))
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
197 (face (read-face-name (concat prompt ": ")))
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
198 (default (if (fboundp fn)
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
199 (or (funcall fn face (selected-frame))
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
200 (funcall fn 'default (selected-frame)))))
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
201 (value (if bool
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
202 (y-or-n-p (concat "Should face " (symbol-name face)
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
203 " be " bool "? "))
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
204 (read-string (concat prompt " " (symbol-name face) " to: ")
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
205 default))))
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
206 (list face (if (equal value "") nil value))))
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
207
f4fc0c4c76f9 Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents: 2715
diff changeset
208
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
209
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
210 (defun make-face (name)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
211 "Define a new FACE on all frames.
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
212 You can modify the font, color, etc of this face with the set-face- functions.
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
213 If the face already exists, it is unmodified."
3001
c6c6e476d93d * faces.el (make-face): Change interactive spec to 'S'.
Jim Blandy <jimb@redhat.com>
parents: 2906
diff changeset
214 (interactive "SMake face: ")
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
215 (or (internal-find-face name)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
216 (let ((face (make-vector 8 nil)))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
217 (aset face 0 'face)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
218 (aset face 1 name)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
219 (let* ((frames (frame-list))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
220 (inhibit-quit t)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
221 (id (internal-next-face-id)))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
222 (make-face-internal id)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
223 (aset face 2 id)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
224 (while frames
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
225 (set-frame-face-alist (car frames)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
226 (cons (cons name (copy-sequence face))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
227 (frame-face-alist (car frames))))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
228 (setq frames (cdr frames)))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
229 (setq global-face-data (cons (cons name face) global-face-data)))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
230 ;; when making a face after frames already exist
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
231 (if (eq window-system 'x)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
232 (make-face-x-resource-internal face))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
233 face)))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
234
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
235 ;; Fill in a face by default based on X resources, for all existing frames.
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
236 ;; This has to be done when a new face is made.
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
237 (defun make-face-x-resource-internal (face &optional frame set-anyway)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
238 (cond ((null frame)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
239 (let ((frames (frame-list)))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
240 (while frames
6873
086e14489073 (make-face-x-resource-internal): Don't mess with terminal frames.
Richard M. Stallman <rms@gnu.org>
parents: 6871
diff changeset
241 (if (eq (framep (car frames)) 'x)
086e14489073 (make-face-x-resource-internal): Don't mess with terminal frames.
Richard M. Stallman <rms@gnu.org>
parents: 6871
diff changeset
242 (make-face-x-resource-internal (face-name face)
086e14489073 (make-face-x-resource-internal): Don't mess with terminal frames.
Richard M. Stallman <rms@gnu.org>
parents: 6871
diff changeset
243 (car frames) set-anyway))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
244 (setq frames (cdr frames)))))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
245 (t
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
246 (setq face (internal-get-face (face-name face) frame))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
247 ;;
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
248 ;; These are things like "attributeForeground" instead of simply
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
249 ;; "foreground" because people tend to do things like "*foreground",
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
250 ;; which would cause all faces to be fully qualified, making faces
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
251 ;; inherit attributes in a non-useful way. So we've made them slightly
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
252 ;; less obvious to specify in order to make them work correctly in
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
253 ;; more random environments.
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
254 ;;
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
255 ;; I think these should be called "face.faceForeground" instead of
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
256 ;; "face.attributeForeground", but they're the way they are for
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
257 ;; hysterical reasons.
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
258 ;;
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
259 (let* ((name (symbol-name (face-name face)))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
260 (fn (or (x-get-resource (concat name ".attributeFont")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
261 "Face.AttributeFont")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
262 (and set-anyway (face-font face))))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
263 (fg (or (x-get-resource (concat name ".attributeForeground")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
264 "Face.AttributeForeground")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
265 (and set-anyway (face-foreground face))))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
266 (bg (or (x-get-resource (concat name ".attributeBackground")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
267 "Face.AttributeBackground")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
268 (and set-anyway (face-background face))))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
269 ;; (bgp (or (x-get-resource (concat name ".attributeBackgroundPixmap")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
270 ;; "Face.AttributeBackgroundPixmap")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
271 ;; (and set-anyway (face-background-pixmap face))))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
272 (ulp (or (x-get-resource (concat name ".attributeUnderline")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
273 "Face.AttributeUnderline")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
274 (and set-anyway (face-underline-p face))))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
275 )
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
276 (if fn
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
277 (condition-case ()
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
278 (set-face-font face fn frame)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
279 (error (message "font `%s' not found for face `%s'" fn name))))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
280 (if fg
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
281 (condition-case ()
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
282 (set-face-foreground face fg frame)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
283 (error (message "color `%s' not allocated for face `%s'" fg name))))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
284 (if bg
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
285 (condition-case ()
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
286 (set-face-background face bg frame)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
287 (error (message "color `%s' not allocated for face `%s'" bg name))))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
288 ;; (if bgp
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
289 ;; (condition-case ()
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
290 ;; (set-face-background-pixmap face bgp frame)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
291 ;; (error (message "pixmap `%s' not found for face `%s'" bgp name))))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
292 (if (or ulp set-anyway)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
293 (set-face-underline-p face ulp frame))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
294 )))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
295 face)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
296
5849
d0fc9207705a (copy-face): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5199
diff changeset
297 (defun copy-face (old-face new-face &optional frame new-frame)
d0fc9207705a (copy-face): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5199
diff changeset
298 "Define a face just like OLD-FACE, with name NEW-FACE.
d0fc9207705a (copy-face): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5199
diff changeset
299 If NEW-FACE already exists as a face, it is modified to be like OLD-FACE.
d0fc9207705a (copy-face): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5199
diff changeset
300 If it doesn't already exist, it is created.
d0fc9207705a (copy-face): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5199
diff changeset
301
d0fc9207705a (copy-face): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5199
diff changeset
302 If the optional argument FRAME is given as a frame,
d0fc9207705a (copy-face): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5199
diff changeset
303 NEW-FACE is changed on FRAME only.
d0fc9207705a (copy-face): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5199
diff changeset
304 If FRAME is t, the frame-independent default specification for OLD-FACE
d0fc9207705a (copy-face): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5199
diff changeset
305 is copied to NEW-FACE.
d0fc9207705a (copy-face): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5199
diff changeset
306 If FRAME is nil, copying is done for the frame-independent defaults
d0fc9207705a (copy-face): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5199
diff changeset
307 and for each existing frame.
4083
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
308 If the optional fourth argument NEW-FRAME is given,
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
309 copy the information from face OLD-FACE on frame FRAME
5849
d0fc9207705a (copy-face): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5199
diff changeset
310 to NEW-FACE on frame NEW-FRAME."
4083
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
311 (or new-frame (setq new-frame frame))
6145
843ce3f872c2 (copy-face): Don't change old-face and new-face before the frame loop.
Karl Heuer <kwzh@gnu.org>
parents: 5955
diff changeset
312 (let ((inhibit-quit t))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
313 (if (null frame)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
314 (let ((frames (frame-list)))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
315 (while frames
5849
d0fc9207705a (copy-face): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5199
diff changeset
316 (copy-face old-face new-face (car frames))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
317 (setq frames (cdr frames)))
5849
d0fc9207705a (copy-face): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5199
diff changeset
318 (copy-face old-face new-face t))
6145
843ce3f872c2 (copy-face): Don't change old-face and new-face before the frame loop.
Karl Heuer <kwzh@gnu.org>
parents: 5955
diff changeset
319 (setq old-face (internal-get-face old-face frame))
843ce3f872c2 (copy-face): Don't change old-face and new-face before the frame loop.
Karl Heuer <kwzh@gnu.org>
parents: 5955
diff changeset
320 (setq new-face (or (internal-find-face new-face new-frame)
843ce3f872c2 (copy-face): Don't change old-face and new-face before the frame loop.
Karl Heuer <kwzh@gnu.org>
parents: 5955
diff changeset
321 (make-face new-face)))
4083
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
322 (set-face-font new-face (face-font old-face frame) new-frame)
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
323 (set-face-foreground new-face (face-foreground old-face frame) new-frame)
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
324 (set-face-background new-face (face-background old-face frame) new-frame)
2800
a7b260d27c2c (face-initialize): Don't create the `modeline' face.
Richard M. Stallman <rms@gnu.org>
parents: 2764
diff changeset
325 ;;; (set-face-background-pixmap
4083
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
326 ;;; new-face (face-background-pixmap old-face frame) new-frame)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
327 (set-face-underline-p new-face (face-underline-p old-face frame)
4083
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
328 new-frame))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
329 new-face))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
330
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
331 (defun face-equal (face1 face2 &optional frame)
2906
ca9bf00d4b19 * xfaces.el (face-equal): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 2826
diff changeset
332 "True if the faces FACE1 and FACE2 display in the same way."
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
333 (setq face1 (internal-get-face face1 frame)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
334 face2 (internal-get-face face2 frame))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
335 (and (equal (face-foreground face1 frame) (face-foreground face2 frame))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
336 (equal (face-background face1 frame) (face-background face2 frame))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
337 (equal (face-font face1 frame) (face-font face2 frame))
4122
82f0b478a551 (face-equal): Don't mess with face-background-pixmap.
Richard M. Stallman <rms@gnu.org>
parents: 4083
diff changeset
338 ;; (equal (face-background-pixmap face1 frame)
82f0b478a551 (face-equal): Don't mess with face-background-pixmap.
Richard M. Stallman <rms@gnu.org>
parents: 4083
diff changeset
339 ;; (face-background-pixmap face2 frame))
82f0b478a551 (face-equal): Don't mess with face-background-pixmap.
Richard M. Stallman <rms@gnu.org>
parents: 4083
diff changeset
340 ))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
341
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
342 (defun face-differs-from-default-p (face &optional frame)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
343 "True if face FACE displays differently from the default face, on FRAME.
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
344 A face is considered to be ``the same'' as the default face if it is
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
345 actually specified in the same way (equivalent fonts, etc) or if it is
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
346 fully unspecified, and thus inherits the attributes of any face it
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
347 is displayed on top of."
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
348 (let ((default (internal-get-face 'default frame)))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
349 (setq face (internal-get-face face frame))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
350 (not (and (or (equal (face-foreground default frame)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
351 (face-foreground face frame))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
352 (null (face-foreground face frame)))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
353 (or (equal (face-background default frame)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
354 (face-background face frame))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
355 (null (face-background face frame)))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
356 (or (equal (face-font default frame) (face-font face frame))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
357 (null (face-font face frame)))
2800
a7b260d27c2c (face-initialize): Don't create the `modeline' face.
Richard M. Stallman <rms@gnu.org>
parents: 2764
diff changeset
358 ;;; (or (equal (face-background-pixmap default frame)
a7b260d27c2c (face-initialize): Don't create the `modeline' face.
Richard M. Stallman <rms@gnu.org>
parents: 2764
diff changeset
359 ;;; (face-background-pixmap face frame))
a7b260d27c2c (face-initialize): Don't create the `modeline' face.
Richard M. Stallman <rms@gnu.org>
parents: 2764
diff changeset
360 ;;; (null (face-background-pixmap face frame)))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
361 (equal (face-underline-p default frame)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
362 (face-underline-p face frame))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
363 ))))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
364
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
365
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
366 (defun invert-face (face &optional frame)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
367 "Swap the foreground and background colors of face FACE.
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
368 If the face doesn't specify both foreground and background, then
2800
a7b260d27c2c (face-initialize): Don't create the `modeline' face.
Richard M. Stallman <rms@gnu.org>
parents: 2764
diff changeset
369 set its foreground and background to the default background and foreground."
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
370 (interactive (list (read-face-name "Invert face: ")))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
371 (setq face (internal-get-face face frame))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
372 (let ((fg (face-foreground face frame))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
373 (bg (face-background face frame)))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
374 (if (or fg bg)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
375 (progn
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
376 (set-face-foreground face bg frame)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
377 (set-face-background face fg frame))
2800
a7b260d27c2c (face-initialize): Don't create the `modeline' face.
Richard M. Stallman <rms@gnu.org>
parents: 2764
diff changeset
378 (set-face-foreground face (or (face-background 'default frame)
a7b260d27c2c (face-initialize): Don't create the `modeline' face.
Richard M. Stallman <rms@gnu.org>
parents: 2764
diff changeset
379 (cdr (assq 'background-color (frame-parameters frame))))
a7b260d27c2c (face-initialize): Don't create the `modeline' face.
Richard M. Stallman <rms@gnu.org>
parents: 2764
diff changeset
380 frame)
a7b260d27c2c (face-initialize): Don't create the `modeline' face.
Richard M. Stallman <rms@gnu.org>
parents: 2764
diff changeset
381 (set-face-background face (or (face-foreground 'default frame)
a7b260d27c2c (face-initialize): Don't create the `modeline' face.
Richard M. Stallman <rms@gnu.org>
parents: 2764
diff changeset
382 (cdr (assq 'foreground-color (frame-parameters frame))))
a7b260d27c2c (face-initialize): Don't create the `modeline' face.
Richard M. Stallman <rms@gnu.org>
parents: 2764
diff changeset
383 frame)))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
384 face)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
385
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
386
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
387 (defun internal-try-face-font (face font &optional frame)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
388 "Like set-face-font, but returns nil on failure instead of an error."
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
389 (condition-case ()
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
390 (set-face-font face font frame)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
391 (error nil)))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
392
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
393 ;; Manipulating font names.
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
394
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
395 (defconst x-font-regexp nil)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
396 (defconst x-font-regexp-head nil)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
397 (defconst x-font-regexp-weight nil)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
398 (defconst x-font-regexp-slant nil)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
399
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
400 ;;; Regexps matching font names in "Host Portable Character Representation."
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
401 ;;;
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
402 (let ((- "[-?]")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
403 (foundry "[^-]+")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
404 (family "[^-]+")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
405 (weight "\\(bold\\|demibold\\|medium\\)") ; 1
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
406 ; (weight\? "\\(\\*\\|bold\\|demibold\\|medium\\|\\)") ; 1
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
407 (weight\? "\\([^-]*\\)") ; 1
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
408 (slant "\\([ior]\\)") ; 2
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
409 ; (slant\? "\\([ior?*]?\\)") ; 2
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
410 (slant\? "\\([^-]?\\)") ; 2
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
411 ; (swidth "\\(\\*\\|normal\\|semicondensed\\|\\)") ; 3
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
412 (swidth "\\([^-]*\\)") ; 3
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
413 ; (adstyle "\\(\\*\\|sans\\|\\)") ; 4
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
414 (adstyle "[^-]*") ; 4
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
415 (pixelsize "[0-9]+")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
416 (pointsize "[0-9][0-9]+")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
417 (resx "[0-9][0-9]+")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
418 (resy "[0-9][0-9]+")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
419 (spacing "[cmp?*]")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
420 (avgwidth "[0-9]+")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
421 (registry "[^-]+")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
422 (encoding "[^-]+")
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
423 )
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
424 (setq x-font-regexp
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
425 (concat "\\`\\*?[-?*]"
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
426 foundry - family - weight\? - slant\? - swidth - adstyle -
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
427 pixelsize - pointsize - resx - resy - spacing - registry -
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
428 encoding "[-?*]\\*?\\'"
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
429 ))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
430 (setq x-font-regexp-head
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
431 (concat "\\`[-?*]" foundry - family - weight\? - slant\?
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
432 "\\([-*?]\\|\\'\\)"))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
433 (setq x-font-regexp-slant (concat - slant -))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
434 (setq x-font-regexp-weight (concat - weight -))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
435 nil)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
436
3071
68de05fb5751 * faces.el (set-face-font): Call x-resolve-font-name on the font
Jim Blandy <jimb@redhat.com>
parents: 3049
diff changeset
437 (defun x-resolve-font-name (pattern &optional face frame)
68de05fb5751 * faces.el (set-face-font): Call x-resolve-font-name on the font
Jim Blandy <jimb@redhat.com>
parents: 3049
diff changeset
438 "Return a font name matching PATTERN.
68de05fb5751 * faces.el (set-face-font): Call x-resolve-font-name on the font
Jim Blandy <jimb@redhat.com>
parents: 3049
diff changeset
439 All wildcards in PATTERN become substantiated.
3130
82c29bacb6b3 * faces.el (x-resolve-font-name): If PATTERN is nil, return the
Jim Blandy <jimb@redhat.com>
parents: 3071
diff changeset
440 If PATTERN is nil, return the name of the frame's base font, which never
82c29bacb6b3 * faces.el (x-resolve-font-name): If PATTERN is nil, return the
Jim Blandy <jimb@redhat.com>
parents: 3071
diff changeset
441 contains wildcards.
3071
68de05fb5751 * faces.el (set-face-font): Call x-resolve-font-name on the font
Jim Blandy <jimb@redhat.com>
parents: 3049
diff changeset
442 Given optional arguments FACE and FRAME, try to return a font which is
3130
82c29bacb6b3 * faces.el (x-resolve-font-name): If PATTERN is nil, return the
Jim Blandy <jimb@redhat.com>
parents: 3071
diff changeset
443 also the same size as FACE on FRAME."
3233
28b2df35c33e (x-resolve-font-name): Allow symbol as FACE arg.
Richard M. Stallman <rms@gnu.org>
parents: 3182
diff changeset
444 (or (symbolp face)
28b2df35c33e (x-resolve-font-name): Allow symbol as FACE arg.
Richard M. Stallman <rms@gnu.org>
parents: 3182
diff changeset
445 (setq face (face-name face)))
28b2df35c33e (x-resolve-font-name): Allow symbol as FACE arg.
Richard M. Stallman <rms@gnu.org>
parents: 3182
diff changeset
446 (and (eq frame t)
28b2df35c33e (x-resolve-font-name): Allow symbol as FACE arg.
Richard M. Stallman <rms@gnu.org>
parents: 3182
diff changeset
447 (setq frame nil))
3130
82c29bacb6b3 * faces.el (x-resolve-font-name): If PATTERN is nil, return the
Jim Blandy <jimb@redhat.com>
parents: 3071
diff changeset
448 (if pattern
5092
36508a7c0a3f (x-resolve-font-name): Undo previous change.
Richard M. Stallman <rms@gnu.org>
parents: 5081
diff changeset
449 ;; Note that x-list-fonts has code to handle a face with nil as its font.
36508a7c0a3f (x-resolve-font-name): Undo previous change.
Richard M. Stallman <rms@gnu.org>
parents: 5081
diff changeset
450 (let ((fonts (x-list-fonts pattern face frame)))
3130
82c29bacb6b3 * faces.el (x-resolve-font-name): If PATTERN is nil, return the
Jim Blandy <jimb@redhat.com>
parents: 3071
diff changeset
451 (or fonts
82c29bacb6b3 * faces.el (x-resolve-font-name): If PATTERN is nil, return the
Jim Blandy <jimb@redhat.com>
parents: 3071
diff changeset
452 (if face
3353
8cbd38886eef (x-resolve-font-name): Clean up error messages.
Richard M. Stallman <rms@gnu.org>
parents: 3298
diff changeset
453 (error "No fonts matching pattern are the same size as `%s'"
3298
0b96c67ca1c5 * faces.el (x-resolve-font-name): Give correct error message
Jim Blandy <jimb@redhat.com>
parents: 3297
diff changeset
454 face)
3353
8cbd38886eef (x-resolve-font-name): Clean up error messages.
Richard M. Stallman <rms@gnu.org>
parents: 3298
diff changeset
455 (error "No fonts match `%s'" pattern)))
3130
82c29bacb6b3 * faces.el (x-resolve-font-name): If PATTERN is nil, return the
Jim Blandy <jimb@redhat.com>
parents: 3071
diff changeset
456 (car fonts))
82c29bacb6b3 * faces.el (x-resolve-font-name): If PATTERN is nil, return the
Jim Blandy <jimb@redhat.com>
parents: 3071
diff changeset
457 (cdr (assq 'font (frame-parameters (selected-frame))))))
3071
68de05fb5751 * faces.el (set-face-font): Call x-resolve-font-name on the font
Jim Blandy <jimb@redhat.com>
parents: 3049
diff changeset
458
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
459 (defun x-frob-font-weight (font which)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
460 (if (or (string-match x-font-regexp font)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
461 (string-match x-font-regexp-head font)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
462 (string-match x-font-regexp-weight font))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
463 (concat (substring font 0 (match-beginning 1)) which
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
464 (substring font (match-end 1)))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
465 nil))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
466
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
467 (defun x-frob-font-slant (font which)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
468 (cond ((or (string-match x-font-regexp font)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
469 (string-match x-font-regexp-head font))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
470 (concat (substring font 0 (match-beginning 2)) which
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
471 (substring font (match-end 2))))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
472 ((string-match x-font-regexp-slant font)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
473 (concat (substring font 0 (match-beginning 1)) which
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
474 (substring font (match-end 1))))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
475 (t nil)))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
476
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
477
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
478 (defun x-make-font-bold (font)
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
479 "Given an X font specification, make a bold version of it.
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
480 If that can't be done, return nil."
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
481 (x-frob-font-weight font "bold"))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
482
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
483 (defun x-make-font-demibold (font)
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
484 "Given an X font specification, make a demibold version of it.
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
485 If that can't be done, return nil."
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
486 (x-frob-font-weight font "demibold"))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
487
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
488 (defun x-make-font-unbold (font)
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
489 "Given an X font specification, make a non-bold version of it.
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
490 If that can't be done, return nil."
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
491 (x-frob-font-weight font "medium"))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
492
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
493 (defun x-make-font-italic (font)
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
494 "Given an X font specification, make an italic version of it.
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
495 If that can't be done, return nil."
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
496 (x-frob-font-slant font "i"))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
497
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
498 (defun x-make-font-oblique (font) ; you say tomayto...
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
499 "Given an X font specification, make an oblique version of it.
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
500 If that can't be done, return nil."
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
501 (x-frob-font-slant font "o"))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
502
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
503 (defun x-make-font-unitalic (font)
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
504 "Given an X font specification, make a non-italic version of it.
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
505 If that can't be done, return nil."
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
506 (x-frob-font-slant font "r"))
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
507
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
508 ;;; non-X-specific interface
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
509
2714
bfe999b19082 * faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents: 2456
diff changeset
510 (defun make-face-bold (face &optional frame noerror)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
511 "Make the font of the given face be bold, if possible.
2714
bfe999b19082 * faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents: 2456
diff changeset
512 If NOERROR is non-nil, return nil on failure."
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
513 (interactive (list (read-face-name "Make which face bold: ")))
5199
b8b8063551e1 (make-face-unitalic, make-face-unbold, make-face-bold)
Richard M. Stallman <rms@gnu.org>
parents: 5092
diff changeset
514 (if (and (eq frame t) (listp (face-font face t)))
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
515 (set-face-font face (if (memq 'italic (face-font face t))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
516 '(bold italic) '(bold))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
517 t)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
518 (let ((ofont (face-font face frame))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
519 font f2)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
520 (if (null frame)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
521 (let ((frames (frame-list)))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
522 ;; Make this face bold in global-face-data.
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
523 (make-face-bold face t noerror)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
524 ;; Make this face bold in each frame.
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
525 (while frames
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
526 (make-face-bold face (car frames) noerror)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
527 (setq frames (cdr frames))))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
528 (setq face (internal-get-face face frame))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
529 (setq font (or (face-font face frame)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
530 (face-font face t)))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
531 (if (listp font)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
532 (setq font nil))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
533 (setq font (or font
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
534 (face-font 'default frame)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
535 (cdr (assq 'font (frame-parameters frame)))))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
536 (make-face-bold-internal face frame))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
537 (or (not (equal ofont (face-font face)))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
538 (and (not noerror)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
539 (error "No bold version of %S" font))))))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
540
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
541 (defun make-face-bold-internal (face frame)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
542 (or (and (setq f2 (x-make-font-bold font))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
543 (internal-try-face-font face f2 frame))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
544 (and (setq f2 (x-make-font-demibold font))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
545 (internal-try-face-font face f2 frame))))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
546
2714
bfe999b19082 * faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents: 2456
diff changeset
547 (defun make-face-italic (face &optional frame noerror)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
548 "Make the font of the given face be italic, if possible.
2714
bfe999b19082 * faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents: 2456
diff changeset
549 If NOERROR is non-nil, return nil on failure."
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
550 (interactive (list (read-face-name "Make which face italic: ")))
5199
b8b8063551e1 (make-face-unitalic, make-face-unbold, make-face-bold)
Richard M. Stallman <rms@gnu.org>
parents: 5092
diff changeset
551 (if (and (eq frame t) (listp (face-font face t)))
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
552 (set-face-font face (if (memq 'bold (face-font face t))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
553 '(bold italic) '(italic))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
554 t)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
555 (let ((ofont (face-font face frame))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
556 font f2)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
557 (if (null frame)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
558 (let ((frames (frame-list)))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
559 ;; Make this face italic in global-face-data.
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
560 (make-face-italic face t noerror)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
561 ;; Make this face italic in each frame.
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
562 (while frames
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
563 (make-face-italic face (car frames) noerror)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
564 (setq frames (cdr frames))))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
565 (setq face (internal-get-face face frame))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
566 (setq font (or (face-font face frame)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
567 (face-font face t)))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
568 (if (listp font)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
569 (setq font nil))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
570 (setq font (or font
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
571 (face-font 'default frame)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
572 (cdr (assq 'font (frame-parameters frame)))))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
573 (make-face-italic-internal face frame))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
574 (or (not (equal ofont (face-font face)))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
575 (and (not noerror)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
576 (error "No italic version of %S" font))))))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
577
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
578 (defun make-face-italic-internal (face frame)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
579 (or (and (setq f2 (x-make-font-italic font))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
580 (internal-try-face-font face f2 frame))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
581 (and (setq f2 (x-make-font-oblique font))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
582 (internal-try-face-font face f2 frame))))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
583
2714
bfe999b19082 * faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents: 2456
diff changeset
584 (defun make-face-bold-italic (face &optional frame noerror)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
585 "Make the font of the given face be bold and italic, if possible.
2714
bfe999b19082 * faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents: 2456
diff changeset
586 If NOERROR is non-nil, return nil on failure."
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
587 (interactive (list (read-face-name "Make which face bold-italic: ")))
5199
b8b8063551e1 (make-face-unitalic, make-face-unbold, make-face-bold)
Richard M. Stallman <rms@gnu.org>
parents: 5092
diff changeset
588 (if (and (eq frame t) (listp (face-font face t)))
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
589 (set-face-font face '(bold italic) t)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
590 (let ((ofont (face-font face frame))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
591 font)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
592 (if (null frame)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
593 (let ((frames (frame-list)))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
594 ;; Make this face bold-italic in global-face-data.
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
595 (make-face-bold-italic face t noerror)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
596 ;; Make this face bold in each frame.
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
597 (while frames
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
598 (make-face-bold-italic face (car frames) noerror)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
599 (setq frames (cdr frames))))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
600 (setq face (internal-get-face face frame))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
601 (setq font (or (face-font face frame)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
602 (face-font face t)))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
603 (if (listp font)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
604 (setq font nil))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
605 (setq font (or font
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
606 (face-font 'default frame)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
607 (cdr (assq 'font (frame-parameters frame)))))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
608 (make-face-bold-italic-internal face frame))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
609 (or (not (equal ofont (face-font face)))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
610 (and (not noerror)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
611 (error "No bold italic version of %S" font))))))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
612
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
613 (defun make-face-bold-italic-internal (face frame)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
614 (let (f2 f3)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
615 (or (and (setq f2 (x-make-font-italic font))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
616 (not (equal font f2))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
617 (setq f3 (x-make-font-bold f2))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
618 (not (equal f2 f3))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
619 (internal-try-face-font face f3 frame))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
620 (and (setq f2 (x-make-font-oblique font))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
621 (not (equal font f2))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
622 (setq f3 (x-make-font-bold f2))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
623 (not (equal f2 f3))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
624 (internal-try-face-font face f3 frame))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
625 (and (setq f2 (x-make-font-italic font))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
626 (not (equal font f2))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
627 (setq f3 (x-make-font-demibold f2))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
628 (not (equal f2 f3))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
629 (internal-try-face-font face f3 frame))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
630 (and (setq f2 (x-make-font-oblique font))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
631 (not (equal font f2))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
632 (setq f3 (x-make-font-demibold f2))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
633 (not (equal f2 f3))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
634 (internal-try-face-font face f3 frame)))))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
635
2714
bfe999b19082 * faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents: 2456
diff changeset
636 (defun make-face-unbold (face &optional frame noerror)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
637 "Make the font of the given face be non-bold, if possible.
2714
bfe999b19082 * faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents: 2456
diff changeset
638 If NOERROR is non-nil, return nil on failure."
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
639 (interactive (list (read-face-name "Make which face non-bold: ")))
5199
b8b8063551e1 (make-face-unitalic, make-face-unbold, make-face-bold)
Richard M. Stallman <rms@gnu.org>
parents: 5092
diff changeset
640 (if (and (eq frame t) (listp (face-font face t)))
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
641 (set-face-font face (if (memq 'italic (face-font face t))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
642 '(italic) nil)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
643 t)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
644 (let ((ofont (face-font face frame))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
645 font font1)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
646 (if (null frame)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
647 (let ((frames (frame-list)))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
648 ;; Make this face unbold in global-face-data.
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
649 (make-face-unbold face t noerror)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
650 ;; Make this face unbold in each frame.
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
651 (while frames
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
652 (make-face-unbold face (car frames) noerror)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
653 (setq frames (cdr frames))))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
654 (setq face (internal-get-face face frame))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
655 (setq font1 (or (face-font face frame)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
656 (face-font face t)))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
657 (if (listp font1)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
658 (setq font1 nil))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
659 (setq font1 (or font1
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
660 (face-font 'default frame)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
661 (cdr (assq 'font (frame-parameters frame)))))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
662 (setq font (x-make-font-unbold font1))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
663 (if font (internal-try-face-font face font frame)))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
664 (or (not (equal ofont (face-font face)))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
665 (and (not noerror)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
666 (error "No unbold version of %S" font1))))))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
667
2714
bfe999b19082 * faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents: 2456
diff changeset
668 (defun make-face-unitalic (face &optional frame noerror)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
669 "Make the font of the given face be non-italic, if possible.
2714
bfe999b19082 * faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents: 2456
diff changeset
670 If NOERROR is non-nil, return nil on failure."
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
671 (interactive (list (read-face-name "Make which face non-italic: ")))
5199
b8b8063551e1 (make-face-unitalic, make-face-unbold, make-face-bold)
Richard M. Stallman <rms@gnu.org>
parents: 5092
diff changeset
672 (if (and (eq frame t) (listp (face-font face t)))
4439
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
673 (set-face-font face (if (memq 'bold (face-font face t))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
674 '(bold) nil)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
675 t)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
676 (let ((ofont (face-font face frame))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
677 font font1)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
678 (if (null frame)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
679 (let ((frames (frame-list)))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
680 ;; Make this face unitalic in global-face-data.
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
681 (make-face-unitalic face t noerror)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
682 ;; Make this face unitalic in each frame.
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
683 (while frames
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
684 (make-face-unitalic face (car frames) noerror)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
685 (setq frames (cdr frames))))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
686 (setq face (internal-get-face face frame))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
687 (setq font1 (or (face-font face frame)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
688 (face-font face t)))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
689 (if (listp font1)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
690 (setq font1 nil))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
691 (setq font1 (or font1
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
692 (face-font 'default frame)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
693 (cdr (assq 'font (frame-parameters frame)))))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
694 (setq font (x-make-font-unitalic font1))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
695 (if font (internal-try-face-font face font frame)))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
696 (or (not (equal ofont (face-font face)))
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
697 (and (not noerror)
e7ab04f23df5 Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents: 4122
diff changeset
698 (error "No unitalic version of %S" font1))))))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
699
4083
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
700 (defvar list-faces-sample-text
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
701 "abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ"
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
702 "*Text string to display as the sample text for `list-faces-display'.")
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
703
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
704 ;; The name list-faces would be more consistent, but let's avoid a conflict
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
705 ;; with Lucid, which uses that name differently.
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
706 (defun list-faces-display ()
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
707 "List all faces, using the same sample text in each.
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
708 The sample text is a string that comes from the variable
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
709 `list-faces-sample-text'.
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
710
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
711 It is possible to give a particular face name different appearances in
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
712 different frames. This command shows the appearance in the
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
713 selected frame."
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
714 (interactive)
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
715 (let ((faces (sort (face-list) (function string-lessp)))
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
716 (face nil)
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
717 (frame (selected-frame))
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
718 disp-frame window)
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
719 (with-output-to-temp-buffer "*Faces*"
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
720 (save-excursion
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
721 (set-buffer standard-output)
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
722 (setq truncate-lines t)
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
723 (while faces
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
724 (setq face (car faces))
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
725 (setq faces (cdr faces))
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
726 (insert (format "%25s " (symbol-name face)))
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
727 (let ((beg (point)))
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
728 (insert list-faces-sample-text)
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
729 (insert "\n")
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
730 (put-text-property beg (1- (point)) 'face face)))
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
731 (goto-char (point-min))))
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
732 ;; If the *Faces* buffer appears in a different frame,
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
733 ;; copy all the face definitions from FRAME,
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
734 ;; so that the display will reflect the frame that was selected.
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
735 (setq window (get-buffer-window (get-buffer "*Faces*") t))
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
736 (setq disp-frame (if window (window-frame window)
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
737 (car (frame-list))))
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
738 (or (eq frame disp-frame)
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
739 (let ((faces (face-list)))
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
740 (while faces
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
741 (copy-face (car faces) (car faces) frame disp-frame)
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
742 (setq faces (cdr faces)))))))
465c6787d6dd (copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents: 3969
diff changeset
743
5929
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
744 ;;; Make the standard faces.
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
745 ;;; The C code knows the default and modeline faces as faces 0 and 1,
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
746 ;;; so they must be the first two faces made.
2764
17c322204ce3 (face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2744
diff changeset
747 (defun face-initialize ()
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
748 (make-face 'default)
2826
9c22af6d7885 (face-initialize): Do make the modeline face.
Richard M. Stallman <rms@gnu.org>
parents: 2807
diff changeset
749 (make-face 'modeline)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
750 (make-face 'highlight)
5929
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
751
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
752 ;; These aren't really special in any way, but they're nice to have around.
5929
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
753
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
754 (make-face 'bold)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
755 (make-face 'italic)
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
756 (make-face 'bold-italic)
2807
9e8635dafd40 Rename `primary-selection' to `region'.
Richard M. Stallman <rms@gnu.org>
parents: 2800
diff changeset
757 (make-face 'region)
2764
17c322204ce3 (face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2744
diff changeset
758 (make-face 'secondary-selection)
3911
06dbadd0e4a7 (face-initialize): Create `underline' face.
Richard M. Stallman <rms@gnu.org>
parents: 3910
diff changeset
759 (make-face 'underline)
2764
17c322204ce3 (face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2744
diff changeset
760
2807
9e8635dafd40 Rename `primary-selection' to `region'.
Richard M. Stallman <rms@gnu.org>
parents: 2800
diff changeset
761 (setq region-face (face-id 'region))
2800
a7b260d27c2c (face-initialize): Don't create the `modeline' face.
Richard M. Stallman <rms@gnu.org>
parents: 2764
diff changeset
762
5929
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
763 ;; Specify the global properties of these faces
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
764 ;; so they will come out right on new frames.
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
765
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
766 (make-face-bold 'bold t)
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
767 (make-face-italic 'italic t)
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
768 (make-face-bold-italic 'bold-italic t)
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
769
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
770 (set-face-background 'highlight '("darkseagreen2" "green" t) t)
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
771 (set-face-background 'region '("gray" t) t)
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
772 (set-face-background 'secondary-selection '("paleturquoise" "green" t) t)
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
773 (set-face-background 'modeline '(t) t)
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
774 (set-face-underline-p 'underline t t)
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
775
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
776 ;; Set up the faces of all existing X Window frames
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
777 ;; from those global properties, unless already set in a given frame.
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
778
2764
17c322204ce3 (face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2744
diff changeset
779 (let ((frames (frame-list)))
17c322204ce3 (face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2744
diff changeset
780 (while frames
17c322204ce3 (face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2744
diff changeset
781 (if (eq (framep (car frames)) 'x)
5929
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
782 (let ((frame (car frames))
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
783 (rest global-face-data))
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
784 (while rest
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
785 (let ((face (car (car rest))))
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
786 (or (face-differs-from-default-p face)
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
787 (face-fill-in face (cdr (car rest)) frame)))
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
788 (setq rest (cdr rest)))))
2764
17c322204ce3 (face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2744
diff changeset
789 (setq frames (cdr frames)))))
17c322204ce3 (face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2744
diff changeset
790
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
791
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
792 ;; Like x-create-frame but also set up the faces.
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
793
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
794 (defun x-create-frame-with-faces (&optional parameters)
2764
17c322204ce3 (face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2744
diff changeset
795 (if (null global-face-data)
17c322204ce3 (face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2744
diff changeset
796 (x-create-frame parameters)
6871
54d45937d243 (x-create-frame-with-faces): Create frame invisible,
Richard M. Stallman <rms@gnu.org>
parents: 6145
diff changeset
797 (let* ((visibility-spec (assq 'visibility parameters))
54d45937d243 (x-create-frame-with-faces): Create frame invisible,
Richard M. Stallman <rms@gnu.org>
parents: 6145
diff changeset
798 (frame (x-create-frame (cons '(visibility . nil) parameters)))
2764
17c322204ce3 (face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2744
diff changeset
799 (faces (copy-alist global-face-data))
2826
9c22af6d7885 (face-initialize): Do make the modeline face.
Richard M. Stallman <rms@gnu.org>
parents: 2807
diff changeset
800 (rest faces))
2764
17c322204ce3 (face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2744
diff changeset
801 (set-frame-face-alist frame faces)
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
802
3049
314cb8d34dcd (x-create-frame-with-faces): Handle `reverse' as parameter.
Richard M. Stallman <rms@gnu.org>
parents: 3001
diff changeset
803 (if (cdr (or (assq 'reverse parameters)
3182
d38749acdf27 (x-create-frame-with-faces): Handle reverseVideo resource.
Richard M. Stallman <rms@gnu.org>
parents: 3130
diff changeset
804 (assq 'reverse default-frame-alist)
d38749acdf27 (x-create-frame-with-faces): Handle reverseVideo resource.
Richard M. Stallman <rms@gnu.org>
parents: 3130
diff changeset
805 (cons nil
4624
62564c5e2df7 (x-create-frame-with-faces): Check for `on' or `true'
Richard M. Stallman <rms@gnu.org>
parents: 4439
diff changeset
806 (member (x-get-resource "reverseVideo" "ReverseVideo")
62564c5e2df7 (x-create-frame-with-faces): Check for `on' or `true'
Richard M. Stallman <rms@gnu.org>
parents: 4439
diff changeset
807 '("on" "true")))))
3049
314cb8d34dcd (x-create-frame-with-faces): Handle `reverse' as parameter.
Richard M. Stallman <rms@gnu.org>
parents: 3001
diff changeset
808 (let ((params (frame-parameters frame)))
314cb8d34dcd (x-create-frame-with-faces): Handle `reverse' as parameter.
Richard M. Stallman <rms@gnu.org>
parents: 3001
diff changeset
809 (modify-frame-parameters
314cb8d34dcd (x-create-frame-with-faces): Handle `reverse' as parameter.
Richard M. Stallman <rms@gnu.org>
parents: 3001
diff changeset
810 frame
314cb8d34dcd (x-create-frame-with-faces): Handle `reverse' as parameter.
Richard M. Stallman <rms@gnu.org>
parents: 3001
diff changeset
811 (list (cons 'foreground-color (cdr (assq 'background-color params)))
314cb8d34dcd (x-create-frame-with-faces): Handle `reverse' as parameter.
Richard M. Stallman <rms@gnu.org>
parents: 3001
diff changeset
812 (cons 'background-color (cdr (assq 'foreground-color params)))
314cb8d34dcd (x-create-frame-with-faces): Handle `reverse' as parameter.
Richard M. Stallman <rms@gnu.org>
parents: 3001
diff changeset
813 (cons 'mouse-color (cdr (assq 'background-color params)))
314cb8d34dcd (x-create-frame-with-faces): Handle `reverse' as parameter.
Richard M. Stallman <rms@gnu.org>
parents: 3001
diff changeset
814 (cons 'cursor-color (cdr (assq 'background-color params)))
314cb8d34dcd (x-create-frame-with-faces): Handle `reverse' as parameter.
Richard M. Stallman <rms@gnu.org>
parents: 3001
diff changeset
815 (cons 'border-color (cdr (assq 'background-color params)))))))
314cb8d34dcd (x-create-frame-with-faces): Handle `reverse' as parameter.
Richard M. Stallman <rms@gnu.org>
parents: 3001
diff changeset
816
2764
17c322204ce3 (face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2744
diff changeset
817 ;; Copy the vectors that represent the faces.
17c322204ce3 (face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2744
diff changeset
818 ;; Also fill them in from X resources.
17c322204ce3 (face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2744
diff changeset
819 (while rest
5929
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
820 (let ((global (cdr (car rest))))
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
821 (setcdr (car rest) (vector 'face
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
822 (face-name (cdr (car rest)))
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
823 (face-id (cdr (car rest)))
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
824 nil nil nil nil nil))
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
825 (face-fill-in (car (car rest)) global frame))
2764
17c322204ce3 (face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2744
diff changeset
826 (make-face-x-resource-internal (cdr (car rest)) frame t)
17c322204ce3 (face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2744
diff changeset
827 (setq rest (cdr rest)))
6871
54d45937d243 (x-create-frame-with-faces): Create frame invisible,
Richard M. Stallman <rms@gnu.org>
parents: 6145
diff changeset
828 (if (null visibility-spec)
54d45937d243 (x-create-frame-with-faces): Create frame invisible,
Richard M. Stallman <rms@gnu.org>
parents: 6145
diff changeset
829 (make-frame-visible frame)
54d45937d243 (x-create-frame-with-faces): Create frame invisible,
Richard M. Stallman <rms@gnu.org>
parents: 6145
diff changeset
830 (modify-frame-parameters frame (list visibility-spec)))
5929
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
831 frame)))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
832
5929
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
833 ;; Fill in the face FACE from frame-independent face data DATA.
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
834 ;; DATA should be the non-frame-specific ("global") face vector
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
835 ;; for the face. FACE should be a face name or face object.
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
836 ;; FRAME is the frame to act on; it must be an actual frame, not nil or t.
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
837 (defun face-fill-in (face data frame)
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
838 (condition-case nil
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
839 (let ((foreground (face-foreground data))
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
840 (background (face-background data))
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
841 (font (face-font data)))
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
842 (set-face-underline-p face (face-underline-p data) frame)
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
843 (if foreground
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
844 (face-try-color-list 'set-face-foreground
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
845 face foreground frame))
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
846 (if background
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
847 (face-try-color-list 'set-face-background
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
848 face background frame))
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
849 (if (listp font)
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
850 (let ((bold (memq 'bold font))
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
851 (italic (memq 'italic font)))
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
852 (cond ((and bold italic)
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
853 (make-face-bold-italic face frame))
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
854 (bold
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
855 (make-face-bold face frame))
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
856 (italic
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
857 (make-face-italic face frame))))
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
858 (if font
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
859 (set-face-font face font frame))))
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
860 (error nil)))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
861
5929
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
862 ;; Use FUNCTION to store a color in FACE on FRAME.
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
863 ;; COLORS is either a single color or a list of colors.
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
864 ;; If it is a list, try the colors one by one until one of them
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
865 ;; succeeds. We signal an error only if all the colors failed.
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
866 ;; t as COLORS or as an element of COLORS means to invert the face.
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
867 ;; That can't fail, so any subsequent elements after the t are ignored.
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
868 (defun face-try-color-list (function face colors frame)
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
869 (if (stringp colors)
5955
459bb5807c0b (face-try-color-list): Don't rely on errors from using
Richard M. Stallman <rms@gnu.org>
parents: 5929
diff changeset
870 (if (or (and (not (x-display-color-p)) (not (string= colors "gray")))
459bb5807c0b (face-try-color-list): Don't rely on errors from using
Richard M. Stallman <rms@gnu.org>
parents: 5929
diff changeset
871 (= (x-display-planes) 1))
459bb5807c0b (face-try-color-list): Don't rely on errors from using
Richard M. Stallman <rms@gnu.org>
parents: 5929
diff changeset
872 nil
459bb5807c0b (face-try-color-list): Don't rely on errors from using
Richard M. Stallman <rms@gnu.org>
parents: 5929
diff changeset
873 (funcall function face colors frame))
5929
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
874 (if (eq colors t)
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
875 (invert-face face frame)
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
876 (let (done)
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
877 (while (and colors (not done))
5955
459bb5807c0b (face-try-color-list): Don't rely on errors from using
Richard M. Stallman <rms@gnu.org>
parents: 5929
diff changeset
878 (if (and (stringp (car colors))
459bb5807c0b (face-try-color-list): Don't rely on errors from using
Richard M. Stallman <rms@gnu.org>
parents: 5929
diff changeset
879 (or (and (not (x-display-color-p))
459bb5807c0b (face-try-color-list): Don't rely on errors from using
Richard M. Stallman <rms@gnu.org>
parents: 5929
diff changeset
880 (not (string= (car colors) "gray")))
459bb5807c0b (face-try-color-list): Don't rely on errors from using
Richard M. Stallman <rms@gnu.org>
parents: 5929
diff changeset
881 (= (x-display-planes) 1)))
459bb5807c0b (face-try-color-list): Don't rely on errors from using
Richard M. Stallman <rms@gnu.org>
parents: 5929
diff changeset
882 nil
459bb5807c0b (face-try-color-list): Don't rely on errors from using
Richard M. Stallman <rms@gnu.org>
parents: 5929
diff changeset
883 (if (cdr colors)
459bb5807c0b (face-try-color-list): Don't rely on errors from using
Richard M. Stallman <rms@gnu.org>
parents: 5929
diff changeset
884 ;; If there are more colors to try, catch errors
459bb5807c0b (face-try-color-list): Don't rely on errors from using
Richard M. Stallman <rms@gnu.org>
parents: 5929
diff changeset
885 ;; and set `done' if we succeed.
459bb5807c0b (face-try-color-list): Don't rely on errors from using
Richard M. Stallman <rms@gnu.org>
parents: 5929
diff changeset
886 (condition-case nil
459bb5807c0b (face-try-color-list): Don't rely on errors from using
Richard M. Stallman <rms@gnu.org>
parents: 5929
diff changeset
887 (progn
459bb5807c0b (face-try-color-list): Don't rely on errors from using
Richard M. Stallman <rms@gnu.org>
parents: 5929
diff changeset
888 (if (eq (car colors) t)
459bb5807c0b (face-try-color-list): Don't rely on errors from using
Richard M. Stallman <rms@gnu.org>
parents: 5929
diff changeset
889 (invert-face face frame)
459bb5807c0b (face-try-color-list): Don't rely on errors from using
Richard M. Stallman <rms@gnu.org>
parents: 5929
diff changeset
890 (funcall function face (car colors) frame))
459bb5807c0b (face-try-color-list): Don't rely on errors from using
Richard M. Stallman <rms@gnu.org>
parents: 5929
diff changeset
891 (setq done t))
459bb5807c0b (face-try-color-list): Don't rely on errors from using
Richard M. Stallman <rms@gnu.org>
parents: 5929
diff changeset
892 (error nil))
459bb5807c0b (face-try-color-list): Don't rely on errors from using
Richard M. Stallman <rms@gnu.org>
parents: 5929
diff changeset
893 ;; If this is the last color, let the error get out if it fails.
459bb5807c0b (face-try-color-list): Don't rely on errors from using
Richard M. Stallman <rms@gnu.org>
parents: 5929
diff changeset
894 ;; If it succeeds, we will exit anyway after this iteration.
459bb5807c0b (face-try-color-list): Don't rely on errors from using
Richard M. Stallman <rms@gnu.org>
parents: 5929
diff changeset
895 (if (eq (car colors) t)
459bb5807c0b (face-try-color-list): Don't rely on errors from using
Richard M. Stallman <rms@gnu.org>
parents: 5929
diff changeset
896 (invert-face face frame)
459bb5807c0b (face-try-color-list): Don't rely on errors from using
Richard M. Stallman <rms@gnu.org>
parents: 5929
diff changeset
897 (funcall function face (car colors) frame))))
5929
2538d44f96d4 (face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents: 5849
diff changeset
898 (setq colors (cdr colors)))))))
2764
17c322204ce3 (face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2744
diff changeset
899
17c322204ce3 (face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2744
diff changeset
900 ;; If we are already using x-window frames, initialize faces for them.
17c322204ce3 (face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2744
diff changeset
901 (if (eq (framep (selected-frame)) 'x)
17c322204ce3 (face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2744
diff changeset
902 (face-initialize))
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
903
2715
9caee9338229 * faces.el: Call internal-set-face-1, not internat-set-face-1.
Jim Blandy <jimb@redhat.com>
parents: 2714
diff changeset
904 (provide 'faces)
9caee9338229 * faces.el: Call internal-set-face-1, not internat-set-face-1.
Jim Blandy <jimb@redhat.com>
parents: 2714
diff changeset
905
2456
39a58fdf2dee Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
906 ;;; faces.el ends here