Mercurial > emacs
annotate lisp/faces.el @ 27196:64fe9058e235
(browse-url): Fix case of browse-url-browser-function being an alist.
author | Dave Love <fx@gnu.org> |
---|---|
date | Wed, 05 Jan 2000 15:41:44 +0000 |
parents | 6838a53d4992 |
children | 4a4f7f602836 |
rev | line source |
---|---|
25012 | 1 ;;; faces.el --- Lisp faces |
2456 | 2 |
25688 | 3 ;; Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999 |
25012 | 4 ;; Free Software Foundation, Inc. |
2456 | 5 |
6 ;; This file is part of GNU Emacs. | |
7 | |
8 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
9 ;; it under the terms of the GNU General Public License as published by | |
10 ;; the Free Software Foundation; either version 2, or (at your option) | |
11 ;; any later version. | |
12 | |
13 ;; GNU Emacs is distributed in the hope that it will be useful, | |
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 ;; GNU General Public License for more details. | |
17 | |
18 ;; You should have received a copy of the GNU General Public License | |
14169 | 19 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
20 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
21 ;; Boston, MA 02111-1307, USA. | |
2456 | 22 |
23 ;;; Commentary: | |
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 |
25012 | 28 (require 'custom) |
29 (require 'cl)) | |
2456 | 30 |
25012 | 31 (require 'cus-face) |
2456 | 32 |
2744
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
33 |
25012 | 34 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
35 ;;; Font selection. | |
36 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
2456 | 37 |
25012 | 38 (defgroup font-selection nil |
39 "Influencing face font selection." | |
40 :group 'faces) | |
2456 | 41 |
12562
a9b08e50d6ec
(x-create-frame-with-faces): Set background-mode
Karl Heuer <kwzh@gnu.org>
parents:
12475
diff
changeset
|
42 |
25012 | 43 (defcustom face-font-selection-order |
44 '(:width :height :weight :slant) | |
45 "*A list specifying how face font selection chooses fonts. | |
46 Each of the four symbols `:width', `:height', `:weight', and `:slant' | |
47 must appear once in the list, and the list must not contain any other | |
48 elements. Font selection tries to find a best matching font for | |
49 those face attributes first that appear first in the list. For | |
50 example, if `:slant' appears before `:height', font selection first | |
51 tries to find a font with a suitable slant, even if this results in | |
52 a font height that isn't optimal." | |
53 :tag "Font selection order." | |
54 :group 'font-selection | |
55 :set #'(lambda (symbol value) | |
56 (set-default symbol value) | |
57 (internal-set-font-selection-order value))) | |
17522
209c61e51bd0
(frame-set-background-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
17386
diff
changeset
|
58 |
13725 | 59 |
25012 | 60 (defcustom face-font-family-alternatives |
61 '(("courier" "fixed") | |
62 ("helv" "helvetica" "fixed")) | |
63 "*Alist of alternative font family names. | |
64 Each element has the the form (FAMILY ALTERNATIVE1 ALTERNATIVE2 ...). | |
65 If fonts of family FAMILY can't be loaded, try ALTERNATIVE1, then | |
66 ALTERNATIVE2 etc." | |
67 :tag "Alternative font families to try." | |
68 :group 'font-selection | |
69 :set #'(lambda (symbol value) | |
70 (set-default symbol value) | |
71 (internal-set-alternative-font-family-alist value))) | |
13725 | 72 |
25012 | 73 |
2744
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
74 |
25012 | 75 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
76 ;;; Creation, copying. | |
77 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
2744
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
78 |
3925
f286657c098e
* faces.el (global-face-data): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
3911
diff
changeset
|
79 |
2744
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
80 (defun face-list () |
25012 | 81 "Return a list of all defined face names." |
82 (mapcar #'car face-new-frame-defaults)) | |
83 | |
84 | |
85 ;;; ### If not frame-local initialize by what X resources? | |
86 | |
87 (defun make-face (face &optional no-init-from-resources) | |
88 "Define a new face with name FACE, a symbol. | |
89 NO-INIT-FROM-RESOURCES non-nil means don't initialize frame-local | |
90 variants of FACE from X resources. (X resources recognized are found | |
91 in the global variable `face-x-resources'.) If FACE is already known | |
92 as a face, leave it unmodified. Value is FACE." | |
93 (interactive "SMake face: ") | |
94 (unless (facep face) | |
95 ;; Make frame-local faces (this also makes the global one). | |
96 (dolist (frame (frame-list)) | |
97 (internal-make-lisp-face face frame)) | |
98 ;; Add the face to the face menu. | |
99 (when (fboundp 'facemenu-add-new-face) | |
100 (facemenu-add-new-face face)) | |
101 ;; Define frame-local faces for all frames from X resources. | |
102 (unless no-init-from-resources | |
103 (make-face-x-resource-internal face))) | |
104 face) | |
105 | |
106 | |
107 (defun make-empty-face (face) | |
108 "Define a new, empty face with name FACE. | |
109 If the face already exists, it is left unmodified. Value is FACE." | |
110 (interactive "SMake empty face: ") | |
111 (make-face face 'no-init-from-resources)) | |
112 | |
113 | |
114 (defun copy-face (old-face new-face &optional frame new-frame) | |
115 "Define a face just like OLD-FACE, with name NEW-FACE. | |
116 | |
117 If NEW-FACE already exists as a face, it is modified to be like | |
118 OLD-FACE. If it doesn't already exist, it is created. | |
119 | |
120 If the optional argument FRAME is given as a frame, NEW-FACE is | |
121 changed on FRAME only. | |
122 If FRAME is t, the frame-independent default specification for OLD-FACE | |
123 is copied to NEW-FACE. | |
124 If FRAME is nil, copying is done for the frame-independent defaults | |
125 and for each existing frame. | |
126 | |
127 If the optional fourth argument NEW-FRAME is given, | |
128 copy the information from face OLD-FACE on frame FRAME | |
129 to NEW-FACE on frame NEW-FRAME." | |
130 (let ((inhibit-quit t)) | |
131 (if (null frame) | |
132 (progn | |
133 (dolist (frame (frame-list)) | |
134 (copy-face old-face new-face frame)) | |
135 (copy-face old-face new-face t)) | |
136 (internal-copy-lisp-face old-face new-face frame new-frame)) | |
137 new-face)) | |
138 | |
139 | |
140 | |
141 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
142 ;;; Obsolete functions | |
143 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
144 | |
145 ;; The functions in this section are defined because Lisp packages use | |
146 ;; them, despite the prefix `internal-' suggesting that they are | |
147 ;; private to the face implementation. | |
2744
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
148 |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
149 (defun internal-find-face (name &optional frame) |
25012 | 150 "Retrieve the face named NAME. |
151 Return nil if there is no such face. | |
2744
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
152 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
|
153 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
|
154 If FRAME is the symbol t, then the global, non-frame face is returned. |
25012 | 155 If NAME is already a face, it is simply returned. |
156 | |
157 This function is defined for compatibility with Emacs 20.2. It | |
158 should not be used anymore." | |
159 (facep name)) | |
160 | |
2744
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
161 |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
162 (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
|
163 "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
|
164 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
|
165 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
|
166 If FRAME is the symbol t, then the global, non-frame face is returned. |
25012 | 167 If NAME is already a face, it is simply returned. |
168 | |
169 This function is defined for compatibility with Emacs 20.2. It | |
170 should not be used anymore." | |
2744
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
171 (or (internal-find-face name frame) |
25012 | 172 (check-face name))) |
2744
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
173 |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
174 |
25012 | 175 |
176 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
177 ;;; Predicates, type checks. | |
178 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
179 | |
180 (defun facep (face) | |
181 "Return non-nil if FACE is a face name." | |
182 (internal-lisp-face-p face)) | |
183 | |
184 | |
185 (defun check-face (face) | |
186 "Signal an error if FACE doesn't name a face. | |
187 Value is FACE." | |
188 (unless (facep face) | |
189 (error "Not a face: %s" face)) | |
190 face) | |
2744
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
191 |
f4fc0c4c76f9
Re-arranged stuff to put defsubst accessors at the top
Jim Blandy <jimb@redhat.com>
parents:
2715
diff
changeset
|
192 |
25012 | 193 ;; The ID returned is not to be confused with the internally used IDs |
194 ;; of realized faces. The ID assigned to Lisp faces is used to | |
195 ;; support faces in display table entries. | |
17386
b251c8820860
(make-face): New arg no-resources.
Richard M. Stallman <rms@gnu.org>
parents:
17173
diff
changeset
|
196 |
25012 | 197 (defun face-id (face &optional frame) |
198 "Return the interNal ID of face with name FACE. | |
199 If optional argument FRAME is nil or omitted, use the selected frame." | |
200 (check-face face) | |
201 (get face 'face)) | |
2456 | 202 |
203 | |
204 (defun face-equal (face1 face2 &optional frame) | |
25012 | 205 "Non-nil if faces FACE1 and FACE2 are equal. |
206 Faces are considered equal if all their attributes are equal. | |
207 If the optional argument FRAME is given, report on face FACE in that frame. | |
208 If FRAME is t, report on the defaults for face FACE (for new frames). | |
209 If FRAME is omitted or nil, use the selected frame." | |
210 (internal-lisp-face-equal-p face1 face2 frame)) | |
211 | |
2456 | 212 |
213 (defun face-differs-from-default-p (face &optional frame) | |
25012 | 214 "Non-nil if FACE displays differently from the default face. |
215 If the optional argument FRAME is given, report on face FACE in that frame. | |
216 If FRAME is t, report on the defaults for face FACE (for new frames). | |
217 If FRAME is omitted or nil, use the selected frame. | |
218 A face is considered to be ``the same'' as the default face if it is | |
219 actually specified in the same way (equal attributes) or if it is | |
220 fully-unspecified, and thus inherits the attributes of any face it | |
221 is displayed on top of." | |
25814
34c27e95b254
(face-differs-from-default-p): Compare face
Gerd Moellmann <gerd@gnu.org>
parents:
25688
diff
changeset
|
222 (cond ((eq frame t) (setq frame nil)) |
34c27e95b254
(face-differs-from-default-p): Compare face
Gerd Moellmann <gerd@gnu.org>
parents:
25688
diff
changeset
|
223 ((null frame) (setq frame (selected-frame)))) |
34c27e95b254
(face-differs-from-default-p): Compare face
Gerd Moellmann <gerd@gnu.org>
parents:
25688
diff
changeset
|
224 (let* ((v1 (internal-lisp-face-p face frame)) |
34c27e95b254
(face-differs-from-default-p): Compare face
Gerd Moellmann <gerd@gnu.org>
parents:
25688
diff
changeset
|
225 (n (if v1 (length v1) 0)) |
34c27e95b254
(face-differs-from-default-p): Compare face
Gerd Moellmann <gerd@gnu.org>
parents:
25688
diff
changeset
|
226 (v2 (internal-lisp-face-p 'default frame)) |
34c27e95b254
(face-differs-from-default-p): Compare face
Gerd Moellmann <gerd@gnu.org>
parents:
25688
diff
changeset
|
227 (i 1)) |
34c27e95b254
(face-differs-from-default-p): Compare face
Gerd Moellmann <gerd@gnu.org>
parents:
25688
diff
changeset
|
228 (unless v1 |
34c27e95b254
(face-differs-from-default-p): Compare face
Gerd Moellmann <gerd@gnu.org>
parents:
25688
diff
changeset
|
229 (error "Not a face: %S" face)) |
34c27e95b254
(face-differs-from-default-p): Compare face
Gerd Moellmann <gerd@gnu.org>
parents:
25688
diff
changeset
|
230 (while (and (< i n) |
34c27e95b254
(face-differs-from-default-p): Compare face
Gerd Moellmann <gerd@gnu.org>
parents:
25688
diff
changeset
|
231 (or (eq 'unspecified (aref v1 i)) |
34c27e95b254
(face-differs-from-default-p): Compare face
Gerd Moellmann <gerd@gnu.org>
parents:
25688
diff
changeset
|
232 (equal (aref v1 i) (aref v2 i)))) |
34c27e95b254
(face-differs-from-default-p): Compare face
Gerd Moellmann <gerd@gnu.org>
parents:
25688
diff
changeset
|
233 (setq i (1+ i))) |
34c27e95b254
(face-differs-from-default-p): Compare face
Gerd Moellmann <gerd@gnu.org>
parents:
25688
diff
changeset
|
234 (< i n))) |
10379
f9d713e8c77c
(face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10375
diff
changeset
|
235 |
2456 | 236 |
10379
f9d713e8c77c
(face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10375
diff
changeset
|
237 (defun face-nontrivial-p (face &optional frame) |
f9d713e8c77c
(face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10375
diff
changeset
|
238 "True if face FACE has some non-nil attribute. |
25012 | 239 If the optional argument FRAME is given, report on face FACE in that frame. |
240 If FRAME is t, report on the defaults for face FACE (for new frames). | |
241 If FRAME is omitted or nil, use the selected frame." | |
242 (not (internal-lisp-face-empty-p face frame))) | |
243 | |
244 | |
245 | |
246 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
247 ;;; Setting face attributes from X resources. | |
248 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
249 | |
250 (defcustom face-x-resources | |
251 '((:family (".attributeFamily" . "Face.AttributeFamily")) | |
252 (:width (".attributeWidth" . "Face.AttributeWidth")) | |
253 (:height (".attributeHeight" . "Face.AttributeHeight")) | |
254 (:weight (".attributeWeight" . "Face.AttributeWeight")) | |
255 (:slant (".attributeSlant" . "Face.AttributeSlant")) | |
256 (:foreground (".attributeForeground" . "Face.AttributeForeground")) | |
257 (:background (".attributeBackground" . "Face.AttributeBackground")) | |
258 (:overline (".attributeOverline" . "Face.AttributeOverline")) | |
259 (:strike-through (".attributeStrikeThrough" . "Face.AttributeStrikeThrough")) | |
260 (:box (".attributeBox" . "Face.AttributeBox")) | |
261 (:underline (".attributeUnderline" . "Face.AttributeUnderline")) | |
262 (:inverse-video (".attributeInverse" . "Face.AttributeInverse")) | |
263 (:stipple | |
264 (".attributeStipple" . "Face.AttributeStipple") | |
265 (".attributeBackgroundPixmap" . "Face.AttributeBackgroundPixmap")) | |
266 (:font (".attributeFont" . "Face.AttributeFont")) | |
267 (:bold (".attributeBold" . "Face.AttributeBold")) | |
268 (:italic (".attributeItalic" . "Face.AttributeItalic")) | |
269 (:font (".attributeFont" . "Face.AttributeFont"))) | |
270 "*List of X resources and classes for face attributes. | |
271 Each element has the form (ATTRIBUTE ENTRY1 ENTRY2...) where ATTRIBUTE is | |
272 the name of a face attribute, and each ENTRY is a cons of the form | |
273 (RESOURCE . CLASS) with RESOURCE being the resource and CLASS being the | |
274 X resource class for the attribute." | |
275 :type 'sexp | |
276 :group 'faces) | |
277 | |
278 | |
279 (defun set-face-attribute-from-resource (face attribute resource class frame) | |
280 "Set FACE's ATTRIBUTE from X resource RESOURCE, class CLASS on FRAME. | |
281 Value is the attribute value specified by the resource, or nil | |
282 if not present. This function displays a message if the resource | |
283 specifies an invalid attribute." | |
284 (let* ((face-name (face-name face)) | |
285 (value (internal-face-x-get-resource (concat face-name resource) | |
286 class frame))) | |
287 (when value | |
288 (condition-case () | |
289 (internal-set-lisp-face-attribute-from-resource | |
290 face attribute (downcase value) frame) | |
291 (error | |
292 (message "Face %s, frame %s: invalid attribute %s %s from X resource" | |
293 face-name frame attribute value)))) | |
294 value)) | |
295 | |
296 | |
297 (defun set-face-attributes-from-resources (face frame) | |
298 "Set attributes of FACE from X resources for FRAME." | |
299 (when (memq (framep frame) '(x w32)) | |
300 (dolist (definition face-x-resources) | |
301 (let ((attribute (car definition))) | |
302 (dolist (entry (cdr definition)) | |
303 (set-face-attribute-from-resource face attribute (car entry) | |
304 (cdr entry) frame)))))) | |
305 | |
306 | |
307 (defun make-face-x-resource-internal (face &optional frame) | |
308 "Fill frame-local FACE on FRAME from X resources. | |
309 FRAME nil or not specified means do it for all frames." | |
310 (if (null frame) | |
311 (dolist (frame (frame-list)) | |
312 (set-face-attributes-from-resources face frame)) | |
313 (set-face-attributes-from-resources face frame))) | |
314 | |
315 | |
316 | |
317 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
318 ;;; Retrieving face attributes. | |
319 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
320 | |
321 (defun face-name (face) | |
322 "Return the name of face FACE." | |
323 (symbol-name (check-face face))) | |
324 | |
325 | |
326 (defun face-attribute (face attribute &optional frame) | |
327 "Return the value of FACE's ATTRIBUTE on FRAME. | |
328 If the optional argument FRAME is given, report on face FACE in that frame. | |
329 If FRAME is t, report on the defaults for face FACE (for new frames). | |
330 If FRAME is omitted or nil, use the selected frame." | |
331 (internal-get-lisp-face-attribute face attribute frame)) | |
332 | |
333 | |
334 (defun face-foreground (face &optional frame) | |
335 "Return the foreground color name of FACE, or nil if unspecified. | |
336 If the optional argument FRAME is given, report on face FACE in that frame. | |
337 If FRAME is t, report on the defaults for face FACE (for new frames). | |
338 If FRAME is omitted or nil, use the selected frame." | |
339 (internal-get-lisp-face-attribute face :foreground frame)) | |
340 | |
341 | |
342 (defun face-background (face &optional frame) | |
343 "Return the background color name of FACE, or nil if unspecified. | |
344 If the optional argument FRAME is given, report on face FACE in that frame. | |
345 If FRAME is t, report on the defaults for face FACE (for new frames). | |
346 If FRAME is omitted or nil, use the selected frame." | |
347 (internal-get-lisp-face-attribute face :background frame)) | |
348 | |
349 | |
350 (defun face-stipple (face &optional frame) | |
351 "Return the stipple pixmap name of FACE, or nil if unspecified. | |
352 If the optional argument FRAME is given, report on face FACE in that frame. | |
353 If FRAME is t, report on the defaults for face FACE (for new frames). | |
354 If FRAME is omitted or nil, use the selected frame." | |
355 (internal-get-lisp-face-attribute face :stipple frame)) | |
356 | |
357 | |
358 (defalias 'face-background-pixmap 'face-stipple) | |
359 | |
360 | |
361 (defun face-underline-p (face &optional frame) | |
362 "Return non-nil if FACE is underlined. | |
363 If the optional argument FRAME is given, report on face FACE in that frame. | |
364 If FRAME is t, report on the defaults for face FACE (for new frames). | |
365 If FRAME is omitted or nil, use the selected frame." | |
366 (eq (face-attribute face :underline frame) t)) | |
367 | |
368 | |
369 (defun face-inverse-video-p (face &optional frame) | |
370 "Return non-nil if FACE is in inverse video on FRAME. | |
371 If the optional argument FRAME is given, report on face FACE in that frame. | |
372 If FRAME is t, report on the defaults for face FACE (for new frames). | |
373 If FRAME is omitted or nil, use the selected frame." | |
374 (eq (face-attribute face :inverse-video frame) t)) | |
375 | |
376 | |
377 (defun face-bold-p (face &optional frame) | |
378 "Return non-nil if the font of FACE is bold on FRAME. | |
379 If the optional argument FRAME is given, report on face FACE in that frame. | |
380 If FRAME is t, report on the defaults for face FACE (for new frames). | |
381 If FRAME is omitted or nil, use the selected frame. | |
382 Use `face-attribute' for finer control." | |
383 (let ((bold (face-attribute face :weight frame))) | |
25561
67c224f5cc1a
(face-bold-p): Don't return t if face has lighter
Gerd Moellmann <gerd@gnu.org>
parents:
25545
diff
changeset
|
384 (memq bold '(semi-bold bold extra-bold ultra-bold)))) |
25012 | 385 |
386 | |
387 (defun face-italic-p (face &optional frame) | |
388 "Return non-nil if the font of FACE is italic on FRAME. | |
389 If the optional argument FRAME is given, report on face FACE in that frame. | |
390 If FRAME is t, report on the defaults for face FACE (for new frames). | |
391 If FRAME is omitted or nil, use the selected frame. | |
392 Use `face-attribute' for finer control." | |
393 (let ((italic (face-attribute face :slant frame))) | |
25616
4dbea85f5af0
(face-italic-p): Return t only for values `italic'
Gerd Moellmann <gerd@gnu.org>
parents:
25588
diff
changeset
|
394 (memq italic '(italic oblique)))) |
25012 | 395 |
396 | |
397 | |
398 | |
399 | |
400 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
401 ;;; Face documentation. | |
402 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
403 | |
404 (defun face-documentation (face) | |
405 "Get the documentation string for FACE." | |
406 (get face 'face-documentation)) | |
407 | |
408 | |
409 (defun set-face-documentation (face string) | |
410 "Set the documentation string for FACE to STRING." | |
26927
27d6c0e07ea8
(set-face-attribute): Purecopy the attributes set.
Dave Love <fx@gnu.org>
parents:
26902
diff
changeset
|
411 ;; Perhaps the text should go in DOC. |
26657
b5c0d55411ad
(set-face-documentation): Purecopy STRING.
Dave Love <fx@gnu.org>
parents:
26353
diff
changeset
|
412 (put face 'face-documentation (purecopy string))) |
25012 | 413 |
414 | |
415 (defalias 'face-doc-string 'face-documentation) | |
416 (defalias 'set-face-doc-string 'set-face-documentation) | |
417 | |
418 | |
419 | |
420 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
421 ;; Setting face attributes. | |
422 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
423 | |
424 | |
425 (defun set-face-attribute (face frame &rest args) | |
426 "Set attributes of FACE on FRAME from ARGS. | |
427 | |
428 FRAME nil means change attributes on all frames. FRAME t means change | |
429 the default for new frames (this is done automatically each time an | |
430 attribute is changed on all frames). | |
431 | |
432 ARGS must come in pairs ATTRIBUTE VALUE. ATTRIBUTE must be a valid | |
433 face attribute name. All attributes can be set to `unspecified'; | |
434 this fact is not further mentioned below. | |
435 | |
436 The following attributes are recognized: | |
437 | |
438 `:family' | |
439 | |
440 VALUE must be a string specifying the font family, e.g. ``courier'', | |
441 or a fontset alias name. If a font family is specified, wild-cards `*' | |
442 and `?' are allowed. | |
443 | |
444 `:width' | |
445 | |
446 VALUE specifies the relative proportionate width of the font to use. | |
447 It must be one of the symbols `ultra-condensed', `extra-condensed', | |
448 `condensed', `semi-condensed', `normal', `semi-expanded', `expanded', | |
449 `extra-expanded', or `ultra-expanded'. | |
450 | |
451 `:height' | |
452 | |
453 VALUE must be an integer specifying the height of the font to use in | |
454 1/10 pt. | |
455 | |
456 `:weight' | |
457 | |
458 VALUE specifies the weight of the font to use. It must be one of the | |
459 symbols `ultra-bold', `extra-bold', `bold', `semi-bold', `normal', | |
460 `semi-light', `light', `extra-light', `ultra-light'. | |
461 | |
462 `:slant' | |
463 | |
464 VALUE specifies the slant of the font to use. It must be one of the | |
465 symbols `italic', `oblique', `normal', `reverse-italic', or | |
466 `reverse-oblique'. | |
467 | |
468 `:foreground', `:background' | |
469 | |
470 VALUE must be a color name, a string. | |
471 | |
472 `:underline' | |
473 | |
474 VALUE specifies whether characters in FACE should be underlined. If | |
475 VALUE is t, underline with foreground color of the face. If VALUE is | |
476 a string, underline with that color. If VALUE is nil, explicitly | |
477 don't underline. | |
478 | |
479 `:overline' | |
480 | |
481 VALUE specifies whether characters in FACE should be overlined. If | |
482 VALUE is t, overline with foreground color of the face. If VALUE is a | |
483 string, overline with that color. If VALUE is nil, explicitly don't | |
484 overline. | |
485 | |
486 `:strike-through' | |
487 | |
488 VALUE specifies whether characters in FACE should be drawn with a line | |
489 striking through them. If VALUE is t, use the foreground color of the | |
490 face. If VALUE is a string, strike-through with that color. If VALUE | |
491 is nil, explicitly don't strike through. | |
492 | |
493 `:box' | |
494 | |
495 VALUE specifies whether characters in FACE should have a box drawn | |
496 around them. If VALUE is nil, explicitly don't draw boxes. If | |
497 VALUE is t, draw a box with lines of width 1 in the foreground color | |
498 of the face. If VALUE is a string, the string must be a color name, | |
499 and the box is drawn in that color with a line width of 1. Otherwise, | |
500 VALUE must be a property list of the form `(:line-width WIDTH | |
501 :color COLOR :style STYLE)'. If a keyword/value pair is missing from | |
502 the property list, a default value will be used for the value, as | |
503 specified below. WIDTH specifies the width of the lines to draw; it | |
504 defaults to 1. COLOR is the name of the color to draw in, default is | |
505 the foreground color of the face for simple boxes, and the background | |
506 color of the face for 3D boxes. STYLE specifies whether a 3D box | |
507 should be draw. If STYLE is `released-button', draw a box looking | |
508 like a released 3D button. If STYLE is `pressed-button' draw a box | |
509 that appears like a pressed button. If STYLE is nil, the default if | |
510 the property list doesn't contain a style specification, draw a 2D | |
511 box. | |
512 | |
513 `:inverse-video' | |
514 | |
515 VALUE specifies whether characters in FACE should be displayed in | |
516 inverse video. VALUE must be one of t or nil. | |
517 | |
518 `:stipple' | |
519 | |
520 If VALUE is a string, it must be the name of a file of pixmap data. | |
521 The directories listed in the `x-bitmap-file-path' variable are | |
522 searched. Alternatively, VALUE may be a list of the form (WIDTH | |
523 HEIGHT DATA) where WIDTH and HEIGHT are the size in pixels, and DATA | |
524 is a string containing the raw bits of the bitmap. VALUE nil means | |
525 explicitly don't use a stipple pattern. | |
526 | |
527 For convenience, attributes `:family', `:width', `:height', `:weight', | |
528 and `:slant' may also be set in one step from an X font name: | |
529 | |
530 `:font' | |
531 | |
532 Set font-related face attributes from VALUE. VALUE must be a valid | |
533 XLFD font name. If it is a font name pattern, the first matching font | |
534 will be used. | |
535 | |
536 For compatibility with Emacs 20, keywords `:bold' and `:italic' can | |
537 be used to specify that a bold or italic font should be used. VALUE | |
538 must be t or nil in that case. A value of `unspecified' is not allowed." | |
539 (cond ((null frame) | |
540 ;; Change face on all frames. | |
541 (dolist (frame (frame-list)) | |
542 (apply #'set-face-attribute face frame args)) | |
543 ;; Record that as a default for new frames. | |
544 (apply #'set-face-attribute face t args)) | |
545 (t | |
546 (while args | |
547 (internal-set-lisp-face-attribute face (car args) | |
26927
27d6c0e07ea8
(set-face-attribute): Purecopy the attributes set.
Dave Love <fx@gnu.org>
parents:
26902
diff
changeset
|
548 (purecopy (cadr args)) |
27d6c0e07ea8
(set-face-attribute): Purecopy the attributes set.
Dave Love <fx@gnu.org>
parents:
26902
diff
changeset
|
549 frame) |
25012 | 550 (setq args (cdr (cdr args))))))) |
551 | |
552 | |
26337
6bf33b333eb2
(make-face-bold, make-face-unbold, make-face-italic)
Gerd Moellmann <gerd@gnu.org>
parents:
25947
diff
changeset
|
553 (defun make-face-bold (face &optional frame noerror) |
25012 | 554 "Make the font of FACE be bold, if possible. |
555 FRAME nil or not specified means change face on all frames. | |
26337
6bf33b333eb2
(make-face-bold, make-face-unbold, make-face-italic)
Gerd Moellmann <gerd@gnu.org>
parents:
25947
diff
changeset
|
556 Argument NOERROR is ignored and retained for compatibility. |
25012 | 557 Use `set-face-attribute' for finer control of the font weight." |
558 (interactive (list (read-face-name "Make which face bold: "))) | |
559 (set-face-attribute face frame :weight 'bold)) | |
560 | |
561 | |
26337
6bf33b333eb2
(make-face-bold, make-face-unbold, make-face-italic)
Gerd Moellmann <gerd@gnu.org>
parents:
25947
diff
changeset
|
562 (defun make-face-unbold (face &optional frame noerror) |
25012 | 563 "Make the font of FACE be non-bold, if possible. |
26337
6bf33b333eb2
(make-face-bold, make-face-unbold, make-face-italic)
Gerd Moellmann <gerd@gnu.org>
parents:
25947
diff
changeset
|
564 FRAME nil or not specified means change face on all frames. |
6bf33b333eb2
(make-face-bold, make-face-unbold, make-face-italic)
Gerd Moellmann <gerd@gnu.org>
parents:
25947
diff
changeset
|
565 Argument NOERROR is ignored and retained for compatibility." |
25012 | 566 (interactive (list (read-face-name "Make which face non-bold: "))) |
567 (set-face-attribute face frame :weight 'normal)) | |
568 | |
569 | |
26337
6bf33b333eb2
(make-face-bold, make-face-unbold, make-face-italic)
Gerd Moellmann <gerd@gnu.org>
parents:
25947
diff
changeset
|
570 (defun make-face-italic (face &optional frame noerror) |
25012 | 571 "Make the font of FACE be italic, if possible. |
572 FRAME nil or not specified means change face on all frames. | |
26337
6bf33b333eb2
(make-face-bold, make-face-unbold, make-face-italic)
Gerd Moellmann <gerd@gnu.org>
parents:
25947
diff
changeset
|
573 Argument NOERROR is ignored and retained for compatibility. |
25012 | 574 Use `set-face-attribute' for finer control of the font slant." |
575 (interactive (list (read-face-name "Make which face italic: "))) | |
576 (set-face-attribute face frame :slant 'italic)) | |
577 | |
578 | |
26337
6bf33b333eb2
(make-face-bold, make-face-unbold, make-face-italic)
Gerd Moellmann <gerd@gnu.org>
parents:
25947
diff
changeset
|
579 (defun make-face-unitalic (face &optional frame noerror) |
25012 | 580 "Make the font of FACE be non-italic, if possible. |
581 FRAME nil or not specified means change face on all frames." | |
582 (interactive (list (read-face-name "Make which face non-italic: "))) | |
583 (set-face-attribute face frame :slant 'normal)) | |
584 | |
585 | |
26337
6bf33b333eb2
(make-face-bold, make-face-unbold, make-face-italic)
Gerd Moellmann <gerd@gnu.org>
parents:
25947
diff
changeset
|
586 (defun make-face-bold-italic (face &optional frame noerror) |
25012 | 587 "Make the font of FACE be bold and italic, if possible. |
588 FRAME nil or not specified means change face on all frames. | |
26337
6bf33b333eb2
(make-face-bold, make-face-unbold, make-face-italic)
Gerd Moellmann <gerd@gnu.org>
parents:
25947
diff
changeset
|
589 Argument NOERROR is ignored and retained for compatibility. |
25012 | 590 Use `set-face-attribute' for finer control of font weight and slant." |
591 (interactive (list (read-face-name "Make which face bold-italic: "))) | |
592 (set-face-attribute face frame :weight 'bold :slant 'italic)) | |
593 | |
594 | |
595 (defun set-face-font (face font &optional frame) | |
596 "Change font-related attributes of FACE to those of FONT (a string). | |
597 FRAME nil or not specified means change face on all frames. | |
598 This sets the attributes `:family', `:width', `:height', `:weight', | |
599 and `:slant'. When called interactively, prompt for the face and font." | |
600 (interactive (read-face-and-attribute :font)) | |
601 (set-face-attribute face frame :font font)) | |
602 | |
603 | |
604 ;; Implementation note: Emulating gray background colors with a | |
605 ;; stipple pattern is now part of the face realization process, and is | |
606 ;; done in C depending on the frame on which the face is realized. | |
607 | |
608 (defun set-face-background (face color &optional frame) | |
609 "Change the background color of face FACE to COLOR (a string). | |
610 FRAME nil or not specified means change face on all frames. | |
611 When called interactively, prompt for the face and color." | |
612 (interactive (read-face-and-attribute :background)) | |
613 (set-face-attribute face frame :background color)) | |
614 | |
615 | |
616 (defun set-face-foreground (face color &optional frame) | |
617 "Change the foreground color of face FACE to COLOR (a string). | |
618 FRAME nil or not specified means change face on all frames. | |
619 When called interactively, prompt for the face and color." | |
620 (interactive (read-face-and-attribute :foreground)) | |
621 (set-face-attribute face frame :foreground color)) | |
622 | |
623 | |
624 (defun set-face-stipple (face stipple &optional frame) | |
625 "Change the stipple pixmap of face FACE to STIPPLE. | |
626 FRAME nil or not specified means change face on all frames. | |
627 STIPPLE. should be a string, the name of a file of pixmap data. | |
628 The directories listed in the `x-bitmap-file-path' variable are searched. | |
629 | |
630 Alternatively, STIPPLE may be a list of the form (WIDTH HEIGHT DATA) | |
631 where WIDTH and HEIGHT are the size in pixels, | |
632 and DATA is a string, containing the raw bits of the bitmap." | |
633 (interactive (read-face-and-attribute :stipple)) | |
634 (set-face-attribute face frame :stipple stipple)) | |
635 | |
636 | |
637 (defun set-face-underline (face underline &optional frame) | |
638 "Specify whether face FACE is underlined. | |
639 UNDERLINE nil means FACE explicitly doesn't underline. | |
640 UNDERLINE non-nil means FACE explicitly does underlining | |
641 with the same of the foreground color. | |
642 If UNDERLINE is a string, underline with the color named UNDERLINE. | |
643 FRAME nil or not specified means change face on all frames. | |
644 Use `set-face-attribute' to ``unspecify'' underlining." | |
645 (interactive | |
646 (let ((list (read-face-and-attribute :underline))) | |
647 (list (car list) (eq (car (cdr list)) t)))) | |
648 (set-face-attribute face frame :underline underline)) | |
649 | |
650 | |
651 (defun set-face-underline-p (face underline-p &optional frame) | |
652 "Specify whether face FACE is underlined. | |
653 UNDERLINE-P nil means FACE explicitly doesn't underline. | |
654 UNDERLINE-P non-nil means FACE explicitly does underlining. | |
655 FRAME nil or not specified means change face on all frames. | |
656 Use `set-face-attribute' to ``unspecify'' underlining." | |
657 (interactive | |
658 (let ((list (read-face-and-attribute :underline))) | |
659 (list (car list) (eq (car (cdr list)) t)))) | |
660 (set-face-attribute face frame :underline underline-p)) | |
661 | |
662 | |
663 (defun set-face-inverse-video-p (face inverse-video-p &optional frame) | |
664 "Specify whether face FACE is in inverse video. | |
665 INVERSE-VIDEO-P non-nil means FACE displays explicitly in inverse video. | |
666 INVERSE-VIDEO-P nil means FACE explicitly is not in inverse video. | |
667 FRAME nil or not specified means change face on all frames. | |
668 Use `set-face-attribute' to ``unspecify'' the inverse video attribute." | |
669 (interactive | |
670 (let ((list (read-face-and-attribute :inverse-video))) | |
671 (list (car list) (eq (car (cdr list)) t)))) | |
672 (set-face-attribute face frame :inverse-video inverse-video-p)) | |
673 | |
674 | |
675 (defun set-face-bold-p (face bold-p &optional frame) | |
676 "Specify whether face FACE is bold. | |
677 BOLD-P non-nil means FACE should explicitly display bold. | |
678 BOLD-P nil means FACE should explicitly display non-bold. | |
679 FRAME nil or not specified means change face on all frames. | |
680 Use `set-face-attribute' or `modify-face' for finer control." | |
681 (if (null bold-p) | |
682 (make-face-unbold face frame) | |
683 (make-face-bold face frame))) | |
684 | |
685 | |
686 (defun set-face-italic-p (face italic-p &optional frame) | |
687 "Specify whether face FACE is italic. | |
688 ITALIC-P non-nil means FACE should explicitly display italic. | |
689 ITALIC-P nil means FACE should explicitly display non-italic. | |
690 FRAME nil or not specified means change face on all frames. | |
691 Use `set-face-attribute' or `modify-face' for finer control." | |
692 (if (null italic-p) | |
693 (make-face-unitalic face frame) | |
694 (make-face-italic face frame))) | |
695 | |
696 | |
697 (defalias 'set-face-background-pixmap 'set-face-stipple) | |
10379
f9d713e8c77c
(face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10375
diff
changeset
|
698 |
2456 | 699 |
700 (defun invert-face (face &optional frame) | |
25012 | 701 "Swap the foreground and background colors of FACE. |
702 FRAME nil or not specified means change face on all frames. | |
703 If FACE specifies neither foreground nor background color, | |
704 set its foreground and background to the background and foreground | |
705 of the default face. Value is FACE." | |
2456 | 706 (interactive (list (read-face-name "Invert face: "))) |
25012 | 707 (let ((fg (face-attribute face :foreground frame)) |
708 (bg (face-attribute face :background frame))) | |
2456 | 709 (if (or fg bg) |
25012 | 710 (set-face-attribute face frame :foreground bg :background fg) |
711 (set-face-attribute face frame | |
712 :foreground | |
713 (face-attribute 'default :background frame) | |
714 :background | |
715 (face-attribute 'default :foreground frame)))) | |
2456 | 716 face) |
717 | |
25012 | 718 |
719 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
720 ;;; Interactively modifying faces. | |
721 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
2456 | 722 |
25012 | 723 (defun read-face-name (prompt) |
724 "Read and return a face symbol, prompting with PROMPT. | |
725 Value is a symbol naming a known face." | |
726 (let ((face-list (mapcar #'(lambda (x) (cons (symbol-name x) x)) | |
727 (face-list))) | |
728 face) | |
729 (while (equal "" (setq face (completing-read prompt face-list nil t)))) | |
730 (intern face))) | |
731 | |
732 | |
733 (defun face-valid-attribute-values (attribute &optional frame) | |
734 "Return valid values for face attribute ATTRIBUTE. | |
735 The optional argument FRAME is used to determine available fonts | |
736 and colors. If it is nil or not specified, the selected frame is | |
737 used. Value is an alist of (NAME . VALUE) if ATTRIBUTE expects a value | |
738 out of a set of discrete values. Value is `integerp' if ATTRIBUTE expects | |
739 an integer value." | |
25245
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
740 (let (valid) |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
741 (setq valid |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
742 (case attribute |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
743 (:family |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
744 (if window-system |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
745 (mapcar #'(lambda (x) (cons (car x) (car x))) |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
746 (x-font-family-list)) |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
747 ;; Only one font on TTYs. |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
748 (list (cons "default" "default")))) |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
749 ((:width :weight :slant :inverse-video) |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
750 (mapcar #'(lambda (x) (cons (symbol-name x) x)) |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
751 (internal-lisp-face-attribute-values attribute))) |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
752 ((:underline :overline :strike-through :box) |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
753 (if window-system |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
754 (nconc (mapcar #'(lambda (x) (cons (symbol-name x) x)) |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
755 (internal-lisp-face-attribute-values attribute)) |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
756 (mapcar #'(lambda (c) (cons c c)) |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
757 (x-defined-colors frame))) |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
758 (mapcar #'(lambda (x) (cons (symbol-name x) x)) |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
759 (internal-lisp-face-attribute-values attribute)))) |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
760 ((:foreground :background) |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
761 (mapcar #'(lambda (c) (cons c c)) |
26736
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26657
diff
changeset
|
762 (defined-colors frame))) |
25245
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
763 ((:height) |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
764 'integerp) |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
765 (:stipple |
25265
3aba9b200c5f
(face-valid-attribute-values): Look in
Eli Zaretskii <eliz@gnu.org>
parents:
25245
diff
changeset
|
766 (and (memq window-system '(x w32)) |
25245
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
767 (mapcar #'list |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
768 (apply #'nconc (mapcar #'directory-files |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
769 x-bitmap-file-path))))) |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
770 (t |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
771 (error "Internal error")))) |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
772 (if (listp valid) |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
773 (nconc (list (cons "unspecified" 'unspecified)) valid) |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
774 valid))) |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
775 |
25012 | 776 |
777 | |
778 (defvar face-attribute-name-alist | |
779 '((:family . "font family") | |
780 (:width . "character set width") | |
781 (:height . "height in 1/10 pt") | |
782 (:weight . "weight") | |
783 (:slant . "slant") | |
784 (:underline . "underline") | |
785 (:overline . "overline") | |
786 (:strike-through . "strike-through") | |
787 (:box . "box") | |
788 (:inverse-video . "inverse-video display") | |
789 (:foreground . "foreground color") | |
790 (:background . "background color") | |
791 (:stipple . "background stipple")) | |
792 "An alist of descriptive names for face attributes. | |
793 Each element has the form (ATTRIBUTE-NAME . DESCRIPTION) where | |
794 ATTRIBUTE-NAME is a face attribute name (a keyword symbol), and | |
795 DESCRIPTION is a descriptive name for ATTRIBUTE-NAME.") | |
796 | |
797 | |
798 (defun face-descriptive-attribute-name (attribute) | |
799 "Return a descriptive name for ATTRIBUTE." | |
800 (cdr (assq attribute face-attribute-name-alist))) | |
801 | |
802 | |
803 (defun face-read-string (face default name &optional completion-alist) | |
804 "Interactively read a face attribute string value. | |
805 FACE is the face whose attribute is read. DEFAULT is the default | |
806 value to return if no new value is entered. NAME is a descriptive | |
807 name of the attribute for prompting. COMPLETION-ALIST is an alist | |
808 of valid values, if non-nil. | |
809 | |
25245
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
810 Entering nothing accepts the default value DEFAULT. |
25012 | 811 Value is the new attribute value." |
812 (let* ((completion-ignore-case t) | |
813 (value (completing-read | |
814 (if default | |
815 (format "Set face %s %s (default %s): " | |
816 face name (downcase (if (symbolp default) | |
817 (symbol-name default) | |
818 default))) | |
819 (format "Set face %s %s: " face name)) | |
820 completion-alist))) | |
25245
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
821 (if (equal value "") default value))) |
25012 | 822 |
823 | |
824 (defun face-read-integer (face default name) | |
825 "Interactively read an integer face attribute value. | |
826 FACE is the face whose attribute is read. DEFAULT is the default | |
827 value to return if no new value is entered. NAME is a descriptive | |
828 name of the attribute for prompting. Value is the new attribute value." | |
25245
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
829 (let ((new-value |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
830 (face-read-string face |
27117
6838a53d4992
(face-read-integer, read-face-attribute)
Eli Zaretskii <eliz@gnu.org>
parents:
27090
diff
changeset
|
831 (if (memq default |
6838a53d4992
(face-read-integer, read-face-attribute)
Eli Zaretskii <eliz@gnu.org>
parents:
27090
diff
changeset
|
832 '(unspecified |
6838a53d4992
(face-read-integer, read-face-attribute)
Eli Zaretskii <eliz@gnu.org>
parents:
27090
diff
changeset
|
833 "unspecified-fg" |
6838a53d4992
(face-read-integer, read-face-attribute)
Eli Zaretskii <eliz@gnu.org>
parents:
27090
diff
changeset
|
834 "unspecified-bg")) |
26902
264b83a3a688
Changes for separate unspecified foreground and background colors
Eli Zaretskii <eliz@gnu.org>
parents:
26736
diff
changeset
|
835 default |
25245
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
836 (int-to-string default)) |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
837 name |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
838 (list (cons "unspecified" 'unspecified))))) |
27117
6838a53d4992
(face-read-integer, read-face-attribute)
Eli Zaretskii <eliz@gnu.org>
parents:
27090
diff
changeset
|
839 (if (memq new-value '(unspecified "unspecified-fg" "unspecified-bg")) |
25245
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
840 new-value |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
841 (string-to-int new-value)))) |
25012 | 842 |
843 | |
844 (defun read-face-attribute (face attribute &optional frame) | |
845 "Interactively read a new value for FACE's ATTRIBUTE. | |
846 Optional argument FRAME nil or unspecified means read an attribute value | |
847 of a global face. Value is the new attribute value." | |
848 (let* ((old-value (face-attribute face attribute frame)) | |
849 (attribute-name (face-descriptive-attribute-name attribute)) | |
850 (valid (face-valid-attribute-values attribute frame)) | |
851 new-value) | |
852 ;; Represent complex attribute values as strings by printing them | |
853 ;; out. Stipple can be a vector; (WIDTH HEIGHT DATA). Box can be | |
854 ;; a list `(:width WIDTH :color COLOR)' or `(:width WIDTH :shadow | |
855 ;; SHADOW)'. | |
856 (when (and (or (eq attribute :stipple) | |
857 (eq attribute :box)) | |
858 (or (consp old-value) | |
859 (vectorp old-value))) | |
860 (setq old-value (prin1-to-string old-value))) | |
861 (cond ((listp valid) | |
862 (setq new-value | |
25245
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
863 (face-read-string face old-value attribute-name valid)) |
26736
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26657
diff
changeset
|
864 ;; Terminal frames can support colors that don't appear |
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26657
diff
changeset
|
865 ;; explicitly in VALID, using color approximation code |
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26657
diff
changeset
|
866 ;; in tty-colors.el. |
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26657
diff
changeset
|
867 (if (and (memq attribute '(:foreground :background)) |
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26657
diff
changeset
|
868 (not (memq window-system '(x w32 mac))) |
26902
264b83a3a688
Changes for separate unspecified foreground and background colors
Eli Zaretskii <eliz@gnu.org>
parents:
26736
diff
changeset
|
869 (not (memq new-value |
27117
6838a53d4992
(face-read-integer, read-face-attribute)
Eli Zaretskii <eliz@gnu.org>
parents:
27090
diff
changeset
|
870 '(unspecified |
6838a53d4992
(face-read-integer, read-face-attribute)
Eli Zaretskii <eliz@gnu.org>
parents:
27090
diff
changeset
|
871 "unspecified-fg" |
6838a53d4992
(face-read-integer, read-face-attribute)
Eli Zaretskii <eliz@gnu.org>
parents:
27090
diff
changeset
|
872 "unspecified-bg")))) |
27090
52e469fb402a
(read-face-attribute, defined-colors, color-defined-p):
Eli Zaretskii <eliz@gnu.org>
parents:
26927
diff
changeset
|
873 (setq new-value (car (tty-color-desc new-value frame)))) |
25245
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
874 (unless (eq new-value 'unspecified) |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
875 (setq new-value (cdr (assoc new-value valid))))) |
25012 | 876 ((eq valid 'integerp) |
877 (setq new-value (face-read-integer face old-value attribute-name))) | |
878 (t (error "Internal error"))) | |
879 ;; Convert stipple and box value text we read back to a list or | |
880 ;; vector if it looks like one. This makes the assumption that a | |
881 ;; pixmap file name won't start with an open-paren. | |
882 (when (and (or (eq attribute :stipple) | |
883 (eq attribute :box)) | |
884 (stringp new-value) | |
885 (string-match "^[[(]" new-value)) | |
886 (setq new-value (read new-value))) | |
887 new-value)) | |
888 | |
889 | |
890 (defun read-face-font (face &optional frame) | |
891 "Read the name of a font for FACE on FRAME. | |
892 If optional argument FRAME Is nil or omitted, use the selected frame." | |
893 (let ((completion-ignore-case t)) | |
894 (completing-read "Set font attributes of face %s from font: " | |
895 face (x-list-fonts "*" nil frame)))) | |
896 | |
897 | |
898 (defun read-all-face-attributes (face &optional frame) | |
899 "Interactively read all attributes for FACE. | |
900 If optional argument FRAME Is nil or omitted, use the selected frame. | |
901 Value is a property list of attribute names and new values." | |
902 (let (result) | |
903 (dolist (attribute face-attribute-name-alist result) | |
904 (setq result (cons (car attribute) | |
905 (cons (read-face-attribute face (car attribute) frame) | |
906 result)))))) | |
907 | |
908 | |
909 (defun modify-face (&optional frame) | |
910 "Modify attributes of faces interactively. | |
911 If optional argument FRAME is nil or omitted, modify the face used | |
912 for newly created frame, i.e. the global face." | |
913 (interactive) | |
914 (let ((face (read-face-name "Modify face: "))) | |
915 (apply #'set-face-attribute face frame | |
916 (read-all-face-attributes face frame)))) | |
917 | |
918 | |
919 (defun read-face-and-attribute (attribute &optional frame) | |
920 "Read face name and face attribute value. | |
921 ATTRIBUTE is the attribute whose new value is read. | |
922 FRAME nil or unspecified means read attribute value of global face. | |
923 Value is a list (FACE NEW-VALUE) where FACE is the face read | |
924 (a symbol), and NEW-VALUE is value read." | |
925 (cond ((eq attribute :font) | |
926 (let* ((prompt (format "Set font-related attributes of face: ")) | |
927 (face (read-face-name prompt)) | |
928 (font (read-face-font face frame))) | |
929 (list face font))) | |
930 (t | |
931 (let* ((attribute-name (face-descriptive-attribute-name attribute)) | |
932 (prompt (format "Set %s of face: " attribute-name)) | |
933 (face (read-face-name prompt)) | |
934 (new-value (read-face-attribute face attribute frame))) | |
935 (list face new-value))))) | |
936 | |
937 | |
938 | |
939 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
940 ;;; Listing faces. | |
941 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
942 | |
943 (defvar list-faces-sample-text | |
944 "abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ" | |
945 "*Text string to display as the sample text for `list-faces-display'.") | |
946 | |
947 | |
948 ;; The name list-faces would be more consistent, but let's avoid a | |
949 ;; conflict with Lucid, which uses that name differently. | |
950 | |
951 (defun list-faces-display () | |
952 "List all faces, using the same sample text in each. | |
953 The sample text is a string that comes from the variable | |
954 `list-faces-sample-text'." | |
955 (interactive) | |
956 (let ((faces (sort (face-list) #'string-lessp)) | |
957 (face nil) | |
958 (frame (selected-frame)) | |
959 disp-frame window) | |
960 (with-output-to-temp-buffer "*Faces*" | |
961 (save-excursion | |
962 (set-buffer standard-output) | |
963 (setq truncate-lines t) | |
964 (while faces | |
965 (setq face (car faces)) | |
966 (setq faces (cdr faces)) | |
967 (insert (format "%25s " (face-name face))) | |
968 (let ((beg (point))) | |
969 (insert list-faces-sample-text) | |
970 (insert "\n") | |
971 (put-text-property beg (1- (point)) 'face face) | |
972 ;; If the sample text has multiple lines, line up all of them. | |
973 (goto-char beg) | |
974 (forward-line 1) | |
975 (while (not (eobp)) | |
976 (insert " ") | |
977 (forward-line 1)))) | |
978 (goto-char (point-min))) | |
979 (print-help-return-message)) | |
980 ;; If the *Faces* buffer appears in a different frame, | |
981 ;; copy all the face definitions from FRAME, | |
982 ;; so that the display will reflect the frame that was selected. | |
983 (setq window (get-buffer-window (get-buffer "*Faces*") t)) | |
984 (setq disp-frame (if window (window-frame window) | |
985 (car (frame-list)))) | |
986 (or (eq frame disp-frame) | |
987 (let ((faces (face-list))) | |
988 (while faces | |
989 (copy-face (car faces) (car faces) frame disp-frame) | |
990 (setq faces (cdr faces))))))) | |
991 | |
992 | |
993 (defun describe-face (face &optional frame) | |
994 "Display the properties of face FACE on FRAME. | |
995 If the optional argument FRAME is given, report on face FACE in that frame. | |
996 If FRAME is t, report on the defaults for face FACE (for new frames). | |
997 If FRAME is omitted or nil, use the selected frame." | |
998 (interactive (list (read-face-name "Describe face: "))) | |
999 (let* ((attrs '((:family . "Family") | |
1000 (:width . "Width") | |
1001 (:height . "Height") | |
1002 (:weight . "Weight") | |
1003 (:slant . "Slant") | |
1004 (:foreground . "Foreground") | |
1005 (:background . "Background") | |
1006 (:underline . "Underline") | |
1007 (:overline . "Overline") | |
1008 (:strike-through . "Strike-through") | |
1009 (:box . "Box") | |
1010 (:inverse-video . "Inverse") | |
1011 (:stipple . "Stipple"))) | |
1012 (max-width (apply #'max (mapcar #'(lambda (x) (length (cdr x))) | |
1013 attrs)))) | |
1014 (with-output-to-temp-buffer "*Help*" | |
1015 (save-excursion | |
1016 (set-buffer standard-output) | |
1017 (dolist (a attrs) | |
1018 (let ((attr (face-attribute face (car a) frame))) | |
1019 (insert (make-string (- max-width (length (cdr a))) ?\ ) | |
1020 (cdr a) ": " (format "%s" attr) "\n"))) | |
1021 (insert "\nDocumentation:\n\n" | |
1022 (or (face-documentation face) | |
1023 "not documented as a face."))) | |
1024 (print-help-return-message)))) | |
1025 | |
1026 | |
1027 | |
2456 | 1028 |
25012 | 1029 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1030 ;;; Face specifications (defface). | |
1031 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
1032 | |
1033 ;; Parameter FRAME Is kept for call compatibility to with previous | |
1034 ;; face implementation. | |
1035 | |
1036 (defun face-attr-construct (face &optional frame) | |
1037 "Return a defface-style attribute list for FACE on FRAME. | |
1038 Value is a property list of pairs ATTRIBUTE VALUE for all specified | |
1039 face attributes of FACE where ATTRIBUTE is the attribute name and | |
1040 VALUE is the specified value of that attribute." | |
1041 (let (result) | |
1042 (dolist (entry face-attribute-name-alist result) | |
1043 (let* ((attribute (car entry)) | |
1044 (value (face-attribute face attribute))) | |
1045 (unless (eq value 'unspecified) | |
1046 (setq result (nconc (list attribute value) result))))))) | |
1047 | |
1048 | |
1049 (defun face-spec-set-match-display (display frame) | |
1050 "Non-nil if DISPLAY matches FRAME. | |
1051 DISPLAY is part of a spec such as can be used in `defface'. | |
1052 If FRAME is nil, the current FRAME is used." | |
1053 (let* ((conjuncts display) | |
1054 conjunct req options | |
1055 ;; t means we have succeeded against all the conjuncts in | |
1056 ;; DISPLAY that have been tested so far. | |
1057 (match t)) | |
1058 (if (eq conjuncts t) | |
1059 (setq conjuncts nil)) | |
1060 (while (and conjuncts match) | |
1061 (setq conjunct (car conjuncts) | |
1062 conjuncts (cdr conjuncts) | |
1063 req (car conjunct) | |
1064 options (cdr conjunct) | |
1065 match (cond ((eq req 'type) | |
1066 (or (memq window-system options) | |
1067 (and (null window-system) | |
25887
099a3776ff00
(face-spec-set-match-display): Recognize `type' of
Gerd Moellmann <gerd@gnu.org>
parents:
25814
diff
changeset
|
1068 (memq 'tty options)) |
099a3776ff00
(face-spec-set-match-display): Recognize `type' of
Gerd Moellmann <gerd@gnu.org>
parents:
25814
diff
changeset
|
1069 (and (memq 'motif options) |
099a3776ff00
(face-spec-set-match-display): Recognize `type' of
Gerd Moellmann <gerd@gnu.org>
parents:
25814
diff
changeset
|
1070 (featurep 'motif)) |
099a3776ff00
(face-spec-set-match-display): Recognize `type' of
Gerd Moellmann <gerd@gnu.org>
parents:
25814
diff
changeset
|
1071 (and (memq 'lucid options) |
099a3776ff00
(face-spec-set-match-display): Recognize `type' of
Gerd Moellmann <gerd@gnu.org>
parents:
25814
diff
changeset
|
1072 (featurep 'x-toolkit) |
099a3776ff00
(face-spec-set-match-display): Recognize `type' of
Gerd Moellmann <gerd@gnu.org>
parents:
25814
diff
changeset
|
1073 (not (featurep 'motif))) |
099a3776ff00
(face-spec-set-match-display): Recognize `type' of
Gerd Moellmann <gerd@gnu.org>
parents:
25814
diff
changeset
|
1074 (and (memq 'x-toolkit options) |
099a3776ff00
(face-spec-set-match-display): Recognize `type' of
Gerd Moellmann <gerd@gnu.org>
parents:
25814
diff
changeset
|
1075 (featurep 'x-toolkit)))) |
25012 | 1076 ((eq req 'class) |
1077 (memq (frame-parameter frame 'display-type) options)) | |
1078 ((eq req 'background) | |
1079 (memq (frame-parameter frame 'background-mode) | |
1080 options)) | |
1081 (t (error "Unknown req `%S' with options `%S'" | |
1082 req options))))) | |
1083 match)) | |
1084 | |
1085 | |
1086 (defun face-spec-choose (spec &optional frame) | |
1087 "Choose the proper attributes for FRAME, out of SPEC." | |
1088 (unless frame | |
1089 (setq frame (selected-frame))) | |
1090 (let ((tail spec) | |
1091 result) | |
1092 (while tail | |
1093 (let* ((entry (car tail)) | |
1094 (display (nth 0 entry)) | |
1095 (attrs (nth 1 entry))) | |
1096 (setq tail (cdr tail)) | |
1097 (when (face-spec-set-match-display display frame) | |
1098 (setq result attrs tail nil)))) | |
1099 result)) | |
1100 | |
1101 | |
1102 (defun face-spec-reset-face (face &optional frame) | |
1103 "Reset all attributes of FACE on FRAME to unspecified." | |
1104 (let ((attrs face-attribute-name-alist) | |
1105 params) | |
1106 (while attrs | |
1107 (let ((attr-and-name (car attrs))) | |
1108 (setq params (cons (car attr-and-name) (cons 'unspecified params)))) | |
1109 (setq attrs (cdr attrs))) | |
1110 (apply #'set-face-attribute face frame params))) | |
1111 | |
1112 | |
1113 (defun face-spec-set (face spec &optional frame) | |
1114 "Set FACE's attributes according to the first matching entry in SPEC. | |
1115 FRAME is the frame whose frame-local face is set. FRAME nil means | |
1116 do it on all frames. See `defface' for information about SPEC." | |
1117 (let ((attrs (face-spec-choose spec frame)) | |
1118 params) | |
1119 (while attrs | |
1120 (let ((attribute (car attrs)) | |
1121 (value (car (cdr attrs)))) | |
1122 ;; Support some old-style attribute names and values. | |
1123 (case attribute | |
1124 (:bold (setq attribute :weight value (if value 'bold 'normal))) | |
1125 (:italic (setq attribute :slant value (if value 'italic 'normal)))) | |
1126 (setq params (cons attribute (cons value params)))) | |
1127 (setq attrs (cdr (cdr attrs)))) | |
1128 (face-spec-reset-face face frame) | |
1129 (apply #'set-face-attribute face frame params))) | |
1130 | |
1131 | |
1132 (defun face-attr-match-p (face attrs &optional frame) | |
1133 "Value is non-nil if attributes of FACE match values in plist ATTRS. | |
1134 Optional parameter FRAME is the frame whose definition of FACE | |
1135 is used. If nil or omitted, use the selected frame." | |
1136 (unless frame | |
1137 (setq frame (selected-frame))) | |
1138 (let ((list face-attribute-name-alist) | |
1139 (match t)) | |
1140 (while (and match (not (null list))) | |
1141 (let* ((attr (car (car list))) | |
1142 (specified-value (plist-get attrs attr)) | |
1143 (value-now (face-attribute face attr frame))) | |
1144 (when specified-value | |
1145 (setq match (equal specified-value value-now))) | |
1146 (setq list (cdr list)))) | |
1147 match)) | |
1148 | |
1149 | |
1150 (defun face-spec-match-p (face spec &optional frame) | |
1151 "Return t if FACE, on FRAME, matches what SPEC says it should look like." | |
1152 (face-attr-match-p face (face-spec-choose spec frame) frame)) | |
1153 | |
1154 | |
1155 | |
1156 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
26736
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26657
diff
changeset
|
1157 ;;; Frame-type independent color support. |
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26657
diff
changeset
|
1158 ;;; We keep the old x-* names as aliases for back-compatibility. |
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26657
diff
changeset
|
1159 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26657
diff
changeset
|
1160 |
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26657
diff
changeset
|
1161 (defun defined-colors (&optional frame) |
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26657
diff
changeset
|
1162 "Return a list of colors supported for a particular frame. |
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26657
diff
changeset
|
1163 The argument FRAME specifies which frame to try. |
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26657
diff
changeset
|
1164 The value may be different for frames on different display types. |
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26657
diff
changeset
|
1165 If FRAME doesn't support colors, the value is nil." |
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26657
diff
changeset
|
1166 (if (memq (framep (or frame (selected-frame))) '(x w32)) |
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26657
diff
changeset
|
1167 (xw-defined-colors frame) |
27090
52e469fb402a
(read-face-attribute, defined-colors, color-defined-p):
Eli Zaretskii <eliz@gnu.org>
parents:
26927
diff
changeset
|
1168 (mapcar 'car (tty-color-alist frame)))) |
26736
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26657
diff
changeset
|
1169 (defalias 'x-defined-colors 'defined-colors) |
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26657
diff
changeset
|
1170 |
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26657
diff
changeset
|
1171 (defun color-defined-p (color &optional frame) |
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26657
diff
changeset
|
1172 "Return non-nil if color COLOR is supported on frame FRAME. |
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26657
diff
changeset
|
1173 If FRAME is omitted or nil, use the selected frame. |
27117
6838a53d4992
(face-read-integer, read-face-attribute)
Eli Zaretskii <eliz@gnu.org>
parents:
27090
diff
changeset
|
1174 If COLOR is the symbol `unspecified' or one of the strings |
6838a53d4992
(face-read-integer, read-face-attribute)
Eli Zaretskii <eliz@gnu.org>
parents:
27090
diff
changeset
|
1175 \"unspecified-fg\" or \"unspecified-bg\", the value is nil." |
6838a53d4992
(face-read-integer, read-face-attribute)
Eli Zaretskii <eliz@gnu.org>
parents:
27090
diff
changeset
|
1176 (if (memq color '(unspecified "unspecified-bg" "unspecified-fg")) |
26736
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26657
diff
changeset
|
1177 nil |
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26657
diff
changeset
|
1178 (if (memq (framep (or frame (selected-frame))) '(x w32)) |
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26657
diff
changeset
|
1179 (xw-color-defined-p color frame) |
27090
52e469fb402a
(read-face-attribute, defined-colors, color-defined-p):
Eli Zaretskii <eliz@gnu.org>
parents:
26927
diff
changeset
|
1180 (numberp (tty-color-translate color frame))))) |
26736
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26657
diff
changeset
|
1181 (defalias 'x-color-defined-p 'color-defined-p) |
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26657
diff
changeset
|
1182 |
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26657
diff
changeset
|
1183 (defun color-values (color &optional frame) |
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26657
diff
changeset
|
1184 "Return a description of the color named COLOR on frame FRAME. |
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26657
diff
changeset
|
1185 The value is a list of integer RGB values--\(RED GREEN BLUE\). |
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26657
diff
changeset
|
1186 These values appear to range from 0 to 65280 or 65535, depending |
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26657
diff
changeset
|
1187 on the system; white is \(65280 65280 65280\) or \(65535 65535 65535\). |
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26657
diff
changeset
|
1188 If FRAME is omitted or nil, use the selected frame. |
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26657
diff
changeset
|
1189 If FRAME cannot display COLOR, the value is nil. |
27117
6838a53d4992
(face-read-integer, read-face-attribute)
Eli Zaretskii <eliz@gnu.org>
parents:
27090
diff
changeset
|
1190 If COLOR is the symbol `unspecified' or one of the strings |
6838a53d4992
(face-read-integer, read-face-attribute)
Eli Zaretskii <eliz@gnu.org>
parents:
27090
diff
changeset
|
1191 \"unspecified-fg\" or \"unspecified-bg\", the value is nil." |
6838a53d4992
(face-read-integer, read-face-attribute)
Eli Zaretskii <eliz@gnu.org>
parents:
27090
diff
changeset
|
1192 (if (memq color '(unspecified "unspecified-fg" "unspecified-bg")) |
26736
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26657
diff
changeset
|
1193 nil |
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26657
diff
changeset
|
1194 (if (memq (framep (or frame (selected-frame))) '(x w32)) |
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26657
diff
changeset
|
1195 (xw-color-values color frame) |
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26657
diff
changeset
|
1196 (tty-color-values color frame)))) |
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26657
diff
changeset
|
1197 (defalias 'x-color-values 'color-values) |
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26657
diff
changeset
|
1198 |
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26657
diff
changeset
|
1199 (defun display-color-p (&optional display) |
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26657
diff
changeset
|
1200 "Return t if DISPLAY supports color. |
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26657
diff
changeset
|
1201 The optional argument DISPLAY specifies which display to ask about. |
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26657
diff
changeset
|
1202 DISPLAY should be either a frame or a display name (a string). |
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26657
diff
changeset
|
1203 If omitted or nil, that stands for the selected frame's display." |
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26657
diff
changeset
|
1204 (if (and (stringp display) (not (fboundp 'x-display-list))) |
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26657
diff
changeset
|
1205 nil |
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26657
diff
changeset
|
1206 (if (memq (framep (or display (selected-frame))) '(x w32)) |
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26657
diff
changeset
|
1207 (xw-display-color-p display) |
27090
52e469fb402a
(read-face-attribute, defined-colors, color-defined-p):
Eli Zaretskii <eliz@gnu.org>
parents:
26927
diff
changeset
|
1208 (tty-display-color-p display)))) |
26736
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26657
diff
changeset
|
1209 (defalias 'x-display-color-p 'display-color-p) |
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26657
diff
changeset
|
1210 |
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26657
diff
changeset
|
1211 |
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26657
diff
changeset
|
1212 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
25012 | 1213 ;;; Background mode. |
1214 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
1215 | |
1216 (defcustom frame-background-mode nil | |
1217 "*The brightness of the background. | |
1218 Set this to the symbol `dark' if your background color is dark, `light' if | |
1219 your background is light, or nil (default) if you want Emacs to | |
1220 examine the brightness for you." | |
1221 :group 'faces | |
1222 :set #'(lambda (var value) | |
1223 (set var value) | |
1224 (mapcar 'frame-set-background-mode (frame-list))) | |
1225 :initialize 'custom-initialize-changed | |
1226 :type '(choice (choice-item dark) | |
1227 (choice-item light) | |
1228 (choice-item :tag "default" nil))) | |
1229 | |
1230 | |
1231 (defun frame-set-background-mode (frame) | |
1232 "Set up the `background-mode' and `display-type' frame parameters for FRAME." | |
1233 (let* ((bg-resource | |
1234 (and window-system | |
1235 (x-get-resource ".backgroundMode" "BackgroundMode"))) | |
1236 (params (frame-parameters frame)) | |
1237 (bg-mode (cond (frame-background-mode) | |
1238 ((null window-system) | |
1239 ;; No way to determine this automatically (?). | |
1240 'dark) | |
1241 (bg-resource | |
1242 (intern (downcase bg-resource))) | |
1243 ((< (apply '+ (x-color-values | |
1244 (cdr (assq 'background-color | |
1245 params)) | |
1246 frame)) | |
1247 ;; Just looking at the screen, colors whose | |
1248 ;; values add up to .6 of the white total | |
1249 ;; still look dark to me. | |
1250 (* (apply '+ (x-color-values "white" frame)) .6)) | |
1251 'dark) | |
1252 (t 'light))) | |
1253 (display-type (cond ((null window-system) | |
27090
52e469fb402a
(read-face-attribute, defined-colors, color-defined-p):
Eli Zaretskii <eliz@gnu.org>
parents:
26927
diff
changeset
|
1254 (if (tty-display-color-p frame) 'color 'mono)) |
25012 | 1255 ((x-display-color-p frame) |
1256 'color) | |
1257 ((x-display-grayscale-p frame) | |
1258 'grayscale) | |
1259 (t 'mono)))) | |
1260 (modify-frame-parameters frame | |
1261 (list (cons 'background-mode bg-mode) | |
1262 (cons 'display-type display-type)))) | |
1263 | |
1264 ;; For all named faces, choose face specs matching the new frame | |
1265 ;; parameters. | |
1266 (let ((face-list (face-list))) | |
1267 (while face-list | |
1268 (let* ((face (car face-list)) | |
1269 (spec (get face 'face-defface-spec))) | |
1270 (when spec | |
1271 (face-spec-set face spec frame)) | |
1272 (setq face-list (cdr face-list)))))) | |
1273 | |
1274 | |
1275 | |
1276 | |
1277 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
1278 ;;; Frame creation. | |
1279 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
1280 | |
1281 (defun x-handle-named-frame-geometry (parameters) | |
1282 "Add geometry parameters for a named frame to parameter list PARAMETERS. | |
1283 Value is the new parameter list." | |
1284 (let* ((name (or (cdr (assq 'name parameters)) | |
1285 (cdr (assq 'name default-frame-alist)))) | |
1286 (x-resource-name name) | |
1287 (res-geometry (if name (x-get-resource "geometry" "Geometry")))) | |
1288 (when res-geometry | |
1289 (let ((parsed (x-parse-geometry res-geometry))) | |
1290 ;; If the resource specifies a position, call the position | |
1291 ;; and size "user-specified". | |
1292 (when (or (assq 'top parsed) | |
1293 (assq 'left parsed)) | |
1294 (setq parsed (append '((user-position . t) (user-size . t)) parsed))) | |
1295 ;; Put the geometry parameters at the end. Copy | |
1296 ;; default-frame-alist so that they go after it. | |
1297 (setq parameters (append parameters default-frame-alist parsed)))) | |
1298 parameters)) | |
1299 | |
1300 | |
1301 (defun x-handle-reverse-video (frame parameters) | |
1302 "Handle the reverse-video frame parameter and X resource. | |
1303 `x-create-frame' does not handle this one." | |
1304 (when (cdr (or (assq 'reverse parameters) | |
1305 (assq 'reverse default-frame-alist) | |
1306 (let ((resource (x-get-resource "reverseVideo" | |
1307 "ReverseVideo"))) | |
1308 (if resource | |
1309 (cons nil (member (downcase resource) | |
1310 '("on" "true"))))))) | |
1311 (let* ((params (frame-parameters frame)) | |
1312 (bg (cdr (assq 'foreground-color params))) | |
1313 (fg (cdr (assq 'background-color params)))) | |
1314 (modify-frame-parameters frame | |
1315 (list (cons 'foreground-color fg) | |
1316 (cons 'background-color bg))) | |
1317 (if (equal bg (cdr (assq 'border-color params))) | |
1318 (modify-frame-parameters frame | |
1319 (list (cons 'border-color fg)))) | |
1320 (if (equal bg (cdr (assq 'mouse-color params))) | |
1321 (modify-frame-parameters frame | |
1322 (list (cons 'mouse-color fg)))) | |
1323 (if (equal bg (cdr (assq 'cursor-color params))) | |
1324 (modify-frame-parameters frame | |
1325 (list (cons 'cursor-color fg))))))) | |
1326 | |
1327 | |
1328 (defun x-create-frame-with-faces (&optional parameters) | |
1329 "Create a frame from optional frame parameters PARAMETERS. | |
1330 Parameters not specified by PARAMETERS are taken from | |
1331 `default-frame-alist'. If PARAMETERS specify a frame name, | |
1332 handle X geometry resources for that name. If either PARAMETERS | |
1333 or `default-frame-alist' contains a `reverse' parameter, or | |
1334 the X resource ``reverseVideo'' is present, handle that. | |
1335 Value is the new frame created." | |
1336 (setq parameters (x-handle-named-frame-geometry parameters)) | |
1337 (let ((visibility-spec (assq 'visibility parameters)) | |
1338 (frame-list (frame-list)) | |
1339 (frame (x-create-frame (cons '(visibility . nil) parameters))) | |
1340 success) | |
1341 (unwind-protect | |
1342 (progn | |
1343 (x-handle-reverse-video frame parameters) | |
1344 (frame-set-background-mode frame) | |
1345 (face-set-after-frame-default frame) | |
1346 (if (or (null frame-list) (null visibility-spec)) | |
1347 (make-frame-visible frame) | |
1348 (modify-frame-parameters frame (list visibility-spec))) | |
1349 (setq success t)) | |
1350 (unless success | |
1351 (delete-frame frame))) | |
1352 frame)) | |
1353 | |
1354 | |
1355 (defun face-set-after-frame-default (frame) | |
25588
1d8ba3dd04e9
(face-set-after-frame-default): Initialize some
Gerd Moellmann <gerd@gnu.org>
parents:
25561
diff
changeset
|
1356 "Set frame-local faces of FRAME from face specs and resources. |
1d8ba3dd04e9
(face-set-after-frame-default): Initialize some
Gerd Moellmann <gerd@gnu.org>
parents:
25561
diff
changeset
|
1357 Initialize colors of certain faces from frame parameters." |
25012 | 1358 (dolist (face (face-list)) |
1359 (let ((spec (or (get face 'saved-face) | |
1360 (get face 'face-defface-spec)))) | |
1361 (when spec | |
1362 (face-spec-set face spec frame)) | |
1363 (internal-merge-in-global-face face frame) | |
25210
b145fd152286
(face-set-after-frame-default): Don't call
Eli Zaretskii <eliz@gnu.org>
parents:
25137
diff
changeset
|
1364 (when (memq window-system '(x w32)) |
25588
1d8ba3dd04e9
(face-set-after-frame-default): Initialize some
Gerd Moellmann <gerd@gnu.org>
parents:
25561
diff
changeset
|
1365 (make-face-x-resource-internal face frame)))) |
1d8ba3dd04e9
(face-set-after-frame-default): Initialize some
Gerd Moellmann <gerd@gnu.org>
parents:
25561
diff
changeset
|
1366 |
1d8ba3dd04e9
(face-set-after-frame-default): Initialize some
Gerd Moellmann <gerd@gnu.org>
parents:
25561
diff
changeset
|
1367 ;; Initialize attributes from frame parameters. |
1d8ba3dd04e9
(face-set-after-frame-default): Initialize some
Gerd Moellmann <gerd@gnu.org>
parents:
25561
diff
changeset
|
1368 (let ((params '((foreground-color default :foreground) |
1d8ba3dd04e9
(face-set-after-frame-default): Initialize some
Gerd Moellmann <gerd@gnu.org>
parents:
25561
diff
changeset
|
1369 (background-color default :background) |
1d8ba3dd04e9
(face-set-after-frame-default): Initialize some
Gerd Moellmann <gerd@gnu.org>
parents:
25561
diff
changeset
|
1370 (border-color border :background) |
1d8ba3dd04e9
(face-set-after-frame-default): Initialize some
Gerd Moellmann <gerd@gnu.org>
parents:
25561
diff
changeset
|
1371 (cursor-color cursor :background) |
1d8ba3dd04e9
(face-set-after-frame-default): Initialize some
Gerd Moellmann <gerd@gnu.org>
parents:
25561
diff
changeset
|
1372 (scroll-bar-foreground scroll-bar :foreground) |
1d8ba3dd04e9
(face-set-after-frame-default): Initialize some
Gerd Moellmann <gerd@gnu.org>
parents:
25561
diff
changeset
|
1373 (scroll-bar-background scroll-bar :background) |
1d8ba3dd04e9
(face-set-after-frame-default): Initialize some
Gerd Moellmann <gerd@gnu.org>
parents:
25561
diff
changeset
|
1374 (mouse-color mouse :background)))) |
1d8ba3dd04e9
(face-set-after-frame-default): Initialize some
Gerd Moellmann <gerd@gnu.org>
parents:
25561
diff
changeset
|
1375 (while params |
1d8ba3dd04e9
(face-set-after-frame-default): Initialize some
Gerd Moellmann <gerd@gnu.org>
parents:
25561
diff
changeset
|
1376 (let ((param-name (nth 0 (car params))) |
1d8ba3dd04e9
(face-set-after-frame-default): Initialize some
Gerd Moellmann <gerd@gnu.org>
parents:
25561
diff
changeset
|
1377 (face (nth 1 (car params))) |
1d8ba3dd04e9
(face-set-after-frame-default): Initialize some
Gerd Moellmann <gerd@gnu.org>
parents:
25561
diff
changeset
|
1378 (attr (nth 2 (car params))) |
1d8ba3dd04e9
(face-set-after-frame-default): Initialize some
Gerd Moellmann <gerd@gnu.org>
parents:
25561
diff
changeset
|
1379 value) |
1d8ba3dd04e9
(face-set-after-frame-default): Initialize some
Gerd Moellmann <gerd@gnu.org>
parents:
25561
diff
changeset
|
1380 (when (setq value (frame-parameter frame param-name)) |
1d8ba3dd04e9
(face-set-after-frame-default): Initialize some
Gerd Moellmann <gerd@gnu.org>
parents:
25561
diff
changeset
|
1381 (set-face-attribute face frame attr value))) |
1d8ba3dd04e9
(face-set-after-frame-default): Initialize some
Gerd Moellmann <gerd@gnu.org>
parents:
25561
diff
changeset
|
1382 (setq params (cdr params))))) |
25012 | 1383 |
1384 | |
1385 (defun tty-create-frame-with-faces (&optional parameters) | |
1386 "Create a frame from optional frame parameters PARAMETERS. | |
1387 Parameters not specified by PARAMETERS are taken from | |
1388 `default-frame-alist'. If either PARAMETERS or `default-frame-alist' | |
1389 contains a `reverse' parameter, handle that. Value is the new frame | |
1390 created." | |
1391 (let ((frame (make-terminal-frame parameters)) | |
1392 success) | |
1393 (unwind-protect | |
1394 (progn | |
1395 (frame-set-background-mode frame) | |
1396 (face-set-after-frame-default frame) | |
1397 (setq success t)) | |
1398 (unless success | |
1399 (delete-frame frame))) | |
1400 frame)) | |
1401 | |
1402 | |
1403 ;; Called from C function init_display to initialize faces of the | |
1404 ;; dumped terminal frame on startup. | |
1405 | |
1406 (defun tty-set-up-initial-frame-faces () | |
1407 (let ((frame (selected-frame))) | |
1408 (frame-set-background-mode frame) | |
1409 (face-set-after-frame-default frame))) | |
1410 | |
1411 | |
1412 | |
1413 | |
1414 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
1415 ;;; Compatiblity with 20.2 | |
1416 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
1417 | |
1418 ;; Update a frame's faces when we change its default font. | |
1419 | |
1420 (defun frame-update-faces (frame) | |
1421 nil) | |
1422 | |
1423 | |
1424 ;; Update the colors of FACE, after FRAME's own colors have been | |
1425 ;; changed. | |
1426 | |
1427 (defun frame-update-face-colors (frame) | |
1428 (frame-set-background-mode frame)) | |
1429 | |
1430 | |
1431 | |
1432 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
1433 ;;; Standard faces. | |
1434 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
1435 | |
1436 (defgroup basic-faces nil | |
1437 "The standard faces of Emacs." | |
1438 :group 'faces) | |
1439 | |
1440 | |
1441 (defface default | |
1442 '((t nil)) | |
1443 "Basic default face." | |
1444 :group 'basic-faces) | |
1445 | |
1446 | |
25650
8b06b47a1fea
(mode-line): Replaces `modeline'.
Gerd Moellmann <gerd@gnu.org>
parents:
25616
diff
changeset
|
1447 (defface mode-line |
25012 | 1448 '((((type x) (class color)) |
1449 (:box (:line-width 2 :style released-button) :background "grey75")) | |
1450 (t | |
1451 (:inverse-video t))) | |
1452 "Basic mode line face." | |
25687
afad62240679
(mode-line, header-line, tool-bar, ): Add :version.
Dave Love <fx@gnu.org>
parents:
25650
diff
changeset
|
1453 :version "21.1" |
25012 | 1454 :group 'basic-faces) |
1455 | |
25650
8b06b47a1fea
(mode-line): Replaces `modeline'.
Gerd Moellmann <gerd@gnu.org>
parents:
25616
diff
changeset
|
1456 ;; Make `modeline' an alias for `mode-line', for compatibility. |
8b06b47a1fea
(mode-line): Replaces `modeline'.
Gerd Moellmann <gerd@gnu.org>
parents:
25616
diff
changeset
|
1457 (put 'modeline 'face-alias 'mode-line) |
25012 | 1458 |
25545
b0a117037bde
(header-line): Renamed from `top-line'.
Gerd Moellmann <gerd@gnu.org>
parents:
25542
diff
changeset
|
1459 (defface header-line |
25012 | 1460 '((((type x) (class color)) |
1461 (:box (:line-width 2 :style released-button) :background "grey75")) | |
1462 (t | |
1463 (:inverse-video t))) | |
25545
b0a117037bde
(header-line): Renamed from `top-line'.
Gerd Moellmann <gerd@gnu.org>
parents:
25542
diff
changeset
|
1464 "Basic header-line face." |
25687
afad62240679
(mode-line, header-line, tool-bar, ): Add :version.
Dave Love <fx@gnu.org>
parents:
25650
diff
changeset
|
1465 :version "21.1" |
25012 | 1466 :group 'basic-faces) |
1467 | |
1468 | |
25542
047532b73119
(tool-bar): Change face `toolbar' to `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents:
25494
diff
changeset
|
1469 (defface tool-bar |
25012 | 1470 '((((type x) (class color)) |
1471 (:box (:line-width 1 :style released-button) :background "grey75")) | |
25090
4cd409210c7f
(toolbar): Add face definition for mono displays.
Gerd Moellmann <gerd@gnu.org>
parents:
25070
diff
changeset
|
1472 (((type x) (class mono)) |
4cd409210c7f
(toolbar): Add face definition for mono displays.
Gerd Moellmann <gerd@gnu.org>
parents:
25070
diff
changeset
|
1473 (:box (:line-width 1 :style released-button) :background "grey")) |
25012 | 1474 (t |
1475 ())) | |
25542
047532b73119
(tool-bar): Change face `toolbar' to `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents:
25494
diff
changeset
|
1476 "Basic tool-bar face." |
25687
afad62240679
(mode-line, header-line, tool-bar, ): Add :version.
Dave Love <fx@gnu.org>
parents:
25650
diff
changeset
|
1477 :version "21.1" |
25012 | 1478 :group 'basic-faces) |
1479 | |
1480 | |
1481 (defface region | |
1482 '((((type tty) (class color)) | |
1483 (:background "blue" :foreground "white")) | |
1484 (((type tty) (class mono)) | |
1485 (:inverse-video t)) | |
1486 (((class color) (background dark)) | |
1487 (:background "blue")) | |
1488 (((class color) (background light)) | |
1489 (:background "lightblue")) | |
1490 (t (:background "gray"))) | |
25947 | 1491 "Basic face for highlighting the region." |
25012 | 1492 :group 'basic-faces) |
1493 | |
1494 | |
25588
1d8ba3dd04e9
(face-set-after-frame-default): Initialize some
Gerd Moellmann <gerd@gnu.org>
parents:
25561
diff
changeset
|
1495 (defface fringe |
25012 | 1496 '((((class color)) |
1497 (:background "grey95")) | |
25070
b4b6828139fd
(bitmap-area): Change background to white for mono displays.
Gerd Moellmann <gerd@gnu.org>
parents:
25012
diff
changeset
|
1498 (t |
b4b6828139fd
(bitmap-area): Change background to white for mono displays.
Gerd Moellmann <gerd@gnu.org>
parents:
25012
diff
changeset
|
1499 (:background "gray"))) |
25588
1d8ba3dd04e9
(face-set-after-frame-default): Initialize some
Gerd Moellmann <gerd@gnu.org>
parents:
25561
diff
changeset
|
1500 "Basic face for the fringes to the left and right of windows under X." |
1d8ba3dd04e9
(face-set-after-frame-default): Initialize some
Gerd Moellmann <gerd@gnu.org>
parents:
25561
diff
changeset
|
1501 :version "21.1" |
1d8ba3dd04e9
(face-set-after-frame-default): Initialize some
Gerd Moellmann <gerd@gnu.org>
parents:
25561
diff
changeset
|
1502 :group 'basic-faces) |
1d8ba3dd04e9
(face-set-after-frame-default): Initialize some
Gerd Moellmann <gerd@gnu.org>
parents:
25561
diff
changeset
|
1503 |
1d8ba3dd04e9
(face-set-after-frame-default): Initialize some
Gerd Moellmann <gerd@gnu.org>
parents:
25561
diff
changeset
|
1504 |
1d8ba3dd04e9
(face-set-after-frame-default): Initialize some
Gerd Moellmann <gerd@gnu.org>
parents:
25561
diff
changeset
|
1505 (defface scroll-bar '() |
1d8ba3dd04e9
(face-set-after-frame-default): Initialize some
Gerd Moellmann <gerd@gnu.org>
parents:
25561
diff
changeset
|
1506 "Basic face for the scroll bar colors under X." |
1d8ba3dd04e9
(face-set-after-frame-default): Initialize some
Gerd Moellmann <gerd@gnu.org>
parents:
25561
diff
changeset
|
1507 :version "21.1" |
1d8ba3dd04e9
(face-set-after-frame-default): Initialize some
Gerd Moellmann <gerd@gnu.org>
parents:
25561
diff
changeset
|
1508 :group 'basic-faces) |
1d8ba3dd04e9
(face-set-after-frame-default): Initialize some
Gerd Moellmann <gerd@gnu.org>
parents:
25561
diff
changeset
|
1509 |
1d8ba3dd04e9
(face-set-after-frame-default): Initialize some
Gerd Moellmann <gerd@gnu.org>
parents:
25561
diff
changeset
|
1510 |
25887
099a3776ff00
(face-spec-set-match-display): Recognize `type' of
Gerd Moellmann <gerd@gnu.org>
parents:
25814
diff
changeset
|
1511 (defface menu |
099a3776ff00
(face-spec-set-match-display): Recognize `type' of
Gerd Moellmann <gerd@gnu.org>
parents:
25814
diff
changeset
|
1512 '((((type x-toolkit)) ()) |
099a3776ff00
(face-spec-set-match-display): Recognize `type' of
Gerd Moellmann <gerd@gnu.org>
parents:
25814
diff
changeset
|
1513 (t (:inverse-video t))) |
099a3776ff00
(face-spec-set-match-display): Recognize `type' of
Gerd Moellmann <gerd@gnu.org>
parents:
25814
diff
changeset
|
1514 "Basic menu face." |
099a3776ff00
(face-spec-set-match-display): Recognize `type' of
Gerd Moellmann <gerd@gnu.org>
parents:
25814
diff
changeset
|
1515 :version "21.1" |
099a3776ff00
(face-spec-set-match-display): Recognize `type' of
Gerd Moellmann <gerd@gnu.org>
parents:
25814
diff
changeset
|
1516 :group 'basic-faces) |
099a3776ff00
(face-spec-set-match-display): Recognize `type' of
Gerd Moellmann <gerd@gnu.org>
parents:
25814
diff
changeset
|
1517 |
099a3776ff00
(face-spec-set-match-display): Recognize `type' of
Gerd Moellmann <gerd@gnu.org>
parents:
25814
diff
changeset
|
1518 |
25588
1d8ba3dd04e9
(face-set-after-frame-default): Initialize some
Gerd Moellmann <gerd@gnu.org>
parents:
25561
diff
changeset
|
1519 (defface border '() |
1d8ba3dd04e9
(face-set-after-frame-default): Initialize some
Gerd Moellmann <gerd@gnu.org>
parents:
25561
diff
changeset
|
1520 "Basic face for the frame border under X." |
1d8ba3dd04e9
(face-set-after-frame-default): Initialize some
Gerd Moellmann <gerd@gnu.org>
parents:
25561
diff
changeset
|
1521 :version "21.1" |
1d8ba3dd04e9
(face-set-after-frame-default): Initialize some
Gerd Moellmann <gerd@gnu.org>
parents:
25561
diff
changeset
|
1522 :group 'basic-faces) |
1d8ba3dd04e9
(face-set-after-frame-default): Initialize some
Gerd Moellmann <gerd@gnu.org>
parents:
25561
diff
changeset
|
1523 |
1d8ba3dd04e9
(face-set-after-frame-default): Initialize some
Gerd Moellmann <gerd@gnu.org>
parents:
25561
diff
changeset
|
1524 |
1d8ba3dd04e9
(face-set-after-frame-default): Initialize some
Gerd Moellmann <gerd@gnu.org>
parents:
25561
diff
changeset
|
1525 (defface cursor '() |
1d8ba3dd04e9
(face-set-after-frame-default): Initialize some
Gerd Moellmann <gerd@gnu.org>
parents:
25561
diff
changeset
|
1526 "Basic face for the cursor color under X." |
1d8ba3dd04e9
(face-set-after-frame-default): Initialize some
Gerd Moellmann <gerd@gnu.org>
parents:
25561
diff
changeset
|
1527 :version "21.1" |
1d8ba3dd04e9
(face-set-after-frame-default): Initialize some
Gerd Moellmann <gerd@gnu.org>
parents:
25561
diff
changeset
|
1528 :group 'basic-faces) |
1d8ba3dd04e9
(face-set-after-frame-default): Initialize some
Gerd Moellmann <gerd@gnu.org>
parents:
25561
diff
changeset
|
1529 |
1d8ba3dd04e9
(face-set-after-frame-default): Initialize some
Gerd Moellmann <gerd@gnu.org>
parents:
25561
diff
changeset
|
1530 |
1d8ba3dd04e9
(face-set-after-frame-default): Initialize some
Gerd Moellmann <gerd@gnu.org>
parents:
25561
diff
changeset
|
1531 (defface mouse '() |
1d8ba3dd04e9
(face-set-after-frame-default): Initialize some
Gerd Moellmann <gerd@gnu.org>
parents:
25561
diff
changeset
|
1532 "Basic face for the mouse color under X." |
25137 | 1533 :version "21.1" |
25012 | 1534 :group 'basic-faces) |
1535 | |
1536 | |
1537 (defface bold '((t (:weight bold))) | |
1538 "Basic bold face." | |
1539 :group 'basic-faces) | |
1540 | |
1541 | |
1542 (defface italic '((t (:slant italic))) | |
1543 "Basic italic font." | |
1544 :group 'basic-faces) | |
1545 | |
1546 | |
1547 (defface bold-italic '((t (:weight bold :slant italic))) | |
1548 "Basic bold-italic face." | |
1549 :group 'basic-faces) | |
1550 | |
1551 | |
1552 (defface underline '((t (:underline t))) | |
1553 "Basic underlined face." | |
1554 :group 'basic-faces) | |
1555 | |
1556 | |
1557 (defface highlight | |
1558 '((((type tty) (class color)) | |
1559 (:background "green")) | |
1560 (((class color) (background light)) | |
1561 (:background "darkseagreen2")) | |
1562 (((class color) (background dark)) | |
1563 (:background "darkolivegreen")) | |
1564 (t (:inverse-video t))) | |
25687
afad62240679
(mode-line, header-line, tool-bar, ): Add :version.
Dave Love <fx@gnu.org>
parents:
25650
diff
changeset
|
1565 "Basic face for highlighting." |
afad62240679
(mode-line, header-line, tool-bar, ): Add :version.
Dave Love <fx@gnu.org>
parents:
25650
diff
changeset
|
1566 :group 'basic-faces) |
25012 | 1567 |
1568 | |
1569 (defface secondary-selection | |
1570 '((((type tty) (class color)) | |
1571 (:background "cyan")) | |
1572 (((class color) (background light)) | |
26353
f9c908630f61
(secondary-selection): Fix wrong color name.
Gerd Moellmann <gerd@gnu.org>
parents:
26343
diff
changeset
|
1573 (:background "yellow")) |
25012 | 1574 (((class color) (background dark)) |
26343
5fd5d2ab9546
* faces.el (secondary-selection): Change background to yellow.
Gerd Moellmann <gerd@gnu.org>
parents:
26337
diff
changeset
|
1575 (:background "yellow")) |
25012 | 1576 (t (:inverse-video t))) |
25687
afad62240679
(mode-line, header-line, tool-bar, ): Add :version.
Dave Love <fx@gnu.org>
parents:
25650
diff
changeset
|
1577 "Basic face for displaying the secondary selection." |
afad62240679
(mode-line, header-line, tool-bar, ): Add :version.
Dave Love <fx@gnu.org>
parents:
25650
diff
changeset
|
1578 :group 'basic-faces) |
25012 | 1579 |
1580 | |
1581 (defface fixed-pitch '((t (:family "courier*"))) | |
1582 "The basic fixed-pitch face." | |
1583 :group 'basic-faces) | |
1584 | |
1585 | |
1586 (defface variable-pitch '((t (:family "helv*"))) | |
1587 "The basic variable-pitch face." | |
1588 :group 'basic-faces) | |
1589 | |
1590 | |
1591 (defface trailing-whitespace | |
1592 '((((class color) (background light)) | |
1593 (:background "red")) | |
1594 (((class color) (background dark)) | |
1595 (:background "red")) | |
1596 (t (:inverse-video t))) | |
25687
afad62240679
(mode-line, header-line, tool-bar, ): Add :version.
Dave Love <fx@gnu.org>
parents:
25650
diff
changeset
|
1597 "Basic face for highlighting trailing whitespace." |
afad62240679
(mode-line, header-line, tool-bar, ): Add :version.
Dave Love <fx@gnu.org>
parents:
25650
diff
changeset
|
1598 :version "21.1" |
afad62240679
(mode-line, header-line, tool-bar, ): Add :version.
Dave Love <fx@gnu.org>
parents:
25650
diff
changeset
|
1599 :group 'basic-faces) |
25012 | 1600 |
1601 | |
1602 | |
1603 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
1604 ;;; Manipulating font names. | |
1605 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
1606 | |
1607 ;; This is here for compatibilty with Emacs 20.2. For example, | |
1608 ;; international/fontset.el uses these functions to manipulate font | |
1609 ;; names. The following functions are not used in the face | |
1610 ;; implementation itself. | |
2456 | 1611 |
16687
049c87a96dca
Change defconsts to defvars.
Richard M. Stallman <rms@gnu.org>
parents:
16590
diff
changeset
|
1612 (defvar x-font-regexp nil) |
049c87a96dca
Change defconsts to defvars.
Richard M. Stallman <rms@gnu.org>
parents:
16590
diff
changeset
|
1613 (defvar x-font-regexp-head nil) |
049c87a96dca
Change defconsts to defvars.
Richard M. Stallman <rms@gnu.org>
parents:
16590
diff
changeset
|
1614 (defvar x-font-regexp-weight nil) |
049c87a96dca
Change defconsts to defvars.
Richard M. Stallman <rms@gnu.org>
parents:
16590
diff
changeset
|
1615 (defvar x-font-regexp-slant nil) |
2456 | 1616 |
12668
7660e82d0346
(x-font-regexp-weight-subnum, x-font-regexp-slant-subnum)
Karl Heuer <kwzh@gnu.org>
parents:
12651
diff
changeset
|
1617 (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
|
1618 (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
|
1619 (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
|
1620 (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
|
1621 |
2456 | 1622 ;;; Regexps matching font names in "Host Portable Character Representation." |
1623 ;;; | |
1624 (let ((- "[-?]") | |
1625 (foundry "[^-]+") | |
1626 (family "[^-]+") | |
1627 (weight "\\(bold\\|demibold\\|medium\\)") ; 1 | |
1628 ; (weight\? "\\(\\*\\|bold\\|demibold\\|medium\\|\\)") ; 1 | |
1629 (weight\? "\\([^-]*\\)") ; 1 | |
1630 (slant "\\([ior]\\)") ; 2 | |
1631 ; (slant\? "\\([ior?*]?\\)") ; 2 | |
1632 (slant\? "\\([^-]?\\)") ; 2 | |
1633 ; (swidth "\\(\\*\\|normal\\|semicondensed\\|\\)") ; 3 | |
1634 (swidth "\\([^-]*\\)") ; 3 | |
1635 ; (adstyle "\\(\\*\\|sans\\|\\)") ; 4 | |
12690
e2d3fa52d100
(x-font-regexp): Add \\(\\) for substring extraction.
Karl Heuer <kwzh@gnu.org>
parents:
12668
diff
changeset
|
1636 (adstyle "\\([^-]*\\)") ; 4 |
2456 | 1637 (pixelsize "[0-9]+") |
1638 (pointsize "[0-9][0-9]+") | |
1639 (resx "[0-9][0-9]+") | |
1640 (resy "[0-9][0-9]+") | |
1641 (spacing "[cmp?*]") | |
1642 (avgwidth "[0-9]+") | |
1643 (registry "[^-]+") | |
1644 (encoding "[^-]+") | |
1645 ) | |
1646 (setq x-font-regexp | |
1647 (concat "\\`\\*?[-?*]" | |
1648 foundry - family - weight\? - slant\? - swidth - adstyle - | |
12475
eb436b0c4ab3
(x-font-regexp): Include the avgwidth.
Richard M. Stallman <rms@gnu.org>
parents:
12460
diff
changeset
|
1649 pixelsize - pointsize - resx - resy - spacing - avgwidth - |
eb436b0c4ab3
(x-font-regexp): Include the avgwidth.
Richard M. Stallman <rms@gnu.org>
parents:
12460
diff
changeset
|
1650 registry - encoding "\\*?\\'" |
2456 | 1651 )) |
1652 (setq x-font-regexp-head | |
1653 (concat "\\`[-?*]" foundry - family - weight\? - slant\? | |
1654 "\\([-*?]\\|\\'\\)")) | |
1655 (setq x-font-regexp-slant (concat - slant -)) | |
1656 (setq x-font-regexp-weight (concat - weight -)) | |
1657 nil) | |
1658 | |
25012 | 1659 |
3071
68de05fb5751
* faces.el (set-face-font): Call x-resolve-font-name on the font
Jim Blandy <jimb@redhat.com>
parents:
3049
diff
changeset
|
1660 (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
|
1661 "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
|
1662 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
|
1663 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
|
1664 contains wildcards. |
10170
5fc240a3e4a0
(face-initialize): Test for framep not t or nil.
Richard M. Stallman <rms@gnu.org>
parents:
10107
diff
changeset
|
1665 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
|
1666 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
|
1667 (or (symbolp face) |
28b2df35c33e
(x-resolve-font-name): Allow symbol as FACE arg.
Richard M. Stallman <rms@gnu.org>
parents:
3182
diff
changeset
|
1668 (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
|
1669 (and (eq frame t) |
28b2df35c33e
(x-resolve-font-name): Allow symbol as FACE arg.
Richard M. Stallman <rms@gnu.org>
parents:
3182
diff
changeset
|
1670 (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
|
1671 (if pattern |
5092
36508a7c0a3f
(x-resolve-font-name): Undo previous change.
Richard M. Stallman <rms@gnu.org>
parents:
5081
diff
changeset
|
1672 ;; Note that x-list-fonts has code to handle a face with nil as its font. |
16002
c8cbde1d3f11
(internal-set-face-1): When calling x-list-fonts, ask for just one match.
Richard M. Stallman <rms@gnu.org>
parents:
15884
diff
changeset
|
1673 (let ((fonts (x-list-fonts pattern face frame 1))) |
3130
82c29bacb6b3
* faces.el (x-resolve-font-name): If PATTERN is nil, return the
Jim Blandy <jimb@redhat.com>
parents:
3071
diff
changeset
|
1674 (or fonts |
82c29bacb6b3
* faces.el (x-resolve-font-name): If PATTERN is nil, return the
Jim Blandy <jimb@redhat.com>
parents:
3071
diff
changeset
|
1675 (if face |
10584 | 1676 (if (string-match "\\*" pattern) |
1677 (if (null (face-font face)) | |
1678 (error "No matching fonts are the same height as the frame default font") | |
1679 (error "No matching fonts are the same height as face `%s'" face)) | |
1680 (if (null (face-font face)) | |
1681 (error "Height of font `%s' doesn't match the frame default font" | |
1682 pattern) | |
1683 (error "Height of font `%s' doesn't match face `%s'" | |
1684 pattern face))) | |
3353
8cbd38886eef
(x-resolve-font-name): Clean up error messages.
Richard M. Stallman <rms@gnu.org>
parents:
3298
diff
changeset
|
1685 (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
|
1686 (car fonts)) |
82c29bacb6b3
* faces.el (x-resolve-font-name): If PATTERN is nil, return the
Jim Blandy <jimb@redhat.com>
parents:
3071
diff
changeset
|
1687 (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
|
1688 |
25012 | 1689 |
2456 | 1690 (defun x-frob-font-weight (font which) |
13704
3dcaddea344a
Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents:
13609
diff
changeset
|
1691 (let ((case-fold-search t)) |
3dcaddea344a
Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents:
13609
diff
changeset
|
1692 (cond ((string-match x-font-regexp font) |
3dcaddea344a
Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents:
13609
diff
changeset
|
1693 (concat (substring font 0 |
3dcaddea344a
Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents:
13609
diff
changeset
|
1694 (match-beginning x-font-regexp-weight-subnum)) |
3dcaddea344a
Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents:
13609
diff
changeset
|
1695 which |
3dcaddea344a
Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents:
13609
diff
changeset
|
1696 (substring font (match-end x-font-regexp-weight-subnum) |
3dcaddea344a
Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents:
13609
diff
changeset
|
1697 (match-beginning x-font-regexp-adstyle-subnum)) |
3dcaddea344a
Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents:
13609
diff
changeset
|
1698 ;; Replace the ADD_STYLE_NAME field with * |
3dcaddea344a
Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents:
13609
diff
changeset
|
1699 ;; because the info in it may not be the same |
3dcaddea344a
Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents:
13609
diff
changeset
|
1700 ;; for related fonts. |
3dcaddea344a
Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents:
13609
diff
changeset
|
1701 "*" |
3dcaddea344a
Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents:
13609
diff
changeset
|
1702 (substring font (match-end x-font-regexp-adstyle-subnum)))) |
14880
b405f39b5493
(x-frob-font-slant): Properly handle a match against
Richard M. Stallman <rms@gnu.org>
parents:
14409
diff
changeset
|
1703 ((string-match x-font-regexp-head font) |
b405f39b5493
(x-frob-font-slant): Properly handle a match against
Richard M. Stallman <rms@gnu.org>
parents:
14409
diff
changeset
|
1704 (concat (substring font 0 (match-beginning 1)) which |
b405f39b5493
(x-frob-font-slant): Properly handle a match against
Richard M. Stallman <rms@gnu.org>
parents:
14409
diff
changeset
|
1705 (substring font (match-end 1)))) |
b405f39b5493
(x-frob-font-slant): Properly handle a match against
Richard M. Stallman <rms@gnu.org>
parents:
14409
diff
changeset
|
1706 ((string-match x-font-regexp-weight font) |
13704
3dcaddea344a
Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents:
13609
diff
changeset
|
1707 (concat (substring font 0 (match-beginning 1)) which |
3dcaddea344a
Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents:
13609
diff
changeset
|
1708 (substring font (match-end 1))))))) |
2456 | 1709 |
25012 | 1710 |
2456 | 1711 (defun x-frob-font-slant (font which) |
13704
3dcaddea344a
Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents:
13609
diff
changeset
|
1712 (let ((case-fold-search t)) |
3dcaddea344a
Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents:
13609
diff
changeset
|
1713 (cond ((string-match x-font-regexp font) |
3dcaddea344a
Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents:
13609
diff
changeset
|
1714 (concat (substring font 0 |
3dcaddea344a
Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents:
13609
diff
changeset
|
1715 (match-beginning x-font-regexp-slant-subnum)) |
3dcaddea344a
Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents:
13609
diff
changeset
|
1716 which |
3dcaddea344a
Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents:
13609
diff
changeset
|
1717 (substring font (match-end x-font-regexp-slant-subnum) |
3dcaddea344a
Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents:
13609
diff
changeset
|
1718 (match-beginning x-font-regexp-adstyle-subnum)) |
3dcaddea344a
Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents:
13609
diff
changeset
|
1719 ;; Replace the ADD_STYLE_NAME field with * |
3dcaddea344a
Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents:
13609
diff
changeset
|
1720 ;; because the info in it may not be the same |
3dcaddea344a
Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents:
13609
diff
changeset
|
1721 ;; for related fonts. |
3dcaddea344a
Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents:
13609
diff
changeset
|
1722 "*" |
3dcaddea344a
Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents:
13609
diff
changeset
|
1723 (substring font (match-end x-font-regexp-adstyle-subnum)))) |
14880
b405f39b5493
(x-frob-font-slant): Properly handle a match against
Richard M. Stallman <rms@gnu.org>
parents:
14409
diff
changeset
|
1724 ((string-match x-font-regexp-head font) |
b405f39b5493
(x-frob-font-slant): Properly handle a match against
Richard M. Stallman <rms@gnu.org>
parents:
14409
diff
changeset
|
1725 (concat (substring font 0 (match-beginning 2)) which |
b405f39b5493
(x-frob-font-slant): Properly handle a match against
Richard M. Stallman <rms@gnu.org>
parents:
14409
diff
changeset
|
1726 (substring font (match-end 2)))) |
b405f39b5493
(x-frob-font-slant): Properly handle a match against
Richard M. Stallman <rms@gnu.org>
parents:
14409
diff
changeset
|
1727 ((string-match x-font-regexp-slant font) |
13704
3dcaddea344a
Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents:
13609
diff
changeset
|
1728 (concat (substring font 0 (match-beginning 1)) which |
3dcaddea344a
Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents:
13609
diff
changeset
|
1729 (substring font (match-end 1))))))) |
2456 | 1730 |
25012 | 1731 |
2456 | 1732 (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
|
1733 "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
|
1734 If that can't be done, return nil." |
2456 | 1735 (x-frob-font-weight font "bold")) |
1736 | |
25012 | 1737 |
2456 | 1738 (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
|
1739 "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
|
1740 If that can't be done, return nil." |
2456 | 1741 (x-frob-font-weight font "demibold")) |
1742 | |
25012 | 1743 |
2456 | 1744 (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
|
1745 "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
|
1746 If that can't be done, return nil." |
2456 | 1747 (x-frob-font-weight font "medium")) |
1748 | |
25012 | 1749 |
2456 | 1750 (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
|
1751 "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
|
1752 If that can't be done, return nil." |
2456 | 1753 (x-frob-font-slant font "i")) |
1754 | |
25012 | 1755 |
2456 | 1756 (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
|
1757 "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
|
1758 If that can't be done, return nil." |
2456 | 1759 (x-frob-font-slant font "o")) |
1760 | |
25012 | 1761 |
2456 | 1762 (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
|
1763 "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
|
1764 If that can't be done, return nil." |
2456 | 1765 (x-frob-font-slant font "r")) |
17752
2687f3d7c191
(x-make-font-bold-italic): New function.
Kenichi Handa <handa@m17n.org>
parents:
17560
diff
changeset
|
1766 |
25012 | 1767 |
17752
2687f3d7c191
(x-make-font-bold-italic): New function.
Kenichi Handa <handa@m17n.org>
parents:
17560
diff
changeset
|
1768 (defun x-make-font-bold-italic (font) |
2687f3d7c191
(x-make-font-bold-italic): New function.
Kenichi Handa <handa@m17n.org>
parents:
17560
diff
changeset
|
1769 "Given an X font specification, make a bold and italic version of it. |
2687f3d7c191
(x-make-font-bold-italic): New function.
Kenichi Handa <handa@m17n.org>
parents:
17560
diff
changeset
|
1770 If that can't be done, return nil." |
2687f3d7c191
(x-make-font-bold-italic): New function.
Kenichi Handa <handa@m17n.org>
parents:
17560
diff
changeset
|
1771 (and (setq font (x-make-font-bold font)) |
2687f3d7c191
(x-make-font-bold-italic): New function.
Kenichi Handa <handa@m17n.org>
parents:
17560
diff
changeset
|
1772 (x-make-font-italic font))) |
2456 | 1773 |
1774 | |
2715
9caee9338229
* faces.el: Call internal-set-face-1, not internat-set-face-1.
Jim Blandy <jimb@redhat.com>
parents:
2714
diff
changeset
|
1775 (provide 'faces) |
9caee9338229
* faces.el: Call internal-set-face-1, not internat-set-face-1.
Jim Blandy <jimb@redhat.com>
parents:
2714
diff
changeset
|
1776 |
25012 | 1777 ;;; end of faces.el |