Mercurial > emacs
annotate lisp/faces.el @ 12755:7a567a79b03b
(HAVE_SOCKETS, NEED_NET_ERRNO_H): Defined.
(HAVE_TERMIOS): Defined.
(HAVE_TERMIO): Add undef.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 02 Aug 1995 18:41:00 +0000 |
parents | 968d38f57f3a |
children | d69a2d6d1ae9 |
rev | line source |
---|---|
2456 | 1 ;;; faces.el --- Lisp interface to the c "face" structure |
2 | |
11234 | 3 ;; Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Inc. |
2456 | 4 |
5 ;; This file is part of GNU Emacs. | |
6 | |
7 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
8 ;; it under the terms of the GNU General Public License as published by | |
9 ;; the Free Software Foundation; either version 2, or (at your option) | |
10 ;; any later version. | |
11 | |
12 ;; GNU Emacs is distributed in the hope that it will be useful, | |
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 ;; GNU General Public License for more details. | |
16 | |
17 ;; You should have received a copy of the GNU General Public License | |
18 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
19 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
20 | |
21 ;;; Commentary: | |
22 | |
23 ;; Mostly derived from Lucid. | |
24 | |
25 ;;; Code: | |
26 | |
10107
2af74ff52cd0
At compile time, discard any defsubr definitions
Richard M. Stallman <rms@gnu.org>
parents:
10105
diff
changeset
|
27 (eval-when-compile |
2af74ff52cd0
At compile time, discard any defsubr definitions
Richard M. Stallman <rms@gnu.org>
parents:
10105
diff
changeset
|
28 ;; These used to be defsubsts, now they're subrs. Avoid losing if we're |
2af74ff52cd0
At compile time, discard any defsubr definitions
Richard M. Stallman <rms@gnu.org>
parents:
10105
diff
changeset
|
29 ;; being compiled with an old Emacs that still has defsubrs in it. |
2af74ff52cd0
At compile time, discard any defsubr definitions
Richard M. Stallman <rms@gnu.org>
parents:
10105
diff
changeset
|
30 (put 'face-name 'byte-optimizer nil) |
2af74ff52cd0
At compile time, discard any defsubr definitions
Richard M. Stallman <rms@gnu.org>
parents:
10105
diff
changeset
|
31 (put 'face-id 'byte-optimizer nil) |
2af74ff52cd0
At compile time, discard any defsubr definitions
Richard M. Stallman <rms@gnu.org>
parents:
10105
diff
changeset
|
32 (put 'face-font 'byte-optimizer nil) |
2af74ff52cd0
At compile time, discard any defsubr definitions
Richard M. Stallman <rms@gnu.org>
parents:
10105
diff
changeset
|
33 (put 'face-foreground 'byte-optimizer nil) |
2af74ff52cd0
At compile time, discard any defsubr definitions
Richard M. Stallman <rms@gnu.org>
parents:
10105
diff
changeset
|
34 (put 'face-background 'byte-optimizer nil) |
2af74ff52cd0
At compile time, discard any defsubr definitions
Richard M. Stallman <rms@gnu.org>
parents:
10105
diff
changeset
|
35 (put 'face-stipple 'byte-optimizer nil) |
2af74ff52cd0
At compile time, discard any defsubr definitions
Richard M. Stallman <rms@gnu.org>
parents:
10105
diff
changeset
|
36 (put 'face-underline-p 'byte-optimizer nil) |
2af74ff52cd0
At compile time, discard any defsubr definitions
Richard M. Stallman <rms@gnu.org>
parents:
10105
diff
changeset
|
37 (put 'set-face-font 'byte-optimizer nil) |
2af74ff52cd0
At compile time, discard any defsubr definitions
Richard M. Stallman <rms@gnu.org>
parents:
10105
diff
changeset
|
38 (put 'set-face-foreground 'byte-optimizer nil) |
2af74ff52cd0
At compile time, discard any defsubr definitions
Richard M. Stallman <rms@gnu.org>
parents:
10105
diff
changeset
|
39 (put 'set-face-background 'byte-optimizer nil) |
11850
f9174d73e755
Put property on set-face-stipple, not set-stipple.
Karl Heuer <kwzh@gnu.org>
parents:
11464
diff
changeset
|
40 (put 'set-face-stipple 'byte-optimizer nil) |
10107
2af74ff52cd0
At compile time, discard any defsubr definitions
Richard M. Stallman <rms@gnu.org>
parents:
10105
diff
changeset
|
41 (put 'set-face-underline-p 'byte-optimizer nil)) |
2744
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
42 |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
43 ;;;; 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
|
44 |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
45 ;;; A face vector is a vector of the form: |
9569
943acba6d366
(set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9197
diff
changeset
|
46 ;;; [face NAME ID FONT FOREGROUND BACKGROUND STIPPLE UNDERLINE] |
2744
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
47 |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
48 ;;; Type checkers. |
2456 | 49 (defsubst internal-facep (x) |
50 (and (vectorp x) (= (length x) 8) (eq (aref x 0) 'face))) | |
51 | |
10584 | 52 (defun facep (x) |
53 "Return t if X is a face name or an internal face vector." | |
54 (and (or (internal-facep x) | |
55 (and (symbolp x) (assq x global-face-data))) | |
56 t)) | |
57 | |
2456 | 58 (defmacro internal-check-face (face) |
10584 | 59 (` (or (internal-facep (, face)) |
60 (signal 'wrong-type-argument (list 'internal-facep (, face)))))) | |
2456 | 61 |
2744
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
62 ;;; Accessors. |
10105
249d94c7e4f1
(face-name, face-id, face-foreground, face-background)
Richard M. Stallman <rms@gnu.org>
parents:
10022
diff
changeset
|
63 (defun face-name (face) |
2456 | 64 "Return the name of face FACE." |
65 (aref (internal-get-face face) 1)) | |
66 | |
10105
249d94c7e4f1
(face-name, face-id, face-foreground, face-background)
Richard M. Stallman <rms@gnu.org>
parents:
10022
diff
changeset
|
67 (defun face-id (face) |
2456 | 68 "Return the internal ID number of face FACE." |
69 (aref (internal-get-face face) 2)) | |
70 | |
10105
249d94c7e4f1
(face-name, face-id, face-foreground, face-background)
Richard M. Stallman <rms@gnu.org>
parents:
10022
diff
changeset
|
71 (defun face-font (face &optional frame) |
2456 | 72 "Return the font name of face FACE, or nil if it is unspecified. |
73 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
|
74 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
|
75 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
|
76 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
|
77 If FRAME is omitted or nil, use the selected frame." |
2456 | 78 (aref (internal-get-face face frame) 3)) |
79 | |
10105
249d94c7e4f1
(face-name, face-id, face-foreground, face-background)
Richard M. Stallman <rms@gnu.org>
parents:
10022
diff
changeset
|
80 (defun face-foreground (face &optional frame) |
2456 | 81 "Return the foreground color name of face FACE, or nil if unspecified. |
82 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
|
83 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
|
84 If FRAME is omitted or nil, use the selected frame." |
2456 | 85 (aref (internal-get-face face frame) 4)) |
86 | |
10105
249d94c7e4f1
(face-name, face-id, face-foreground, face-background)
Richard M. Stallman <rms@gnu.org>
parents:
10022
diff
changeset
|
87 (defun face-background (face &optional frame) |
2456 | 88 "Return the background color name of face FACE, or nil if unspecified. |
89 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
|
90 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
|
91 If FRAME is omitted or nil, use the selected frame." |
2456 | 92 (aref (internal-get-face face frame) 5)) |
93 | |
10105
249d94c7e4f1
(face-name, face-id, face-foreground, face-background)
Richard M. Stallman <rms@gnu.org>
parents:
10022
diff
changeset
|
94 (defun face-stipple (face &optional frame) |
9569
943acba6d366
(set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9197
diff
changeset
|
95 "Return the stipple pixmap name of face FACE, or nil if unspecified. |
943acba6d366
(set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9197
diff
changeset
|
96 If the optional argument FRAME is given, report on face FACE in that frame. |
943acba6d366
(set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9197
diff
changeset
|
97 If FRAME is t, report on the defaults for face FACE (for new frames). |
943acba6d366
(set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9197
diff
changeset
|
98 If FRAME is omitted or nil, use the selected frame." |
943acba6d366
(set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9197
diff
changeset
|
99 (aref (internal-get-face face frame) 6)) |
943acba6d366
(set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9197
diff
changeset
|
100 |
943acba6d366
(set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9197
diff
changeset
|
101 (defalias 'face-background-pixmap 'face-stipple) |
2456 | 102 |
10105
249d94c7e4f1
(face-name, face-id, face-foreground, face-background)
Richard M. Stallman <rms@gnu.org>
parents:
10022
diff
changeset
|
103 (defun face-underline-p (face &optional frame) |
2456 | 104 "Return t if face FACE is underlined. |
105 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
|
106 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
|
107 If FRAME is omitted or nil, use the selected frame." |
2456 | 108 (aref (internal-get-face face frame) 7)) |
109 | |
2744
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
110 |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
111 ;;; Mutators. |
2456 | 112 |
10105
249d94c7e4f1
(face-name, face-id, face-foreground, face-background)
Richard M. Stallman <rms@gnu.org>
parents:
10022
diff
changeset
|
113 (defun set-face-font (face font &optional frame) |
2456 | 114 "Change the font of face FACE to FONT (a string). |
115 If the optional FRAME argument is provided, change only | |
116 in that frame; otherwise change each frame." | |
117 (interactive (internal-face-interactive "font")) | |
10170
5fc240a3e4a0
(face-initialize): Test for framep not t or nil.
Richard M. Stallman <rms@gnu.org>
parents:
10107
diff
changeset
|
118 (if (stringp font) (setq font (x-resolve-font-name font 'default frame))) |
3130
82c29bacb6b3
* faces.el (x-resolve-font-name): If PATTERN is nil, return the
Jim Blandy <jimb@redhat.com>
parents:
3071
diff
changeset
|
119 (internal-set-face-1 face 'font font 3 frame)) |
2456 | 120 |
10105
249d94c7e4f1
(face-name, face-id, face-foreground, face-background)
Richard M. Stallman <rms@gnu.org>
parents:
10022
diff
changeset
|
121 (defun set-face-foreground (face color &optional frame) |
2456 | 122 "Change the foreground color of face FACE to COLOR (a string). |
123 If the optional FRAME argument is provided, change only | |
124 in that frame; otherwise change each frame." | |
125 (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
|
126 (internal-set-face-1 face 'foreground color 4 frame)) |
2456 | 127 |
12562
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
128 (defvar face-default-stipple "gray3" |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
129 "Default stipple pattern used on monochrome displays. |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
130 This stipple pattern is used on monochrome displays |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
131 instead of shades of gray for a face background color. |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
132 See `set-face-stipple' for possible values for this variable.") |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
133 |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
134 (defun face-color-gray-p (color &optional frame) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
135 "Return t if COLOR is a shade of gray (or white or black). |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
136 FRAME specifies the frame and thus the display for interpreting COLOR." |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
137 (let* ((values (x-color-values color frame)) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
138 (r (nth 0 values)) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
139 (g (nth 1 values)) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
140 (b (nth 2 values))) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
141 (and (< (abs (- r g)) (/ (max 1 (abs r) (abs g)) 20)) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
142 (< (abs (- g b)) (/ (max 1 (abs g) (abs b)) 20)) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
143 (< (abs (- b r)) (/ (max 1 (abs b) (abs r)) 20))))) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
144 |
10105
249d94c7e4f1
(face-name, face-id, face-foreground, face-background)
Richard M. Stallman <rms@gnu.org>
parents:
10022
diff
changeset
|
145 (defun set-face-background (face color &optional frame) |
2456 | 146 "Change the background color of face FACE to COLOR (a string). |
147 If the optional FRAME argument is provided, change only | |
148 in that frame; otherwise change each frame." | |
149 (interactive (internal-face-interactive "background")) | |
9665
36bdda3a1dc9
(set-face-background): Set either stipple or color,
Richard M. Stallman <rms@gnu.org>
parents:
9661
diff
changeset
|
150 ;; For a specific frame, use gray stipple instead of gray color |
36bdda3a1dc9
(set-face-background): Set either stipple or color,
Richard M. Stallman <rms@gnu.org>
parents:
9661
diff
changeset
|
151 ;; if the display does not support a gray color. |
12725
968d38f57f3a
(set-face-background): Don't treat nil as a color.
Richard M. Stallman <rms@gnu.org>
parents:
12690
diff
changeset
|
152 (if (and frame (not (eq frame t)) color |
12581
8e4a75fa4b5b
(x-create-frame-with-faces):
Richard M. Stallman <rms@gnu.org>
parents:
12562
diff
changeset
|
153 (not (face-color-supported-p frame color t))) |
12562
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
154 (set-face-stipple face face-default-stipple frame) |
11464
4921121fbdc0
(set-face-background): Handle FRAME = nil directly
Richard M. Stallman <rms@gnu.org>
parents:
11234
diff
changeset
|
155 (if (null frame) |
4921121fbdc0
(set-face-background): Handle FRAME = nil directly
Richard M. Stallman <rms@gnu.org>
parents:
11234
diff
changeset
|
156 (let ((frames (frame-list))) |
4921121fbdc0
(set-face-background): Handle FRAME = nil directly
Richard M. Stallman <rms@gnu.org>
parents:
11234
diff
changeset
|
157 (while frames |
4921121fbdc0
(set-face-background): Handle FRAME = nil directly
Richard M. Stallman <rms@gnu.org>
parents:
11234
diff
changeset
|
158 (set-face-background (face-name face) color (car frames)) |
4921121fbdc0
(set-face-background): Handle FRAME = nil directly
Richard M. Stallman <rms@gnu.org>
parents:
11234
diff
changeset
|
159 (setq frames (cdr frames))) |
4921121fbdc0
(set-face-background): Handle FRAME = nil directly
Richard M. Stallman <rms@gnu.org>
parents:
11234
diff
changeset
|
160 (set-face-background face color t) |
4921121fbdc0
(set-face-background): Handle FRAME = nil directly
Richard M. Stallman <rms@gnu.org>
parents:
11234
diff
changeset
|
161 color) |
4921121fbdc0
(set-face-background): Handle FRAME = nil directly
Richard M. Stallman <rms@gnu.org>
parents:
11234
diff
changeset
|
162 (internal-set-face-1 face 'background color 5 frame)))) |
2456 | 163 |
12562
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
164 (defun set-face-stipple (face pixmap &optional frame) |
9569
943acba6d366
(set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9197
diff
changeset
|
165 "Change the stipple pixmap of face FACE to PIXMAP. |
943acba6d366
(set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9197
diff
changeset
|
166 PIXMAP should be a string, the name of a file of pixmap data. |
943acba6d366
(set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9197
diff
changeset
|
167 The directories listed in the `x-bitmap-file-path' variable are searched. |
2456 | 168 |
9569
943acba6d366
(set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9197
diff
changeset
|
169 Alternatively, PIXMAP may be a list of the form (WIDTH HEIGHT DATA) |
943acba6d366
(set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9197
diff
changeset
|
170 where WIDTH and HEIGHT are the size in pixels, |
943acba6d366
(set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9197
diff
changeset
|
171 and DATA is a string, containing the raw bits of the bitmap. |
2456 | 172 |
9569
943acba6d366
(set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9197
diff
changeset
|
173 If the optional FRAME argument is provided, change only |
943acba6d366
(set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9197
diff
changeset
|
174 in that frame; otherwise change each frame." |
943acba6d366
(set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9197
diff
changeset
|
175 (interactive (internal-face-interactive "stipple")) |
12562
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
176 (internal-set-face-1 face 'background-pixmap pixmap 6 frame)) |
9569
943acba6d366
(set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9197
diff
changeset
|
177 |
943acba6d366
(set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9197
diff
changeset
|
178 (defalias 'set-face-background-pixmap 'set-face-stipple) |
2456 | 179 |
10105
249d94c7e4f1
(face-name, face-id, face-foreground, face-background)
Richard M. Stallman <rms@gnu.org>
parents:
10022
diff
changeset
|
180 (defun set-face-underline-p (face underline-p &optional frame) |
2456 | 181 "Specify whether face FACE is underlined. (Yes if UNDERLINE-P is non-nil.) |
182 If the optional FRAME argument is provided, change only | |
183 in that frame; otherwise change each frame." | |
184 (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
|
185 (internal-set-face-1 face 'underline underline-p 7 frame)) |
9197
3fe469325a8b
(modify-face): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8999
diff
changeset
|
186 |
11153 | 187 (defun modify-face-read-string (face default name alist) |
11152
eb26f12a8be6
(modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents:
10598
diff
changeset
|
188 (let ((value |
eb26f12a8be6
(modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents:
10598
diff
changeset
|
189 (completing-read |
eb26f12a8be6
(modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents:
10598
diff
changeset
|
190 (if default |
eb26f12a8be6
(modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents:
10598
diff
changeset
|
191 (format "Set face %s %s (default %s): " |
eb26f12a8be6
(modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents:
10598
diff
changeset
|
192 face name (downcase default)) |
eb26f12a8be6
(modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents:
10598
diff
changeset
|
193 (format "Set face %s %s: " face name)) |
eb26f12a8be6
(modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents:
10598
diff
changeset
|
194 alist))) |
eb26f12a8be6
(modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents:
10598
diff
changeset
|
195 (cond ((equal value "none") |
eb26f12a8be6
(modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents:
10598
diff
changeset
|
196 nil) |
eb26f12a8be6
(modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents:
10598
diff
changeset
|
197 ((equal value "") |
eb26f12a8be6
(modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents:
10598
diff
changeset
|
198 default) |
eb26f12a8be6
(modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents:
10598
diff
changeset
|
199 (t value)))) |
eb26f12a8be6
(modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents:
10598
diff
changeset
|
200 |
eb26f12a8be6
(modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents:
10598
diff
changeset
|
201 (defun modify-face (face foreground background stipple |
eb26f12a8be6
(modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents:
10598
diff
changeset
|
202 bold-p italic-p underline-p) |
9197
3fe469325a8b
(modify-face): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8999
diff
changeset
|
203 "Change the display attributes for face FACE. |
11152
eb26f12a8be6
(modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents:
10598
diff
changeset
|
204 FOREGROUND and BACKGROUND should be color strings or nil. |
eb26f12a8be6
(modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents:
10598
diff
changeset
|
205 STIPPLE should be a stipple pattern name or nil. |
9197
3fe469325a8b
(modify-face): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8999
diff
changeset
|
206 BOLD-P, ITALIC-P, and UNDERLINE-P specify whether the face should be set bold, |
3fe469325a8b
(modify-face): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8999
diff
changeset
|
207 in italic, and underlined, respectively. (Yes if non-nil.) |
3fe469325a8b
(modify-face): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8999
diff
changeset
|
208 If called interactively, prompts for a face and face attributes." |
3fe469325a8b
(modify-face): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8999
diff
changeset
|
209 (interactive |
3fe469325a8b
(modify-face): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8999
diff
changeset
|
210 (let* ((completion-ignore-case t) |
11152
eb26f12a8be6
(modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents:
10598
diff
changeset
|
211 (face (symbol-name (read-face-name "Modify face: "))) |
eb26f12a8be6
(modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents:
10598
diff
changeset
|
212 (colors (mapcar 'list x-colors)) |
eb26f12a8be6
(modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents:
10598
diff
changeset
|
213 (stipples (mapcar 'list |
eb26f12a8be6
(modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents:
10598
diff
changeset
|
214 (apply 'nconc |
eb26f12a8be6
(modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents:
10598
diff
changeset
|
215 (mapcar 'directory-files |
eb26f12a8be6
(modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents:
10598
diff
changeset
|
216 x-bitmap-file-path)))) |
11153 | 217 (foreground (modify-face-read-string |
218 face (face-foreground (intern face)) | |
219 "foreground" colors)) | |
220 (background (modify-face-read-string | |
221 face (face-background (intern face)) | |
222 "background" colors)) | |
223 (stipple (modify-face-read-string | |
224 face (face-stipple (intern face)) | |
225 "stipple" stipples)) | |
11152
eb26f12a8be6
(modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents:
10598
diff
changeset
|
226 (bold-p (y-or-n-p (concat "Set face " face " bold "))) |
eb26f12a8be6
(modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents:
10598
diff
changeset
|
227 (italic-p (y-or-n-p (concat "Set face " face " italic "))) |
eb26f12a8be6
(modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents:
10598
diff
changeset
|
228 (underline-p (y-or-n-p (concat "Set face " face " underline ")))) |
9197
3fe469325a8b
(modify-face): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8999
diff
changeset
|
229 (message "Face %s: %s" face |
3fe469325a8b
(modify-face): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8999
diff
changeset
|
230 (mapconcat 'identity |
3fe469325a8b
(modify-face): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8999
diff
changeset
|
231 (delq nil |
3fe469325a8b
(modify-face): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8999
diff
changeset
|
232 (list (and foreground (concat (downcase foreground) " foreground")) |
3fe469325a8b
(modify-face): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8999
diff
changeset
|
233 (and background (concat (downcase background) " background")) |
11152
eb26f12a8be6
(modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents:
10598
diff
changeset
|
234 (and stipple (concat (downcase stipple) " stipple")) |
9197
3fe469325a8b
(modify-face): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8999
diff
changeset
|
235 (and bold-p "bold") (and italic-p "italic") |
3fe469325a8b
(modify-face): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8999
diff
changeset
|
236 (and underline-p "underline"))) ", ")) |
11152
eb26f12a8be6
(modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents:
10598
diff
changeset
|
237 (list (intern face) foreground background stipple |
eb26f12a8be6
(modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents:
10598
diff
changeset
|
238 bold-p italic-p underline-p))) |
9197
3fe469325a8b
(modify-face): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8999
diff
changeset
|
239 (condition-case nil (set-face-foreground face foreground) (error nil)) |
3fe469325a8b
(modify-face): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8999
diff
changeset
|
240 (condition-case nil (set-face-background face background) (error nil)) |
11152
eb26f12a8be6
(modify-face): Handle stipple. Handle defaulting properly.
Richard M. Stallman <rms@gnu.org>
parents:
10598
diff
changeset
|
241 (condition-case nil (set-face-stipple face stipple) (error nil)) |
9197
3fe469325a8b
(modify-face): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8999
diff
changeset
|
242 (funcall (if bold-p 'make-face-bold 'make-face-unbold) face nil t) |
3fe469325a8b
(modify-face): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8999
diff
changeset
|
243 (funcall (if italic-p 'make-face-italic 'make-face-unitalic) face nil t) |
3fe469325a8b
(modify-face): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8999
diff
changeset
|
244 (set-face-underline-p face underline-p) |
3fe469325a8b
(modify-face): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8999
diff
changeset
|
245 (and (interactive-p) (redraw-display))) |
2744
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
246 |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
247 ;;;; 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
|
248 |
3925
f286657c098e
* faces.el (global-face-data): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
3911
diff
changeset
|
249 (defvar global-face-data nil |
f286657c098e
* faces.el (global-face-data): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
3911
diff
changeset
|
250 "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
|
251 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
|
252 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
|
253 |
2744
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
254 (defun face-list () |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
255 "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
|
256 (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
|
257 |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
258 (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
|
259 "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
|
260 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
|
261 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
|
262 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
|
263 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
|
264 (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
|
265 (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
|
266 (if (symbolp name) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
267 (cdr (assq name |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
268 (if (eq frame t) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
269 global-face-data |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
270 (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
|
271 (internal-check-face name) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
272 name)) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
273 |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
274 (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
|
275 "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
|
276 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
|
277 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
|
278 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
|
279 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
|
280 (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
|
281 (internal-check-face name))) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
282 |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
283 |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
284 (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
|
285 (let ((inhibit-quit t)) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
286 (if (null frame) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
287 (let ((frames (frame-list))) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
288 (while frames |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
289 (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
|
290 (setq frames (cdr frames))) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
291 (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
|
292 index value) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
293 value) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
294 (or (eq frame t) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
295 (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
|
296 (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
|
297 |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
298 |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
299 (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
|
300 (let (face) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
301 (while (= (length face) 0) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
302 (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
|
303 (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
|
304 (face-list)) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
305 nil t))) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
306 (intern face))) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
307 |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
308 (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
|
309 (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
|
310 (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
|
311 (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
|
312 (default (if (fboundp fn) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
313 (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
|
314 (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
|
315 (value (if bool |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
316 (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
|
317 " be " bool "? ")) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
318 (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
|
319 default)))) |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
320 (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
|
321 |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
322 |
2456 | 323 |
324 (defun make-face (name) | |
325 "Define a new FACE on all frames. | |
326 You can modify the font, color, etc of this face with the set-face- functions. | |
327 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
|
328 (interactive "SMake face: ") |
2456 | 329 (or (internal-find-face name) |
330 (let ((face (make-vector 8 nil))) | |
331 (aset face 0 'face) | |
332 (aset face 1 name) | |
333 (let* ((frames (frame-list)) | |
334 (inhibit-quit t) | |
335 (id (internal-next-face-id))) | |
336 (make-face-internal id) | |
337 (aset face 2 id) | |
338 (while frames | |
339 (set-frame-face-alist (car frames) | |
340 (cons (cons name (copy-sequence face)) | |
341 (frame-face-alist (car frames)))) | |
342 (setq frames (cdr frames))) | |
343 (setq global-face-data (cons (cons name face) global-face-data))) | |
344 ;; when making a face after frames already exist | |
345 (if (eq window-system 'x) | |
346 (make-face-x-resource-internal face)) | |
9622
14e1032a7ae7
(make-face): Add new face to Face menu on creation. -- Bng
Boris Goldowsky <boris@gnu.org>
parents:
9572
diff
changeset
|
347 ;; add to menu |
14e1032a7ae7
(make-face): Add new face to Face menu on creation. -- Bng
Boris Goldowsky <boris@gnu.org>
parents:
9572
diff
changeset
|
348 (if (fboundp 'facemenu-add-new-face) |
14e1032a7ae7
(make-face): Add new face to Face menu on creation. -- Bng
Boris Goldowsky <boris@gnu.org>
parents:
9572
diff
changeset
|
349 (facemenu-add-new-face name)) |
8011
1bb462fc29fc
(make-face): Return the face name, not the vector.
Richard M. Stallman <rms@gnu.org>
parents:
8000
diff
changeset
|
350 face)) |
1bb462fc29fc
(make-face): Return the face name, not the vector.
Richard M. Stallman <rms@gnu.org>
parents:
8000
diff
changeset
|
351 name) |
2456 | 352 |
353 ;; Fill in a face by default based on X resources, for all existing frames. | |
354 ;; This has to be done when a new face is made. | |
355 (defun make-face-x-resource-internal (face &optional frame set-anyway) | |
356 (cond ((null frame) | |
357 (let ((frames (frame-list))) | |
358 (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
|
359 (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
|
360 (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
|
361 (car frames) set-anyway)) |
2456 | 362 (setq frames (cdr frames))))) |
363 (t | |
364 (setq face (internal-get-face (face-name face) frame)) | |
365 ;; | |
366 ;; These are things like "attributeForeground" instead of simply | |
367 ;; "foreground" because people tend to do things like "*foreground", | |
368 ;; which would cause all faces to be fully qualified, making faces | |
369 ;; inherit attributes in a non-useful way. So we've made them slightly | |
370 ;; less obvious to specify in order to make them work correctly in | |
371 ;; more random environments. | |
372 ;; | |
373 ;; I think these should be called "face.faceForeground" instead of | |
374 ;; "face.attributeForeground", but they're the way they are for | |
375 ;; hysterical reasons. | |
376 ;; | |
377 (let* ((name (symbol-name (face-name face))) | |
378 (fn (or (x-get-resource (concat name ".attributeFont") | |
379 "Face.AttributeFont") | |
380 (and set-anyway (face-font face)))) | |
381 (fg (or (x-get-resource (concat name ".attributeForeground") | |
382 "Face.AttributeForeground") | |
383 (and set-anyway (face-foreground face)))) | |
384 (bg (or (x-get-resource (concat name ".attributeBackground") | |
385 "Face.AttributeBackground") | |
386 (and set-anyway (face-background face)))) | |
9569
943acba6d366
(set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9197
diff
changeset
|
387 (bgp (or (x-get-resource (concat name ".attributeStipple") |
943acba6d366
(set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9197
diff
changeset
|
388 "Face.AttributeStipple") |
943acba6d366
(set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9197
diff
changeset
|
389 (x-get-resource (concat name ".attributeBackgroundPixmap") |
943acba6d366
(set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9197
diff
changeset
|
390 "Face.AttributeBackgroundPixmap") |
943acba6d366
(set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9197
diff
changeset
|
391 (and set-anyway (face-stipple face)))) |
8149
5e27997957db
(x-create-frame-with-faces): Ignore case in X resource.
Richard M. Stallman <rms@gnu.org>
parents:
8109
diff
changeset
|
392 (ulp (let ((resource (x-get-resource |
5e27997957db
(x-create-frame-with-faces): Ignore case in X resource.
Richard M. Stallman <rms@gnu.org>
parents:
8109
diff
changeset
|
393 (concat name ".attributeUnderline") |
5e27997957db
(x-create-frame-with-faces): Ignore case in X resource.
Richard M. Stallman <rms@gnu.org>
parents:
8109
diff
changeset
|
394 "Face.AttributeUnderline"))) |
5e27997957db
(x-create-frame-with-faces): Ignore case in X resource.
Richard M. Stallman <rms@gnu.org>
parents:
8109
diff
changeset
|
395 (if resource |
5e27997957db
(x-create-frame-with-faces): Ignore case in X resource.
Richard M. Stallman <rms@gnu.org>
parents:
8109
diff
changeset
|
396 (member (downcase resource) '("on" "true")) |
5e27997957db
(x-create-frame-with-faces): Ignore case in X resource.
Richard M. Stallman <rms@gnu.org>
parents:
8109
diff
changeset
|
397 (and set-anyway (face-underline-p face))))) |
2456 | 398 ) |
399 (if fn | |
400 (condition-case () | |
12460
1e12a802df2b
(describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12169
diff
changeset
|
401 (cond ((string= fn "italic") |
1e12a802df2b
(describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12169
diff
changeset
|
402 (make-face-italic face)) |
1e12a802df2b
(describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12169
diff
changeset
|
403 ((string= fn "bold") |
1e12a802df2b
(describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12169
diff
changeset
|
404 (make-face-bold face)) |
1e12a802df2b
(describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12169
diff
changeset
|
405 ((string= fn "bold-italic") |
1e12a802df2b
(describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12169
diff
changeset
|
406 (make-face-bold-italic face)) |
1e12a802df2b
(describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12169
diff
changeset
|
407 (t |
1e12a802df2b
(describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12169
diff
changeset
|
408 (set-face-font face fn frame))) |
1e12a802df2b
(describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12169
diff
changeset
|
409 (error |
1e12a802df2b
(describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12169
diff
changeset
|
410 (if (member fn '("italic" "bold" "bold-italic")) |
1e12a802df2b
(describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12169
diff
changeset
|
411 (message "no %s version found for face `%s'" fn name) |
1e12a802df2b
(describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12169
diff
changeset
|
412 (message "font `%s' not found for face `%s'" fn name))))) |
2456 | 413 (if fg |
414 (condition-case () | |
415 (set-face-foreground face fg frame) | |
416 (error (message "color `%s' not allocated for face `%s'" fg name)))) | |
417 (if bg | |
418 (condition-case () | |
419 (set-face-background face bg frame) | |
420 (error (message "color `%s' not allocated for face `%s'" bg name)))) | |
9569
943acba6d366
(set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9197
diff
changeset
|
421 (if bgp |
943acba6d366
(set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9197
diff
changeset
|
422 (condition-case () |
943acba6d366
(set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9197
diff
changeset
|
423 (set-face-stipple face bgp frame) |
943acba6d366
(set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9197
diff
changeset
|
424 (error (message "pixmap `%s' not found for face `%s'" bgp name)))) |
2456 | 425 (if (or ulp set-anyway) |
426 (set-face-underline-p face ulp frame)) | |
427 ))) | |
428 face) | |
429 | |
5849 | 430 (defun copy-face (old-face new-face &optional frame new-frame) |
431 "Define a face just like OLD-FACE, with name NEW-FACE. | |
432 If NEW-FACE already exists as a face, it is modified to be like OLD-FACE. | |
433 If it doesn't already exist, it is created. | |
434 | |
435 If the optional argument FRAME is given as a frame, | |
436 NEW-FACE is changed on FRAME only. | |
437 If FRAME is t, the frame-independent default specification for OLD-FACE | |
438 is copied to NEW-FACE. | |
439 If FRAME is nil, copying is done for the frame-independent defaults | |
440 and for each existing frame. | |
4083
465c6787d6dd
(copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents:
3969
diff
changeset
|
441 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
|
442 copy the information from face OLD-FACE on frame FRAME |
5849 | 443 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
|
444 (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
|
445 (let ((inhibit-quit t)) |
2456 | 446 (if (null frame) |
447 (let ((frames (frame-list))) | |
448 (while frames | |
5849 | 449 (copy-face old-face new-face (car frames)) |
2456 | 450 (setq frames (cdr frames))) |
5849 | 451 (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
|
452 (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
|
453 (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
|
454 (make-face new-face))) |
8515
3043fef029a7
(copy-face): Ignore errors in set-face-font.
Richard M. Stallman <rms@gnu.org>
parents:
8377
diff
changeset
|
455 (condition-case nil |
3043fef029a7
(copy-face): Ignore errors in set-face-font.
Richard M. Stallman <rms@gnu.org>
parents:
8377
diff
changeset
|
456 ;; A face that has a global symbolic font modifier such as `bold' |
3043fef029a7
(copy-face): Ignore errors in set-face-font.
Richard M. Stallman <rms@gnu.org>
parents:
8377
diff
changeset
|
457 ;; might legitimately get an error here. |
3043fef029a7
(copy-face): Ignore errors in set-face-font.
Richard M. Stallman <rms@gnu.org>
parents:
8377
diff
changeset
|
458 ;; Use the frame's default font in that case. |
3043fef029a7
(copy-face): Ignore errors in set-face-font.
Richard M. Stallman <rms@gnu.org>
parents:
8377
diff
changeset
|
459 (set-face-font new-face (face-font old-face frame) new-frame) |
3043fef029a7
(copy-face): Ignore errors in set-face-font.
Richard M. Stallman <rms@gnu.org>
parents:
8377
diff
changeset
|
460 (error |
3043fef029a7
(copy-face): Ignore errors in set-face-font.
Richard M. Stallman <rms@gnu.org>
parents:
8377
diff
changeset
|
461 (set-face-font new-face nil new-frame))) |
4083
465c6787d6dd
(copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents:
3969
diff
changeset
|
462 (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
|
463 (set-face-background new-face (face-background old-face frame) new-frame) |
9569
943acba6d366
(set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9197
diff
changeset
|
464 (set-face-stipple new-face |
943acba6d366
(set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9197
diff
changeset
|
465 (face-stipple old-face frame) |
943acba6d366
(set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9197
diff
changeset
|
466 new-frame) |
2456 | 467 (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
|
468 new-frame)) |
2456 | 469 new-face)) |
470 | |
471 (defun face-equal (face1 face2 &optional frame) | |
2906
ca9bf00d4b19
* xfaces.el (face-equal): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
2826
diff
changeset
|
472 "True if the faces FACE1 and FACE2 display in the same way." |
2456 | 473 (setq face1 (internal-get-face face1 frame) |
474 face2 (internal-get-face face2 frame)) | |
475 (and (equal (face-foreground face1 frame) (face-foreground face2 frame)) | |
476 (equal (face-background face1 frame) (face-background face2 frame)) | |
477 (equal (face-font face1 frame) (face-font face2 frame)) | |
8000
6d0a448be1ec
(face-equal): Do check the underline attribute.
Richard M. Stallman <rms@gnu.org>
parents:
7936
diff
changeset
|
478 (eq (face-underline-p face1 frame) (face-underline-p face2 frame)) |
9569
943acba6d366
(set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9197
diff
changeset
|
479 (equal (face-stipple face1 frame) |
943acba6d366
(set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9197
diff
changeset
|
480 (face-stipple face2 frame)))) |
2456 | 481 |
482 (defun face-differs-from-default-p (face &optional frame) | |
483 "True if face FACE displays differently from the default face, on FRAME. | |
484 A face is considered to be ``the same'' as the default face if it is | |
485 actually specified in the same way (equivalent fonts, etc) or if it is | |
486 fully unspecified, and thus inherits the attributes of any face it | |
10379
f9d713e8c77c
(face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10375
diff
changeset
|
487 is displayed on top of. |
f9d713e8c77c
(face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10375
diff
changeset
|
488 |
f9d713e8c77c
(face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10375
diff
changeset
|
489 The optional argument FRAME specifies which frame to test; |
f9d713e8c77c
(face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10375
diff
changeset
|
490 if FRAME is t, test the default for new frames. |
f9d713e8c77c
(face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10375
diff
changeset
|
491 If FRAME is nil or omitted, test the selected frame." |
2456 | 492 (let ((default (internal-get-face 'default frame))) |
493 (setq face (internal-get-face face frame)) | |
494 (not (and (or (equal (face-foreground default frame) | |
495 (face-foreground face frame)) | |
496 (null (face-foreground face frame))) | |
497 (or (equal (face-background default frame) | |
498 (face-background face frame)) | |
499 (null (face-background face frame))) | |
500 (or (equal (face-font default frame) (face-font face frame)) | |
501 (null (face-font face frame))) | |
9569
943acba6d366
(set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9197
diff
changeset
|
502 (or (equal (face-stipple default frame) |
943acba6d366
(set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9197
diff
changeset
|
503 (face-stipple face frame)) |
943acba6d366
(set-face-stipple): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9197
diff
changeset
|
504 (null (face-stipple face frame))) |
2456 | 505 (equal (face-underline-p default frame) |
506 (face-underline-p face frame)) | |
507 )))) | |
508 | |
10379
f9d713e8c77c
(face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10375
diff
changeset
|
509 (defun face-nontrivial-p (face &optional frame) |
f9d713e8c77c
(face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10375
diff
changeset
|
510 "True if face FACE has some non-nil attribute. |
f9d713e8c77c
(face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10375
diff
changeset
|
511 The optional argument FRAME specifies which frame to test; |
f9d713e8c77c
(face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10375
diff
changeset
|
512 if FRAME is t, test the default for new frames. |
f9d713e8c77c
(face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10375
diff
changeset
|
513 If FRAME is nil or omitted, test the selected frame." |
f9d713e8c77c
(face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10375
diff
changeset
|
514 (setq face (internal-get-face face frame)) |
f9d713e8c77c
(face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10375
diff
changeset
|
515 (or (face-foreground face frame) |
f9d713e8c77c
(face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10375
diff
changeset
|
516 (face-background face frame) |
f9d713e8c77c
(face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10375
diff
changeset
|
517 (face-font face frame) |
f9d713e8c77c
(face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10375
diff
changeset
|
518 (face-stipple face frame) |
f9d713e8c77c
(face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10375
diff
changeset
|
519 (face-underline-p face frame))) |
f9d713e8c77c
(face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10375
diff
changeset
|
520 |
2456 | 521 |
522 (defun invert-face (face &optional frame) | |
523 "Swap the foreground and background colors of face FACE. | |
524 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
|
525 set its foreground and background to the default background and foreground." |
2456 | 526 (interactive (list (read-face-name "Invert face: "))) |
527 (setq face (internal-get-face face frame)) | |
528 (let ((fg (face-foreground face frame)) | |
529 (bg (face-background face frame))) | |
530 (if (or fg bg) | |
531 (progn | |
532 (set-face-foreground face bg frame) | |
533 (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
|
534 (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
|
535 (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
|
536 frame) |
a7b260d27c2c
(face-initialize): Don't create the `modeline' face.
Richard M. Stallman <rms@gnu.org>
parents:
2764
diff
changeset
|
537 (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
|
538 (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
|
539 frame))) |
2456 | 540 face) |
541 | |
542 | |
543 (defun internal-try-face-font (face font &optional frame) | |
544 "Like set-face-font, but returns nil on failure instead of an error." | |
545 (condition-case () | |
546 (set-face-font face font frame) | |
547 (error nil))) | |
548 | |
549 ;; Manipulating font names. | |
550 | |
551 (defconst x-font-regexp nil) | |
552 (defconst x-font-regexp-head nil) | |
553 (defconst x-font-regexp-weight nil) | |
554 (defconst x-font-regexp-slant nil) | |
555 | |
12668
7660e82d0346
(x-font-regexp-weight-subnum, x-font-regexp-slant-subnum)
Karl Heuer <kwzh@gnu.org>
parents:
12651
diff
changeset
|
556 (defconst x-font-regexp-weight-subnum 1) |
7660e82d0346
(x-font-regexp-weight-subnum, x-font-regexp-slant-subnum)
Karl Heuer <kwzh@gnu.org>
parents:
12651
diff
changeset
|
557 (defconst x-font-regexp-slant-subnum 2) |
7660e82d0346
(x-font-regexp-weight-subnum, x-font-regexp-slant-subnum)
Karl Heuer <kwzh@gnu.org>
parents:
12651
diff
changeset
|
558 (defconst x-font-regexp-swidth-subnum 3) |
7660e82d0346
(x-font-regexp-weight-subnum, x-font-regexp-slant-subnum)
Karl Heuer <kwzh@gnu.org>
parents:
12651
diff
changeset
|
559 (defconst x-font-regexp-adstyle-subnum 4) |
7660e82d0346
(x-font-regexp-weight-subnum, x-font-regexp-slant-subnum)
Karl Heuer <kwzh@gnu.org>
parents:
12651
diff
changeset
|
560 |
2456 | 561 ;;; Regexps matching font names in "Host Portable Character Representation." |
562 ;;; | |
563 (let ((- "[-?]") | |
564 (foundry "[^-]+") | |
565 (family "[^-]+") | |
566 (weight "\\(bold\\|demibold\\|medium\\)") ; 1 | |
567 ; (weight\? "\\(\\*\\|bold\\|demibold\\|medium\\|\\)") ; 1 | |
568 (weight\? "\\([^-]*\\)") ; 1 | |
569 (slant "\\([ior]\\)") ; 2 | |
570 ; (slant\? "\\([ior?*]?\\)") ; 2 | |
571 (slant\? "\\([^-]?\\)") ; 2 | |
572 ; (swidth "\\(\\*\\|normal\\|semicondensed\\|\\)") ; 3 | |
573 (swidth "\\([^-]*\\)") ; 3 | |
574 ; (adstyle "\\(\\*\\|sans\\|\\)") ; 4 | |
12690
e2d3fa52d100
(x-font-regexp): Add \\(\\) for substring extraction.
Karl Heuer <kwzh@gnu.org>
parents:
12668
diff
changeset
|
575 (adstyle "\\([^-]*\\)") ; 4 |
2456 | 576 (pixelsize "[0-9]+") |
577 (pointsize "[0-9][0-9]+") | |
578 (resx "[0-9][0-9]+") | |
579 (resy "[0-9][0-9]+") | |
580 (spacing "[cmp?*]") | |
581 (avgwidth "[0-9]+") | |
582 (registry "[^-]+") | |
583 (encoding "[^-]+") | |
584 ) | |
585 (setq x-font-regexp | |
586 (concat "\\`\\*?[-?*]" | |
587 foundry - family - weight\? - slant\? - swidth - adstyle - | |
12475
eb436b0c4ab3
(x-font-regexp): Include the avgwidth.
Richard M. Stallman <rms@gnu.org>
parents:
12460
diff
changeset
|
588 pixelsize - pointsize - resx - resy - spacing - avgwidth - |
eb436b0c4ab3
(x-font-regexp): Include the avgwidth.
Richard M. Stallman <rms@gnu.org>
parents:
12460
diff
changeset
|
589 registry - encoding "\\*?\\'" |
2456 | 590 )) |
591 (setq x-font-regexp-head | |
592 (concat "\\`[-?*]" foundry - family - weight\? - slant\? | |
593 "\\([-*?]\\|\\'\\)")) | |
594 (setq x-font-regexp-slant (concat - slant -)) | |
595 (setq x-font-regexp-weight (concat - weight -)) | |
596 nil) | |
597 | |
3071
68de05fb5751
* faces.el (set-face-font): Call x-resolve-font-name on the font
Jim Blandy <jimb@redhat.com>
parents:
3049
diff
changeset
|
598 (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
|
599 "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
|
600 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
|
601 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
|
602 contains wildcards. |
10170
5fc240a3e4a0
(face-initialize): Test for framep not t or nil.
Richard M. Stallman <rms@gnu.org>
parents:
10107
diff
changeset
|
603 Given optional arguments FACE and FRAME, return a font which is |
5fc240a3e4a0
(face-initialize): Test for framep not t or nil.
Richard M. Stallman <rms@gnu.org>
parents:
10107
diff
changeset
|
604 also the same size as FACE on FRAME, or fail." |
3233
28b2df35c33e
(x-resolve-font-name): Allow symbol as FACE arg.
Richard M. Stallman <rms@gnu.org>
parents:
3182
diff
changeset
|
605 (or (symbolp face) |
28b2df35c33e
(x-resolve-font-name): Allow symbol as FACE arg.
Richard M. Stallman <rms@gnu.org>
parents:
3182
diff
changeset
|
606 (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
|
607 (and (eq frame t) |
28b2df35c33e
(x-resolve-font-name): Allow symbol as FACE arg.
Richard M. Stallman <rms@gnu.org>
parents:
3182
diff
changeset
|
608 (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
|
609 (if pattern |
5092
36508a7c0a3f
(x-resolve-font-name): Undo previous change.
Richard M. Stallman <rms@gnu.org>
parents:
5081
diff
changeset
|
610 ;; 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
|
611 (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
|
612 (or fonts |
82c29bacb6b3
* faces.el (x-resolve-font-name): If PATTERN is nil, return the
Jim Blandy <jimb@redhat.com>
parents:
3071
diff
changeset
|
613 (if face |
10584 | 614 (if (string-match "\\*" pattern) |
615 (if (null (face-font face)) | |
616 (error "No matching fonts are the same height as the frame default font") | |
617 (error "No matching fonts are the same height as face `%s'" face)) | |
618 (if (null (face-font face)) | |
619 (error "Height of font `%s' doesn't match the frame default font" | |
620 pattern) | |
621 (error "Height of font `%s' doesn't match face `%s'" | |
622 pattern face))) | |
3353
8cbd38886eef
(x-resolve-font-name): Clean up error messages.
Richard M. Stallman <rms@gnu.org>
parents:
3298
diff
changeset
|
623 (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
|
624 (car fonts)) |
82c29bacb6b3
* faces.el (x-resolve-font-name): If PATTERN is nil, return the
Jim Blandy <jimb@redhat.com>
parents:
3071
diff
changeset
|
625 (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
|
626 |
2456 | 627 (defun x-frob-font-weight (font which) |
12562
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
628 (cond ((string-match x-font-regexp font) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
629 (concat (substring font 0 (match-beginning x-font-regexp-weight-subnum)) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
630 which |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
631 (substring font (match-end x-font-regexp-weight-subnum) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
632 (match-beginning x-font-regexp-adstyle-subnum)) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
633 ;; Replace the ADD_STYLE_NAME field with * |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
634 ;; because the info in it may not be the same |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
635 ;; for related fonts. |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
636 "*" |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
637 (substring font (match-end x-font-regexp-adstyle-subnum)))) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
638 ((or (string-match x-font-regexp-head font) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
639 (string-match x-font-regexp-weight font)) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
640 (concat (substring font 0 (match-beginning 1)) which |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
641 (substring font (match-end 1)))))) |
2456 | 642 |
643 (defun x-frob-font-slant (font which) | |
12562
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
644 (cond ((string-match x-font-regexp font) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
645 (concat (substring font 0 (match-beginning x-font-regexp-slant-subnum)) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
646 which |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
647 (substring font (match-end x-font-regexp-slant-subnum) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
648 (match-beginning x-font-regexp-adstyle-subnum)) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
649 ;; Replace the ADD_STYLE_NAME field with * |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
650 ;; because the info in it may not be the same |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
651 ;; for related fonts. |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
652 "*" |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
653 (substring font (match-end x-font-regexp-adstyle-subnum)))) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
654 ((or (string-match x-font-regexp-head font) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
655 (string-match x-font-regexp-slant font)) |
2456 | 656 (concat (substring font 0 (match-beginning 1)) which |
12562
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
657 (substring font (match-end 1)))))) |
2456 | 658 |
659 (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
|
660 "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
|
661 If that can't be done, return nil." |
2456 | 662 (x-frob-font-weight font "bold")) |
663 | |
664 (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
|
665 "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
|
666 If that can't be done, return nil." |
2456 | 667 (x-frob-font-weight font "demibold")) |
668 | |
669 (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
|
670 "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
|
671 If that can't be done, return nil." |
2456 | 672 (x-frob-font-weight font "medium")) |
673 | |
674 (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
|
675 "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
|
676 If that can't be done, return nil." |
2456 | 677 (x-frob-font-slant font "i")) |
678 | |
679 (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
|
680 "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
|
681 If that can't be done, return nil." |
2456 | 682 (x-frob-font-slant font "o")) |
683 | |
684 (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
|
685 "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
|
686 If that can't be done, return nil." |
2456 | 687 (x-frob-font-slant font "r")) |
688 | |
689 ;;; non-X-specific interface | |
690 | |
2714
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
691 (defun make-face-bold (face &optional frame noerror) |
2456 | 692 "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
|
693 If NOERROR is non-nil, return nil on failure." |
2456 | 694 (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
|
695 (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
|
696 (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
|
697 '(bold italic) '(bold)) |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
698 t) |
12651
4bb00f26c714
(make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents:
12581
diff
changeset
|
699 (let (font) |
4439
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
700 (if (null frame) |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
701 (let ((frames (frame-list))) |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
702 ;; 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
|
703 (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
|
704 ;; 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
|
705 (while frames |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
706 (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
|
707 (setq frames (cdr frames)))) |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
708 (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
|
709 (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
|
710 (face-font face t))) |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
711 (if (listp font) |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
712 (setq font nil)) |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
713 (setq font (or font |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
714 (face-font 'default frame) |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
715 (cdr (assq 'font (frame-parameters frame))))) |
12651
4bb00f26c714
(make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents:
12581
diff
changeset
|
716 (or (and font (make-face-bold-internal face frame font)) |
4bb00f26c714
(make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents:
12581
diff
changeset
|
717 ;; We failed to find a bold version of the font. |
4bb00f26c714
(make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents:
12581
diff
changeset
|
718 noerror |
4bb00f26c714
(make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents:
12581
diff
changeset
|
719 (error "No bold version of %S" font)))))) |
4439
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
720 |
8109
9bc00e1f0f3e
(make-face-italic, make-face-bold): Don't bind f2 here.
Richard M. Stallman <rms@gnu.org>
parents:
8107
diff
changeset
|
721 (defun make-face-bold-internal (face frame font) |
9bc00e1f0f3e
(make-face-italic, make-face-bold): Don't bind f2 here.
Richard M. Stallman <rms@gnu.org>
parents:
8107
diff
changeset
|
722 (let (f2) |
9bc00e1f0f3e
(make-face-italic, make-face-bold): Don't bind f2 here.
Richard M. Stallman <rms@gnu.org>
parents:
8107
diff
changeset
|
723 (or (and (setq f2 (x-make-font-bold font)) |
9bc00e1f0f3e
(make-face-italic, make-face-bold): Don't bind f2 here.
Richard M. Stallman <rms@gnu.org>
parents:
8107
diff
changeset
|
724 (internal-try-face-font face f2 frame)) |
9bc00e1f0f3e
(make-face-italic, make-face-bold): Don't bind f2 here.
Richard M. Stallman <rms@gnu.org>
parents:
8107
diff
changeset
|
725 (and (setq f2 (x-make-font-demibold font)) |
9bc00e1f0f3e
(make-face-italic, make-face-bold): Don't bind f2 here.
Richard M. Stallman <rms@gnu.org>
parents:
8107
diff
changeset
|
726 (internal-try-face-font face f2 frame))))) |
2456 | 727 |
2714
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
728 (defun make-face-italic (face &optional frame noerror) |
2456 | 729 "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
|
730 If NOERROR is non-nil, return nil on failure." |
2456 | 731 (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
|
732 (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
|
733 (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
|
734 '(bold italic) '(italic)) |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
735 t) |
12651
4bb00f26c714
(make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents:
12581
diff
changeset
|
736 (let (font) |
4439
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
737 (if (null frame) |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
738 (let ((frames (frame-list))) |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
739 ;; 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
|
740 (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
|
741 ;; 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
|
742 (while frames |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
743 (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
|
744 (setq frames (cdr frames)))) |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
745 (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
|
746 (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
|
747 (face-font face t))) |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
748 (if (listp font) |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
749 (setq font nil)) |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
750 (setq font (or font |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
751 (face-font 'default frame) |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
752 (cdr (assq 'font (frame-parameters frame))))) |
12651
4bb00f26c714
(make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents:
12581
diff
changeset
|
753 (or (and font (make-face-italic-internal face frame font)) |
4bb00f26c714
(make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents:
12581
diff
changeset
|
754 ;; We failed to find an italic version of the font. |
4bb00f26c714
(make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents:
12581
diff
changeset
|
755 noerror |
4bb00f26c714
(make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents:
12581
diff
changeset
|
756 (error "No italic version of %S" font)))))) |
4439
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
757 |
8109
9bc00e1f0f3e
(make-face-italic, make-face-bold): Don't bind f2 here.
Richard M. Stallman <rms@gnu.org>
parents:
8107
diff
changeset
|
758 (defun make-face-italic-internal (face frame font) |
9bc00e1f0f3e
(make-face-italic, make-face-bold): Don't bind f2 here.
Richard M. Stallman <rms@gnu.org>
parents:
8107
diff
changeset
|
759 (let (f2) |
9bc00e1f0f3e
(make-face-italic, make-face-bold): Don't bind f2 here.
Richard M. Stallman <rms@gnu.org>
parents:
8107
diff
changeset
|
760 (or (and (setq f2 (x-make-font-italic font)) |
9bc00e1f0f3e
(make-face-italic, make-face-bold): Don't bind f2 here.
Richard M. Stallman <rms@gnu.org>
parents:
8107
diff
changeset
|
761 (internal-try-face-font face f2 frame)) |
9bc00e1f0f3e
(make-face-italic, make-face-bold): Don't bind f2 here.
Richard M. Stallman <rms@gnu.org>
parents:
8107
diff
changeset
|
762 (and (setq f2 (x-make-font-oblique font)) |
9bc00e1f0f3e
(make-face-italic, make-face-bold): Don't bind f2 here.
Richard M. Stallman <rms@gnu.org>
parents:
8107
diff
changeset
|
763 (internal-try-face-font face f2 frame))))) |
2456 | 764 |
2714
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
765 (defun make-face-bold-italic (face &optional frame noerror) |
2456 | 766 "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
|
767 If NOERROR is non-nil, return nil on failure." |
2456 | 768 (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
|
769 (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
|
770 (set-face-font face '(bold italic) t) |
12651
4bb00f26c714
(make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents:
12581
diff
changeset
|
771 (let (font) |
4439
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
772 (if (null frame) |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
773 (let ((frames (frame-list))) |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
774 ;; 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
|
775 (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
|
776 ;; 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
|
777 (while frames |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
778 (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
|
779 (setq frames (cdr frames)))) |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
780 (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
|
781 (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
|
782 (face-font face t))) |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
783 (if (listp font) |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
784 (setq font nil)) |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
785 (setq font (or font |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
786 (face-font 'default frame) |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
787 (cdr (assq 'font (frame-parameters frame))))) |
12651
4bb00f26c714
(make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents:
12581
diff
changeset
|
788 (or (and font (make-face-bold-italic-internal face frame font)) |
4bb00f26c714
(make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents:
12581
diff
changeset
|
789 ;; We failed to find a bold italic version. |
4bb00f26c714
(make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents:
12581
diff
changeset
|
790 noerror |
4bb00f26c714
(make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents:
12581
diff
changeset
|
791 (error "No bold italic version of %S" font)))))) |
4439
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
792 |
8109
9bc00e1f0f3e
(make-face-italic, make-face-bold): Don't bind f2 here.
Richard M. Stallman <rms@gnu.org>
parents:
8107
diff
changeset
|
793 (defun make-face-bold-italic-internal (face frame font) |
4439
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
794 (let (f2 f3) |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
795 (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
|
796 (not (equal font f2)) |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
797 (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
|
798 (not (equal f2 f3)) |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
799 (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
|
800 (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
|
801 (not (equal font f2)) |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
802 (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
|
803 (not (equal f2 f3)) |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
804 (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
|
805 (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
|
806 (not (equal font f2)) |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
807 (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
|
808 (not (equal f2 f3)) |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
809 (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
|
810 (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
|
811 (not (equal font f2)) |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
812 (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
|
813 (not (equal f2 f3)) |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
814 (internal-try-face-font face f3 frame))))) |
2456 | 815 |
2714
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
816 (defun make-face-unbold (face &optional frame noerror) |
2456 | 817 "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
|
818 If NOERROR is non-nil, return nil on failure." |
2456 | 819 (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
|
820 (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
|
821 (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
|
822 '(italic) nil) |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
823 t) |
12651
4bb00f26c714
(make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents:
12581
diff
changeset
|
824 (let (font font1) |
4439
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
825 (if (null frame) |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
826 (let ((frames (frame-list))) |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
827 ;; 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
|
828 (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
|
829 ;; 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
|
830 (while frames |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
831 (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
|
832 (setq frames (cdr frames)))) |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
833 (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
|
834 (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
|
835 (face-font face t))) |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
836 (if (listp font1) |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
837 (setq font1 nil)) |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
838 (setq font1 (or font1 |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
839 (face-font 'default frame) |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
840 (cdr (assq 'font (frame-parameters frame))))) |
8732
58d6dc80af5c
(make-face-unbold, make-face-unitalic, make-face-bold, make-face-italic,
Karl Heuer <kwzh@gnu.org>
parents:
8515
diff
changeset
|
841 (setq font (and font1 (x-make-font-unbold font1))) |
12651
4bb00f26c714
(make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents:
12581
diff
changeset
|
842 (or (if font (internal-try-face-font face font frame)) |
4bb00f26c714
(make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents:
12581
diff
changeset
|
843 noerror |
4bb00f26c714
(make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents:
12581
diff
changeset
|
844 (error "No unbold version of %S" font1)))))) |
2456 | 845 |
2714
bfe999b19082
* faces.el (read-face-name): Call face-list, not list-faces.
Jim Blandy <jimb@redhat.com>
parents:
2456
diff
changeset
|
846 (defun make-face-unitalic (face &optional frame noerror) |
2456 | 847 "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
|
848 If NOERROR is non-nil, return nil on failure." |
2456 | 849 (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
|
850 (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
|
851 (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
|
852 '(bold) nil) |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
853 t) |
12651
4bb00f26c714
(make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents:
12581
diff
changeset
|
854 (let (font font1) |
4439
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
855 (if (null frame) |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
856 (let ((frames (frame-list))) |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
857 ;; 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
|
858 (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
|
859 ;; 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
|
860 (while frames |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
861 (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
|
862 (setq frames (cdr frames)))) |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
863 (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
|
864 (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
|
865 (face-font face t))) |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
866 (if (listp font1) |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
867 (setq font1 nil)) |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
868 (setq font1 (or font1 |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
869 (face-font 'default frame) |
e7ab04f23df5
Make boldness and italicness affect subsequently created frames.
Richard M. Stallman <rms@gnu.org>
parents:
4122
diff
changeset
|
870 (cdr (assq 'font (frame-parameters frame))))) |
8732
58d6dc80af5c
(make-face-unbold, make-face-unitalic, make-face-bold, make-face-italic,
Karl Heuer <kwzh@gnu.org>
parents:
8515
diff
changeset
|
871 (setq font (and font1 (x-make-font-unitalic font1))) |
12651
4bb00f26c714
(make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents:
12581
diff
changeset
|
872 (or (if font (internal-try-face-font face font frame)) |
4bb00f26c714
(make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents:
12581
diff
changeset
|
873 noerror |
4bb00f26c714
(make-face-bold, make-face-italic, make-face-bold-italic)
Richard M. Stallman <rms@gnu.org>
parents:
12581
diff
changeset
|
874 (error "No unitalic version of %S" font1)))))) |
2456 | 875 |
4083
465c6787d6dd
(copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents:
3969
diff
changeset
|
876 (defvar list-faces-sample-text |
465c6787d6dd
(copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents:
3969
diff
changeset
|
877 "abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ" |
465c6787d6dd
(copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents:
3969
diff
changeset
|
878 "*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
|
879 |
465c6787d6dd
(copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents:
3969
diff
changeset
|
880 ;; 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
|
881 ;; with Lucid, which uses that name differently. |
465c6787d6dd
(copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents:
3969
diff
changeset
|
882 (defun list-faces-display () |
465c6787d6dd
(copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents:
3969
diff
changeset
|
883 "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
|
884 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
|
885 `list-faces-sample-text'. |
465c6787d6dd
(copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents:
3969
diff
changeset
|
886 |
465c6787d6dd
(copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents:
3969
diff
changeset
|
887 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
|
888 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
|
889 selected frame." |
465c6787d6dd
(copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents:
3969
diff
changeset
|
890 (interactive) |
465c6787d6dd
(copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents:
3969
diff
changeset
|
891 (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
|
892 (face nil) |
465c6787d6dd
(copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents:
3969
diff
changeset
|
893 (frame (selected-frame)) |
465c6787d6dd
(copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents:
3969
diff
changeset
|
894 disp-frame window) |
465c6787d6dd
(copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents:
3969
diff
changeset
|
895 (with-output-to-temp-buffer "*Faces*" |
465c6787d6dd
(copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents:
3969
diff
changeset
|
896 (save-excursion |
465c6787d6dd
(copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents:
3969
diff
changeset
|
897 (set-buffer standard-output) |
465c6787d6dd
(copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents:
3969
diff
changeset
|
898 (setq truncate-lines t) |
465c6787d6dd
(copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents:
3969
diff
changeset
|
899 (while faces |
465c6787d6dd
(copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents:
3969
diff
changeset
|
900 (setq face (car faces)) |
465c6787d6dd
(copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents:
3969
diff
changeset
|
901 (setq faces (cdr faces)) |
465c6787d6dd
(copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents:
3969
diff
changeset
|
902 (insert (format "%25s " (symbol-name face))) |
465c6787d6dd
(copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents:
3969
diff
changeset
|
903 (let ((beg (point))) |
465c6787d6dd
(copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents:
3969
diff
changeset
|
904 (insert list-faces-sample-text) |
465c6787d6dd
(copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents:
3969
diff
changeset
|
905 (insert "\n") |
8107
0885b28decc6
(list-faces-display): Line up multiple lines in sample.
Richard M. Stallman <rms@gnu.org>
parents:
8011
diff
changeset
|
906 (put-text-property beg (1- (point)) 'face face) |
0885b28decc6
(list-faces-display): Line up multiple lines in sample.
Richard M. Stallman <rms@gnu.org>
parents:
8011
diff
changeset
|
907 ;; If the sample text has multiple lines, line up all of them. |
0885b28decc6
(list-faces-display): Line up multiple lines in sample.
Richard M. Stallman <rms@gnu.org>
parents:
8011
diff
changeset
|
908 (goto-char beg) |
0885b28decc6
(list-faces-display): Line up multiple lines in sample.
Richard M. Stallman <rms@gnu.org>
parents:
8011
diff
changeset
|
909 (forward-line 1) |
0885b28decc6
(list-faces-display): Line up multiple lines in sample.
Richard M. Stallman <rms@gnu.org>
parents:
8011
diff
changeset
|
910 (while (not (eobp)) |
0885b28decc6
(list-faces-display): Line up multiple lines in sample.
Richard M. Stallman <rms@gnu.org>
parents:
8011
diff
changeset
|
911 (insert " ") |
0885b28decc6
(list-faces-display): Line up multiple lines in sample.
Richard M. Stallman <rms@gnu.org>
parents:
8011
diff
changeset
|
912 (forward-line 1)))) |
4083
465c6787d6dd
(copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents:
3969
diff
changeset
|
913 (goto-char (point-min)))) |
465c6787d6dd
(copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents:
3969
diff
changeset
|
914 ;; 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
|
915 ;; copy all the face definitions from FRAME, |
465c6787d6dd
(copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents:
3969
diff
changeset
|
916 ;; 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
|
917 (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
|
918 (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
|
919 (car (frame-list)))) |
465c6787d6dd
(copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents:
3969
diff
changeset
|
920 (or (eq frame disp-frame) |
465c6787d6dd
(copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents:
3969
diff
changeset
|
921 (let ((faces (face-list))) |
465c6787d6dd
(copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents:
3969
diff
changeset
|
922 (while faces |
465c6787d6dd
(copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents:
3969
diff
changeset
|
923 (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
|
924 (setq faces (cdr faces))))))) |
12460
1e12a802df2b
(describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12169
diff
changeset
|
925 |
1e12a802df2b
(describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12169
diff
changeset
|
926 (defun describe-face (face) |
1e12a802df2b
(describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12169
diff
changeset
|
927 "Display the properties of face FACE." |
1e12a802df2b
(describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12169
diff
changeset
|
928 (interactive (list (read-face-name "Describe face: "))) |
1e12a802df2b
(describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12169
diff
changeset
|
929 (with-output-to-temp-buffer "*Help*" |
1e12a802df2b
(describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12169
diff
changeset
|
930 (princ "Properties of face `") |
1e12a802df2b
(describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12169
diff
changeset
|
931 (princ (face-name face)) |
1e12a802df2b
(describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12169
diff
changeset
|
932 (princ "':") (terpri) |
1e12a802df2b
(describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12169
diff
changeset
|
933 (princ "Foreground: ") (princ (face-foreground face)) (terpri) |
1e12a802df2b
(describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12169
diff
changeset
|
934 (princ "Background: ") (princ (face-background face)) (terpri) |
1e12a802df2b
(describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12169
diff
changeset
|
935 (princ " Font: ") (princ (face-font face)) (terpri) |
1e12a802df2b
(describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12169
diff
changeset
|
936 (princ "Underlined: ") (princ (if (face-underline-p face) "yes" "no")) (terpri) |
1e12a802df2b
(describe-face): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12169
diff
changeset
|
937 (princ " Stipple: ") (princ (or (face-stipple face) "none")))) |
4083
465c6787d6dd
(copy-face): New arg NEW-FRAME.
Richard M. Stallman <rms@gnu.org>
parents:
3969
diff
changeset
|
938 |
5929
2538d44f96d4
(face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents:
5849
diff
changeset
|
939 ;;; Make the standard faces. |
2538d44f96d4
(face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents:
5849
diff
changeset
|
940 ;;; 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
|
941 ;;; 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
|
942 (defun face-initialize () |
2456 | 943 (make-face 'default) |
2826
9c22af6d7885
(face-initialize): Do make the modeline face.
Richard M. Stallman <rms@gnu.org>
parents:
2807
diff
changeset
|
944 (make-face 'modeline) |
2456 | 945 (make-face 'highlight) |
5929
2538d44f96d4
(face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents:
5849
diff
changeset
|
946 |
2456 | 947 ;; 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
|
948 |
2456 | 949 (make-face 'bold) |
950 (make-face 'italic) | |
951 (make-face 'bold-italic) | |
2807
9e8635dafd40
Rename `primary-selection' to `region'.
Richard M. Stallman <rms@gnu.org>
parents:
2800
diff
changeset
|
952 (make-face 'region) |
2764
17c322204ce3
(face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2744
diff
changeset
|
953 (make-face 'secondary-selection) |
3911
06dbadd0e4a7
(face-initialize): Create `underline' face.
Richard M. Stallman <rms@gnu.org>
parents:
3910
diff
changeset
|
954 (make-face 'underline) |
2764
17c322204ce3
(face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2744
diff
changeset
|
955 |
2807
9e8635dafd40
Rename `primary-selection' to `region'.
Richard M. Stallman <rms@gnu.org>
parents:
2800
diff
changeset
|
956 (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
|
957 |
5929
2538d44f96d4
(face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents:
5849
diff
changeset
|
958 ;; Specify the global properties of these faces |
2538d44f96d4
(face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents:
5849
diff
changeset
|
959 ;; 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
|
960 |
2538d44f96d4
(face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents:
5849
diff
changeset
|
961 (make-face-bold 'bold t) |
2538d44f96d4
(face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents:
5849
diff
changeset
|
962 (make-face-italic 'italic t) |
2538d44f96d4
(face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents:
5849
diff
changeset
|
963 (make-face-bold-italic 'bold-italic t) |
2538d44f96d4
(face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents:
5849
diff
changeset
|
964 |
2538d44f96d4
(face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents:
5849
diff
changeset
|
965 (set-face-background 'highlight '("darkseagreen2" "green" t) t) |
8377
4ac21edb9f78
(face-initialize): Use underlining for region face
Richard M. Stallman <rms@gnu.org>
parents:
8186
diff
changeset
|
966 (set-face-background 'region '("gray" underline) t) |
5929
2538d44f96d4
(face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents:
5849
diff
changeset
|
967 (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
|
968 (set-face-background 'modeline '(t) t) |
2538d44f96d4
(face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents:
5849
diff
changeset
|
969 (set-face-underline-p 'underline t t) |
2538d44f96d4
(face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents:
5849
diff
changeset
|
970 |
2538d44f96d4
(face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents:
5849
diff
changeset
|
971 ;; 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
|
972 ;; 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
|
973 |
2764
17c322204ce3
(face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2744
diff
changeset
|
974 (let ((frames (frame-list))) |
17c322204ce3
(face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2744
diff
changeset
|
975 (while frames |
10170
5fc240a3e4a0
(face-initialize): Test for framep not t or nil.
Richard M. Stallman <rms@gnu.org>
parents:
10107
diff
changeset
|
976 (if (not (memq (framep (car frames)) '(t nil))) |
5929
2538d44f96d4
(face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents:
5849
diff
changeset
|
977 (let ((frame (car frames)) |
2538d44f96d4
(face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents:
5849
diff
changeset
|
978 (rest global-face-data)) |
2538d44f96d4
(face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents:
5849
diff
changeset
|
979 (while rest |
2538d44f96d4
(face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents:
5849
diff
changeset
|
980 (let ((face (car (car rest)))) |
2538d44f96d4
(face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents:
5849
diff
changeset
|
981 (or (face-differs-from-default-p face) |
2538d44f96d4
(face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents:
5849
diff
changeset
|
982 (face-fill-in face (cdr (car rest)) frame))) |
2538d44f96d4
(face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents:
5849
diff
changeset
|
983 (setq rest (cdr rest))))) |
2764
17c322204ce3
(face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2744
diff
changeset
|
984 (setq frames (cdr frames))))) |
17c322204ce3
(face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2744
diff
changeset
|
985 |
2456 | 986 |
987 ;; Like x-create-frame but also set up the faces. | |
988 | |
989 (defun x-create-frame-with-faces (&optional parameters) | |
11927
20eae371b3f0
(x-create-frame-with-faces): Read geometry resource
Karl Heuer <kwzh@gnu.org>
parents:
11850
diff
changeset
|
990 ;; Read this frame's geometry resource, if it has an explicit name, |
20eae371b3f0
(x-create-frame-with-faces): Read geometry resource
Karl Heuer <kwzh@gnu.org>
parents:
11850
diff
changeset
|
991 ;; and put the specs into PARAMETERS. |
20eae371b3f0
(x-create-frame-with-faces): Read geometry resource
Karl Heuer <kwzh@gnu.org>
parents:
11850
diff
changeset
|
992 (let* ((name (or (cdr (assq 'name parameters)) |
12169
67f9dfb23d7c
(x-create-frame-with-faces): Don't use initial-frame-alist
Karl Heuer <kwzh@gnu.org>
parents:
12168
diff
changeset
|
993 (cdr (assq 'name default-frame-alist)))) |
11927
20eae371b3f0
(x-create-frame-with-faces): Read geometry resource
Karl Heuer <kwzh@gnu.org>
parents:
11850
diff
changeset
|
994 (x-resource-name name) |
12168
40be3e73cfb0
(x-create-frame-with-faces): Don't look for geometry
Karl Heuer <kwzh@gnu.org>
parents:
11927
diff
changeset
|
995 (res-geometry (if name (x-get-resource "geometry" "Geometry"))) |
11927
20eae371b3f0
(x-create-frame-with-faces): Read geometry resource
Karl Heuer <kwzh@gnu.org>
parents:
11850
diff
changeset
|
996 parsed) |
20eae371b3f0
(x-create-frame-with-faces): Read geometry resource
Karl Heuer <kwzh@gnu.org>
parents:
11850
diff
changeset
|
997 (if res-geometry |
20eae371b3f0
(x-create-frame-with-faces): Read geometry resource
Karl Heuer <kwzh@gnu.org>
parents:
11850
diff
changeset
|
998 (progn |
20eae371b3f0
(x-create-frame-with-faces): Read geometry resource
Karl Heuer <kwzh@gnu.org>
parents:
11850
diff
changeset
|
999 (setq parsed (x-parse-geometry res-geometry)) |
20eae371b3f0
(x-create-frame-with-faces): Read geometry resource
Karl Heuer <kwzh@gnu.org>
parents:
11850
diff
changeset
|
1000 ;; If the resource specifies a position, |
20eae371b3f0
(x-create-frame-with-faces): Read geometry resource
Karl Heuer <kwzh@gnu.org>
parents:
11850
diff
changeset
|
1001 ;; call the position and size "user-specified". |
20eae371b3f0
(x-create-frame-with-faces): Read geometry resource
Karl Heuer <kwzh@gnu.org>
parents:
11850
diff
changeset
|
1002 (if (or (assq 'top parsed) (assq 'left parsed)) |
20eae371b3f0
(x-create-frame-with-faces): Read geometry resource
Karl Heuer <kwzh@gnu.org>
parents:
11850
diff
changeset
|
1003 (setq parsed (cons '(user-position . t) |
20eae371b3f0
(x-create-frame-with-faces): Read geometry resource
Karl Heuer <kwzh@gnu.org>
parents:
11850
diff
changeset
|
1004 (cons '(user-size . t) parsed)))) |
12169
67f9dfb23d7c
(x-create-frame-with-faces): Don't use initial-frame-alist
Karl Heuer <kwzh@gnu.org>
parents:
12168
diff
changeset
|
1005 ;; Put the geometry parameters at the end. |
67f9dfb23d7c
(x-create-frame-with-faces): Don't use initial-frame-alist
Karl Heuer <kwzh@gnu.org>
parents:
12168
diff
changeset
|
1006 ;; Copy default-frame-alist so that they go after it. |
67f9dfb23d7c
(x-create-frame-with-faces): Don't use initial-frame-alist
Karl Heuer <kwzh@gnu.org>
parents:
12168
diff
changeset
|
1007 (setq parameters (append parameters |
67f9dfb23d7c
(x-create-frame-with-faces): Don't use initial-frame-alist
Karl Heuer <kwzh@gnu.org>
parents:
12168
diff
changeset
|
1008 default-frame-alist |
67f9dfb23d7c
(x-create-frame-with-faces): Don't use initial-frame-alist
Karl Heuer <kwzh@gnu.org>
parents:
12168
diff
changeset
|
1009 parsed))))) |
12562
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1010 (let (frame) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1011 (if (null global-face-data) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1012 (setq frame (x-create-frame parameters)) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1013 (let* ((visibility-spec (assq 'visibility parameters)) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1014 (faces (copy-alist global-face-data)) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1015 success |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1016 (rest faces)) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1017 (setq frame (x-create-frame (cons '(visibility . nil) parameters))) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1018 (unwind-protect |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1019 (progn |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1020 (set-frame-face-alist frame faces) |
2456 | 1021 |
12562
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1022 (if (cdr (or (assq 'reverse parameters) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1023 (assq 'reverse default-frame-alist) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1024 (let ((resource (x-get-resource "reverseVideo" |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1025 "ReverseVideo"))) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1026 (if resource |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1027 (cons nil (member (downcase resource) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1028 '("on" "true"))))))) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1029 (let* ((params (frame-parameters frame)) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1030 (bg (cdr (assq 'foreground-color params))) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1031 (fg (cdr (assq 'background-color params)))) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1032 (modify-frame-parameters frame |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1033 (list (cons 'foreground-color fg) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1034 (cons 'background-color bg))) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1035 (if (equal bg (cdr (assq 'border-color params))) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1036 (modify-frame-parameters frame |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1037 (list (cons 'border-color fg)))) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1038 (if (equal bg (cdr (assq 'mouse-color params))) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1039 (modify-frame-parameters frame |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1040 (list (cons 'mouse-color fg)))) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1041 (if (equal bg (cdr (assq 'cursor-color params))) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1042 (modify-frame-parameters frame |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1043 (list (cons 'cursor-color fg)))))) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1044 ;; Copy the vectors that represent the faces. |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1045 ;; Also fill them in from X resources. |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1046 (while rest |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1047 (let ((global (cdr (car rest)))) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1048 (setcdr (car rest) (vector 'face |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1049 (face-name (cdr (car rest))) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1050 (face-id (cdr (car rest))) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1051 nil nil nil nil nil)) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1052 (face-fill-in (car (car rest)) global frame)) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1053 (make-face-x-resource-internal (cdr (car rest)) frame t) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1054 (setq rest (cdr rest))) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1055 (if (null visibility-spec) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1056 (make-frame-visible frame) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1057 (modify-frame-parameters frame (list visibility-spec))) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1058 (setq success t)) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1059 (or success |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1060 (delete-frame frame))))) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1061 ;; Set up the background-mode frame parameter |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1062 ;; so that programs can decide good ways of highlighting |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1063 ;; on this frame. |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1064 (let ((bg-resource (x-get-resource ".backgroundMode" |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1065 "BackgroundMode")) |
12581
8e4a75fa4b5b
(x-create-frame-with-faces):
Richard M. Stallman <rms@gnu.org>
parents:
12562
diff
changeset
|
1066 (params (frame-parameters frame)) |
12562
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1067 (bg-mode)) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1068 (setq bg-mode |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1069 (cond (bg-resource (intern (downcase bg-resource))) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1070 ((< (apply '+ (x-color-values |
12581
8e4a75fa4b5b
(x-create-frame-with-faces):
Richard M. Stallman <rms@gnu.org>
parents:
12562
diff
changeset
|
1071 (cdr (assq 'background-color params)) |
8e4a75fa4b5b
(x-create-frame-with-faces):
Richard M. Stallman <rms@gnu.org>
parents:
12562
diff
changeset
|
1072 frame)) |
8e4a75fa4b5b
(x-create-frame-with-faces):
Richard M. Stallman <rms@gnu.org>
parents:
12562
diff
changeset
|
1073 (/ (apply '+ (x-color-values "white" frame)) 3)) |
12562
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1074 'dark) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1075 (t 'light))) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1076 (modify-frame-parameters frame |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1077 (list (cons 'background-mode bg-mode) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1078 (cons 'display-type |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1079 (cond ((x-display-color-p frame) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1080 'color) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1081 ((x-display-grayscale-p frame) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1082 'grayscale) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1083 (t 'mono)))))) |
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1084 frame)) |
2456 | 1085 |
7019
74edb669a7e9
(frame-update-faces): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6873
diff
changeset
|
1086 ;; Update a frame's faces when we change its default font. |
74edb669a7e9
(frame-update-faces): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6873
diff
changeset
|
1087 (defun frame-update-faces (frame) |
74edb669a7e9
(frame-update-faces): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6873
diff
changeset
|
1088 (let* ((faces global-face-data) |
74edb669a7e9
(frame-update-faces): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6873
diff
changeset
|
1089 (rest faces)) |
74edb669a7e9
(frame-update-faces): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6873
diff
changeset
|
1090 (while rest |
74edb669a7e9
(frame-update-faces): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6873
diff
changeset
|
1091 (let* ((face (car (car rest))) |
74edb669a7e9
(frame-update-faces): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6873
diff
changeset
|
1092 (font (face-font face t))) |
74edb669a7e9
(frame-update-faces): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6873
diff
changeset
|
1093 (if (listp font) |
74edb669a7e9
(frame-update-faces): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6873
diff
changeset
|
1094 (let ((bold (memq 'bold font)) |
74edb669a7e9
(frame-update-faces): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6873
diff
changeset
|
1095 (italic (memq 'italic font))) |
7120
a03d341e9594
(frame-update-faces): Unset old font.
Karl Heuer <kwzh@gnu.org>
parents:
7019
diff
changeset
|
1096 ;; Ignore any previous (string-valued) font, it might not even |
a03d341e9594
(frame-update-faces): Unset old font.
Karl Heuer <kwzh@gnu.org>
parents:
7019
diff
changeset
|
1097 ;; be the right size anymore. |
a03d341e9594
(frame-update-faces): Unset old font.
Karl Heuer <kwzh@gnu.org>
parents:
7019
diff
changeset
|
1098 (set-face-font face nil frame) |
7019
74edb669a7e9
(frame-update-faces): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6873
diff
changeset
|
1099 (cond ((and bold italic) |
74edb669a7e9
(frame-update-faces): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6873
diff
changeset
|
1100 (make-face-bold-italic face frame t)) |
74edb669a7e9
(frame-update-faces): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6873
diff
changeset
|
1101 (bold |
74edb669a7e9
(frame-update-faces): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6873
diff
changeset
|
1102 (make-face-bold face frame t)) |
74edb669a7e9
(frame-update-faces): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6873
diff
changeset
|
1103 (italic |
74edb669a7e9
(frame-update-faces): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6873
diff
changeset
|
1104 (make-face-italic face frame t))))) |
74edb669a7e9
(frame-update-faces): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6873
diff
changeset
|
1105 (setq rest (cdr rest))) |
74edb669a7e9
(frame-update-faces): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6873
diff
changeset
|
1106 frame))) |
74edb669a7e9
(frame-update-faces): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6873
diff
changeset
|
1107 |
10193
6efa61f222cb
(frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10170
diff
changeset
|
1108 ;; Update the colors of FACE, after FRAME's own colors have been changed. |
6efa61f222cb
(frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10170
diff
changeset
|
1109 ;; This applies only to faces with global color specifications |
6efa61f222cb
(frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10170
diff
changeset
|
1110 ;; that are not simple constants. |
6efa61f222cb
(frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10170
diff
changeset
|
1111 (defun frame-update-face-colors (frame) |
6efa61f222cb
(frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10170
diff
changeset
|
1112 (let ((faces global-face-data)) |
6efa61f222cb
(frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10170
diff
changeset
|
1113 (while faces |
6efa61f222cb
(frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10170
diff
changeset
|
1114 (condition-case nil |
6efa61f222cb
(frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10170
diff
changeset
|
1115 (let* ((data (cdr (car faces))) |
6efa61f222cb
(frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10170
diff
changeset
|
1116 (face (car (car faces))) |
6efa61f222cb
(frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10170
diff
changeset
|
1117 (foreground (face-foreground data)) |
6efa61f222cb
(frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10170
diff
changeset
|
1118 (background (face-background data))) |
6efa61f222cb
(frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10170
diff
changeset
|
1119 ;; If the global spec is a specific color, |
6efa61f222cb
(frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10170
diff
changeset
|
1120 ;; which doesn't depend on the frame's attributes, |
6efa61f222cb
(frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10170
diff
changeset
|
1121 ;; we don't need to recalculate it now. |
6efa61f222cb
(frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10170
diff
changeset
|
1122 (or (listp foreground) |
6efa61f222cb
(frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10170
diff
changeset
|
1123 (setq foreground nil)) |
6efa61f222cb
(frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10170
diff
changeset
|
1124 (or (listp background) |
6efa61f222cb
(frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10170
diff
changeset
|
1125 (setq background nil)) |
6efa61f222cb
(frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10170
diff
changeset
|
1126 ;; If we are going to frob this face at all, |
6efa61f222cb
(frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10170
diff
changeset
|
1127 ;; reinitialize it first. |
6efa61f222cb
(frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10170
diff
changeset
|
1128 (if (or foreground background) |
6efa61f222cb
(frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10170
diff
changeset
|
1129 (progn (set-face-foreground face nil frame) |
6efa61f222cb
(frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10170
diff
changeset
|
1130 (set-face-background face nil frame))) |
6efa61f222cb
(frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10170
diff
changeset
|
1131 (if foreground |
6efa61f222cb
(frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10170
diff
changeset
|
1132 (face-try-color-list 'set-face-foreground |
6efa61f222cb
(frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10170
diff
changeset
|
1133 face foreground frame)) |
6efa61f222cb
(frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10170
diff
changeset
|
1134 (if background |
6efa61f222cb
(frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10170
diff
changeset
|
1135 (face-try-color-list 'set-face-background |
6efa61f222cb
(frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10170
diff
changeset
|
1136 face background frame))) |
6efa61f222cb
(frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10170
diff
changeset
|
1137 (error nil)) |
6efa61f222cb
(frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10170
diff
changeset
|
1138 (setq faces (cdr faces))))) |
6efa61f222cb
(frame-update-face-colors): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10170
diff
changeset
|
1139 |
5929
2538d44f96d4
(face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents:
5849
diff
changeset
|
1140 ;; 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
|
1141 ;; 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
|
1142 ;; 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
|
1143 ;; 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
|
1144 (defun face-fill-in (face data frame) |
2538d44f96d4
(face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents:
5849
diff
changeset
|
1145 (condition-case nil |
2538d44f96d4
(face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents:
5849
diff
changeset
|
1146 (let ((foreground (face-foreground data)) |
2538d44f96d4
(face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents:
5849
diff
changeset
|
1147 (background (face-background data)) |
11850
f9174d73e755
Put property on set-face-stipple, not set-stipple.
Karl Heuer <kwzh@gnu.org>
parents:
11464
diff
changeset
|
1148 (font (face-font data)) |
f9174d73e755
Put property on set-face-stipple, not set-stipple.
Karl Heuer <kwzh@gnu.org>
parents:
11464
diff
changeset
|
1149 (stipple (face-stipple data))) |
5929
2538d44f96d4
(face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents:
5849
diff
changeset
|
1150 (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
|
1151 (if foreground |
2538d44f96d4
(face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents:
5849
diff
changeset
|
1152 (face-try-color-list 'set-face-foreground |
2538d44f96d4
(face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents:
5849
diff
changeset
|
1153 face foreground frame)) |
2538d44f96d4
(face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents:
5849
diff
changeset
|
1154 (if background |
2538d44f96d4
(face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents:
5849
diff
changeset
|
1155 (face-try-color-list 'set-face-background |
2538d44f96d4
(face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents:
5849
diff
changeset
|
1156 face background frame)) |
2538d44f96d4
(face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents:
5849
diff
changeset
|
1157 (if (listp font) |
2538d44f96d4
(face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents:
5849
diff
changeset
|
1158 (let ((bold (memq 'bold font)) |
2538d44f96d4
(face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents:
5849
diff
changeset
|
1159 (italic (memq 'italic font))) |
2538d44f96d4
(face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents:
5849
diff
changeset
|
1160 (cond ((and bold italic) |
2538d44f96d4
(face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents:
5849
diff
changeset
|
1161 (make-face-bold-italic face frame)) |
2538d44f96d4
(face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents:
5849
diff
changeset
|
1162 (bold |
2538d44f96d4
(face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents:
5849
diff
changeset
|
1163 (make-face-bold face frame)) |
2538d44f96d4
(face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents:
5849
diff
changeset
|
1164 (italic |
2538d44f96d4
(face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents:
5849
diff
changeset
|
1165 (make-face-italic face frame)))) |
2538d44f96d4
(face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents:
5849
diff
changeset
|
1166 (if font |
11850
f9174d73e755
Put property on set-face-stipple, not set-stipple.
Karl Heuer <kwzh@gnu.org>
parents:
11464
diff
changeset
|
1167 (set-face-font face font frame))) |
f9174d73e755
Put property on set-face-stipple, not set-stipple.
Karl Heuer <kwzh@gnu.org>
parents:
11464
diff
changeset
|
1168 (if stipple |
f9174d73e755
Put property on set-face-stipple, not set-stipple.
Karl Heuer <kwzh@gnu.org>
parents:
11464
diff
changeset
|
1169 (set-face-stipple face stipple frame))) |
5929
2538d44f96d4
(face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents:
5849
diff
changeset
|
1170 (error nil))) |
2456 | 1171 |
10022
30e0dc7c07cd
(face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9665
diff
changeset
|
1172 ;; Assuming COLOR is a valid color name, |
30e0dc7c07cd
(face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9665
diff
changeset
|
1173 ;; return t if it can be displayed on FRAME. |
30e0dc7c07cd
(face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9665
diff
changeset
|
1174 (defun face-color-supported-p (frame color background-p) |
30e0dc7c07cd
(face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9665
diff
changeset
|
1175 (or (x-display-color-p frame) |
30e0dc7c07cd
(face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9665
diff
changeset
|
1176 ;; A black-and-white display can implement these. |
30e0dc7c07cd
(face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9665
diff
changeset
|
1177 (member color '("black" "white")) |
12562
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1178 ;; A black-and-white display can fake gray for background. |
10022
30e0dc7c07cd
(face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9665
diff
changeset
|
1179 (and background-p |
12562
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1180 (face-color-gray-p color frame)) |
10022
30e0dc7c07cd
(face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9665
diff
changeset
|
1181 ;; A grayscale display can implement colors that are gray (more or less). |
30e0dc7c07cd
(face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9665
diff
changeset
|
1182 (and (x-display-grayscale-p frame) |
12562
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
1183 (face-color-gray-p color frame)))) |
10022
30e0dc7c07cd
(face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9665
diff
changeset
|
1184 |
5929
2538d44f96d4
(face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents:
5849
diff
changeset
|
1185 ;; 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
|
1186 ;; 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
|
1187 ;; 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
|
1188 ;; 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
|
1189 ;; 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
|
1190 ;; 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
|
1191 (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
|
1192 (if (stringp colors) |
10022
30e0dc7c07cd
(face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9665
diff
changeset
|
1193 (if (face-color-supported-p frame colors |
30e0dc7c07cd
(face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9665
diff
changeset
|
1194 (eq function 'set-face-background)) |
30e0dc7c07cd
(face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9665
diff
changeset
|
1195 (funcall function face colors frame)) |
5929
2538d44f96d4
(face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents:
5849
diff
changeset
|
1196 (if (eq colors t) |
2538d44f96d4
(face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents:
5849
diff
changeset
|
1197 (invert-face face frame) |
2538d44f96d4
(face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents:
5849
diff
changeset
|
1198 (let (done) |
2538d44f96d4
(face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents:
5849
diff
changeset
|
1199 (while (and colors (not done)) |
10375
8652c7b84a5f
(face-try-color-list): Treat `underline' as valid.
Richard M. Stallman <rms@gnu.org>
parents:
10193
diff
changeset
|
1200 (if (or (memq (car colors) '(t underline)) |
10022
30e0dc7c07cd
(face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9665
diff
changeset
|
1201 (face-color-supported-p frame (car colors) |
30e0dc7c07cd
(face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9665
diff
changeset
|
1202 (eq function 'set-face-background))) |
30e0dc7c07cd
(face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9665
diff
changeset
|
1203 (if (cdr colors) |
30e0dc7c07cd
(face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9665
diff
changeset
|
1204 ;; If there are more colors to try, catch errors |
30e0dc7c07cd
(face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9665
diff
changeset
|
1205 ;; and set `done' if we succeed. |
30e0dc7c07cd
(face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9665
diff
changeset
|
1206 (condition-case nil |
30e0dc7c07cd
(face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9665
diff
changeset
|
1207 (progn |
30e0dc7c07cd
(face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9665
diff
changeset
|
1208 (cond ((eq (car colors) t) |
30e0dc7c07cd
(face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9665
diff
changeset
|
1209 (invert-face face frame)) |
30e0dc7c07cd
(face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9665
diff
changeset
|
1210 ((eq (car colors) 'underline) |
30e0dc7c07cd
(face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9665
diff
changeset
|
1211 (set-face-underline-p face t frame)) |
30e0dc7c07cd
(face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9665
diff
changeset
|
1212 (t |
30e0dc7c07cd
(face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9665
diff
changeset
|
1213 (funcall function face (car colors) frame))) |
30e0dc7c07cd
(face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9665
diff
changeset
|
1214 (setq done t)) |
30e0dc7c07cd
(face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9665
diff
changeset
|
1215 (error nil)) |
30e0dc7c07cd
(face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9665
diff
changeset
|
1216 ;; If this is the last color, let the error get out if it fails. |
30e0dc7c07cd
(face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9665
diff
changeset
|
1217 ;; If it succeeds, we will exit anyway after this iteration. |
30e0dc7c07cd
(face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9665
diff
changeset
|
1218 (cond ((eq (car colors) t) |
30e0dc7c07cd
(face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9665
diff
changeset
|
1219 (invert-face face frame)) |
30e0dc7c07cd
(face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9665
diff
changeset
|
1220 ((eq (car colors) 'underline) |
30e0dc7c07cd
(face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9665
diff
changeset
|
1221 (set-face-underline-p face t frame)) |
30e0dc7c07cd
(face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9665
diff
changeset
|
1222 (t |
30e0dc7c07cd
(face-color-supported-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9665
diff
changeset
|
1223 (funcall function face (car colors) frame))))) |
5929
2538d44f96d4
(face-initialize): Specify default characteristics
Richard M. Stallman <rms@gnu.org>
parents:
5849
diff
changeset
|
1224 (setq colors (cdr colors))))))) |
2764
17c322204ce3
(face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2744
diff
changeset
|
1225 |
17c322204ce3
(face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2744
diff
changeset
|
1226 ;; 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
|
1227 (if (eq (framep (selected-frame)) 'x) |
17c322204ce3
(face-initialize): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2744
diff
changeset
|
1228 (face-initialize)) |
2456 | 1229 |
2715
9caee9338229
* faces.el: Call internal-set-face-1, not internat-set-face-1.
Jim Blandy <jimb@redhat.com>
parents:
2714
diff
changeset
|
1230 (provide 'faces) |
9caee9338229
* faces.el: Call internal-set-face-1, not internat-set-face-1.
Jim Blandy <jimb@redhat.com>
parents:
2714
diff
changeset
|
1231 |
2456 | 1232 ;;; faces.el ends here |