Mercurial > emacs
annotate lisp/faces.el @ 25489:cd3aa5527b4f
Update Ada, ILISP, GNUPG, MULE_UCS.
author | Dave Love <fx@gnu.org> |
---|---|
date | Thu, 02 Sep 1999 17:06:35 +0000 |
parents | fdefa56606aa |
children | 170d491fe703 |
rev | line source |
---|---|
25012 | 1 ;;; faces.el --- Lisp faces |
2456 | 2 |
25012 | 3 ;; Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998 |
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." | |
222 (or (internal-lisp-face-empty-p face frame) | |
223 (not (internal-lisp-face-equal-p face 'default frame)))) | |
10379
f9d713e8c77c
(face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10375
diff
changeset
|
224 |
2456 | 225 |
10379
f9d713e8c77c
(face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10375
diff
changeset
|
226 (defun face-nontrivial-p (face &optional frame) |
f9d713e8c77c
(face-nontrivial-p): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10375
diff
changeset
|
227 "True if face FACE has some non-nil attribute. |
25012 | 228 If the optional argument FRAME is given, report on face FACE in that frame. |
229 If FRAME is t, report on the defaults for face FACE (for new frames). | |
230 If FRAME is omitted or nil, use the selected frame." | |
231 (not (internal-lisp-face-empty-p face frame))) | |
232 | |
233 | |
234 | |
235 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
236 ;;; Setting face attributes from X resources. | |
237 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
238 | |
239 (defcustom face-x-resources | |
240 '((:family (".attributeFamily" . "Face.AttributeFamily")) | |
241 (:width (".attributeWidth" . "Face.AttributeWidth")) | |
242 (:height (".attributeHeight" . "Face.AttributeHeight")) | |
243 (:weight (".attributeWeight" . "Face.AttributeWeight")) | |
244 (:slant (".attributeSlant" . "Face.AttributeSlant")) | |
245 (:foreground (".attributeForeground" . "Face.AttributeForeground")) | |
246 (:background (".attributeBackground" . "Face.AttributeBackground")) | |
247 (:overline (".attributeOverline" . "Face.AttributeOverline")) | |
248 (:strike-through (".attributeStrikeThrough" . "Face.AttributeStrikeThrough")) | |
249 (:box (".attributeBox" . "Face.AttributeBox")) | |
250 (:underline (".attributeUnderline" . "Face.AttributeUnderline")) | |
251 (:inverse-video (".attributeInverse" . "Face.AttributeInverse")) | |
252 (:stipple | |
253 (".attributeStipple" . "Face.AttributeStipple") | |
254 (".attributeBackgroundPixmap" . "Face.AttributeBackgroundPixmap")) | |
255 (:font (".attributeFont" . "Face.AttributeFont")) | |
256 (:bold (".attributeBold" . "Face.AttributeBold")) | |
257 (:italic (".attributeItalic" . "Face.AttributeItalic")) | |
258 (:font (".attributeFont" . "Face.AttributeFont"))) | |
259 "*List of X resources and classes for face attributes. | |
260 Each element has the form (ATTRIBUTE ENTRY1 ENTRY2...) where ATTRIBUTE is | |
261 the name of a face attribute, and each ENTRY is a cons of the form | |
262 (RESOURCE . CLASS) with RESOURCE being the resource and CLASS being the | |
263 X resource class for the attribute." | |
264 :type 'sexp | |
265 :group 'faces) | |
266 | |
267 | |
268 (defun set-face-attribute-from-resource (face attribute resource class frame) | |
269 "Set FACE's ATTRIBUTE from X resource RESOURCE, class CLASS on FRAME. | |
270 Value is the attribute value specified by the resource, or nil | |
271 if not present. This function displays a message if the resource | |
272 specifies an invalid attribute." | |
273 (let* ((face-name (face-name face)) | |
274 (value (internal-face-x-get-resource (concat face-name resource) | |
275 class frame))) | |
276 (when value | |
277 (condition-case () | |
278 (internal-set-lisp-face-attribute-from-resource | |
279 face attribute (downcase value) frame) | |
280 (error | |
281 (message "Face %s, frame %s: invalid attribute %s %s from X resource" | |
282 face-name frame attribute value)))) | |
283 value)) | |
284 | |
285 | |
286 (defun set-face-attributes-from-resources (face frame) | |
287 "Set attributes of FACE from X resources for FRAME." | |
288 (when (memq (framep frame) '(x w32)) | |
289 (dolist (definition face-x-resources) | |
290 (let ((attribute (car definition))) | |
291 (dolist (entry (cdr definition)) | |
292 (set-face-attribute-from-resource face attribute (car entry) | |
293 (cdr entry) frame)))))) | |
294 | |
295 | |
296 (defun make-face-x-resource-internal (face &optional frame) | |
297 "Fill frame-local FACE on FRAME from X resources. | |
298 FRAME nil or not specified means do it for all frames." | |
299 (if (null frame) | |
300 (dolist (frame (frame-list)) | |
301 (set-face-attributes-from-resources face frame)) | |
302 (set-face-attributes-from-resources face frame))) | |
303 | |
304 | |
305 | |
306 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
307 ;;; Retrieving face attributes. | |
308 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
309 | |
310 (defun face-name (face) | |
311 "Return the name of face FACE." | |
312 (symbol-name (check-face face))) | |
313 | |
314 | |
315 (defun face-attribute (face attribute &optional frame) | |
316 "Return the value of FACE's ATTRIBUTE on FRAME. | |
317 If the optional argument FRAME is given, report on face FACE in that frame. | |
318 If FRAME is t, report on the defaults for face FACE (for new frames). | |
319 If FRAME is omitted or nil, use the selected frame." | |
320 (internal-get-lisp-face-attribute face attribute frame)) | |
321 | |
322 | |
323 (defun face-foreground (face &optional frame) | |
324 "Return the foreground color name of FACE, or nil if unspecified. | |
325 If the optional argument FRAME is given, report on face FACE in that frame. | |
326 If FRAME is t, report on the defaults for face FACE (for new frames). | |
327 If FRAME is omitted or nil, use the selected frame." | |
328 (internal-get-lisp-face-attribute face :foreground frame)) | |
329 | |
330 | |
331 (defun face-background (face &optional frame) | |
332 "Return the background color name of FACE, or nil if unspecified. | |
333 If the optional argument FRAME is given, report on face FACE in that frame. | |
334 If FRAME is t, report on the defaults for face FACE (for new frames). | |
335 If FRAME is omitted or nil, use the selected frame." | |
336 (internal-get-lisp-face-attribute face :background frame)) | |
337 | |
338 | |
339 (defun face-stipple (face &optional frame) | |
340 "Return the stipple pixmap name of FACE, or nil if unspecified. | |
341 If the optional argument FRAME is given, report on face FACE in that frame. | |
342 If FRAME is t, report on the defaults for face FACE (for new frames). | |
343 If FRAME is omitted or nil, use the selected frame." | |
344 (internal-get-lisp-face-attribute face :stipple frame)) | |
345 | |
346 | |
347 (defalias 'face-background-pixmap 'face-stipple) | |
348 | |
349 | |
350 (defun face-underline-p (face &optional frame) | |
351 "Return non-nil if FACE is underlined. | |
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 (eq (face-attribute face :underline frame) t)) | |
356 | |
357 | |
358 (defun face-inverse-video-p (face &optional frame) | |
359 "Return non-nil if FACE is in inverse video on FRAME. | |
360 If the optional argument FRAME is given, report on face FACE in that frame. | |
361 If FRAME is t, report on the defaults for face FACE (for new frames). | |
362 If FRAME is omitted or nil, use the selected frame." | |
363 (eq (face-attribute face :inverse-video frame) t)) | |
364 | |
365 | |
366 (defun face-bold-p (face &optional frame) | |
367 "Return non-nil if the font of FACE is bold on FRAME. | |
368 If the optional argument FRAME is given, report on face FACE in that frame. | |
369 If FRAME is t, report on the defaults for face FACE (for new frames). | |
370 If FRAME is omitted or nil, use the selected frame. | |
371 Use `face-attribute' for finer control." | |
372 (let ((bold (face-attribute face :weight frame))) | |
373 (not (memq bold '(normal unspecified))))) | |
374 | |
375 | |
376 (defun face-italic-p (face &optional frame) | |
377 "Return non-nil if the font of FACE is italic on FRAME. | |
378 If the optional argument FRAME is given, report on face FACE in that frame. | |
379 If FRAME is t, report on the defaults for face FACE (for new frames). | |
380 If FRAME is omitted or nil, use the selected frame. | |
381 Use `face-attribute' for finer control." | |
382 (let ((italic (face-attribute face :slant frame))) | |
383 (not (memq italic '(normal unspecified))))) | |
384 | |
385 | |
386 | |
387 | |
388 | |
389 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
390 ;;; Face documentation. | |
391 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
392 | |
393 (defun face-documentation (face) | |
394 "Get the documentation string for FACE." | |
395 (get face 'face-documentation)) | |
396 | |
397 | |
398 (defun set-face-documentation (face string) | |
399 "Set the documentation string for FACE to STRING." | |
400 (put face 'face-documentation string)) | |
401 | |
402 | |
403 (defalias 'face-doc-string 'face-documentation) | |
404 (defalias 'set-face-doc-string 'set-face-documentation) | |
405 | |
406 | |
407 | |
408 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
409 ;; Setting face attributes. | |
410 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
411 | |
412 | |
413 (defun set-face-attribute (face frame &rest args) | |
414 "Set attributes of FACE on FRAME from ARGS. | |
415 | |
416 FRAME nil means change attributes on all frames. FRAME t means change | |
417 the default for new frames (this is done automatically each time an | |
418 attribute is changed on all frames). | |
419 | |
420 ARGS must come in pairs ATTRIBUTE VALUE. ATTRIBUTE must be a valid | |
421 face attribute name. All attributes can be set to `unspecified'; | |
422 this fact is not further mentioned below. | |
423 | |
424 The following attributes are recognized: | |
425 | |
426 `:family' | |
427 | |
428 VALUE must be a string specifying the font family, e.g. ``courier'', | |
429 or a fontset alias name. If a font family is specified, wild-cards `*' | |
430 and `?' are allowed. | |
431 | |
432 `:width' | |
433 | |
434 VALUE specifies the relative proportionate width of the font to use. | |
435 It must be one of the symbols `ultra-condensed', `extra-condensed', | |
436 `condensed', `semi-condensed', `normal', `semi-expanded', `expanded', | |
437 `extra-expanded', or `ultra-expanded'. | |
438 | |
439 `:height' | |
440 | |
441 VALUE must be an integer specifying the height of the font to use in | |
442 1/10 pt. | |
443 | |
444 `:weight' | |
445 | |
446 VALUE specifies the weight of the font to use. It must be one of the | |
447 symbols `ultra-bold', `extra-bold', `bold', `semi-bold', `normal', | |
448 `semi-light', `light', `extra-light', `ultra-light'. | |
449 | |
450 `:slant' | |
451 | |
452 VALUE specifies the slant of the font to use. It must be one of the | |
453 symbols `italic', `oblique', `normal', `reverse-italic', or | |
454 `reverse-oblique'. | |
455 | |
456 `:foreground', `:background' | |
457 | |
458 VALUE must be a color name, a string. | |
459 | |
460 `:underline' | |
461 | |
462 VALUE specifies whether characters in FACE should be underlined. If | |
463 VALUE is t, underline with foreground color of the face. If VALUE is | |
464 a string, underline with that color. If VALUE is nil, explicitly | |
465 don't underline. | |
466 | |
467 `:overline' | |
468 | |
469 VALUE specifies whether characters in FACE should be overlined. If | |
470 VALUE is t, overline with foreground color of the face. If VALUE is a | |
471 string, overline with that color. If VALUE is nil, explicitly don't | |
472 overline. | |
473 | |
474 `:strike-through' | |
475 | |
476 VALUE specifies whether characters in FACE should be drawn with a line | |
477 striking through them. If VALUE is t, use the foreground color of the | |
478 face. If VALUE is a string, strike-through with that color. If VALUE | |
479 is nil, explicitly don't strike through. | |
480 | |
481 `:box' | |
482 | |
483 VALUE specifies whether characters in FACE should have a box drawn | |
484 around them. If VALUE is nil, explicitly don't draw boxes. If | |
485 VALUE is t, draw a box with lines of width 1 in the foreground color | |
486 of the face. If VALUE is a string, the string must be a color name, | |
487 and the box is drawn in that color with a line width of 1. Otherwise, | |
488 VALUE must be a property list of the form `(:line-width WIDTH | |
489 :color COLOR :style STYLE)'. If a keyword/value pair is missing from | |
490 the property list, a default value will be used for the value, as | |
491 specified below. WIDTH specifies the width of the lines to draw; it | |
492 defaults to 1. COLOR is the name of the color to draw in, default is | |
493 the foreground color of the face for simple boxes, and the background | |
494 color of the face for 3D boxes. STYLE specifies whether a 3D box | |
495 should be draw. If STYLE is `released-button', draw a box looking | |
496 like a released 3D button. If STYLE is `pressed-button' draw a box | |
497 that appears like a pressed button. If STYLE is nil, the default if | |
498 the property list doesn't contain a style specification, draw a 2D | |
499 box. | |
500 | |
501 `:inverse-video' | |
502 | |
503 VALUE specifies whether characters in FACE should be displayed in | |
504 inverse video. VALUE must be one of t or nil. | |
505 | |
506 `:stipple' | |
507 | |
508 If VALUE is a string, it must be the name of a file of pixmap data. | |
509 The directories listed in the `x-bitmap-file-path' variable are | |
510 searched. Alternatively, VALUE may be a list of the form (WIDTH | |
511 HEIGHT DATA) where WIDTH and HEIGHT are the size in pixels, and DATA | |
512 is a string containing the raw bits of the bitmap. VALUE nil means | |
513 explicitly don't use a stipple pattern. | |
514 | |
515 For convenience, attributes `:family', `:width', `:height', `:weight', | |
516 and `:slant' may also be set in one step from an X font name: | |
517 | |
518 `:font' | |
519 | |
520 Set font-related face attributes from VALUE. VALUE must be a valid | |
521 XLFD font name. If it is a font name pattern, the first matching font | |
522 will be used. | |
523 | |
524 For compatibility with Emacs 20, keywords `:bold' and `:italic' can | |
525 be used to specify that a bold or italic font should be used. VALUE | |
526 must be t or nil in that case. A value of `unspecified' is not allowed." | |
527 (cond ((null frame) | |
528 ;; Change face on all frames. | |
529 (dolist (frame (frame-list)) | |
530 (apply #'set-face-attribute face frame args)) | |
531 ;; Record that as a default for new frames. | |
532 (apply #'set-face-attribute face t args)) | |
533 (t | |
534 (while args | |
535 (internal-set-lisp-face-attribute face (car args) | |
536 (car (cdr args)) frame) | |
537 (setq args (cdr (cdr args))))))) | |
538 | |
539 | |
540 (defun make-face-bold (face &optional frame) | |
541 "Make the font of FACE be bold, if possible. | |
542 FRAME nil or not specified means change face on all frames. | |
543 Use `set-face-attribute' for finer control of the font weight." | |
544 (interactive (list (read-face-name "Make which face bold: "))) | |
545 (set-face-attribute face frame :weight 'bold)) | |
546 | |
547 | |
548 (defun make-face-unbold (face &optional frame) | |
549 "Make the font of FACE be non-bold, if possible. | |
550 FRAME nil or not specified means change face on all frames." | |
551 (interactive (list (read-face-name "Make which face non-bold: "))) | |
552 (set-face-attribute face frame :weight 'normal)) | |
553 | |
554 | |
555 (defun make-face-italic (face &optional frame) | |
556 "Make the font of FACE be italic, if possible. | |
557 FRAME nil or not specified means change face on all frames. | |
558 Use `set-face-attribute' for finer control of the font slant." | |
559 (interactive (list (read-face-name "Make which face italic: "))) | |
560 (set-face-attribute face frame :slant 'italic)) | |
561 | |
562 | |
563 (defun make-face-unitalic (face &optional frame) | |
564 "Make the font of FACE be non-italic, if possible. | |
565 FRAME nil or not specified means change face on all frames." | |
566 (interactive (list (read-face-name "Make which face non-italic: "))) | |
567 (set-face-attribute face frame :slant 'normal)) | |
568 | |
569 | |
570 (defun make-face-bold-italic (face &optional frame) | |
571 "Make the font of FACE be bold and italic, if possible. | |
572 FRAME nil or not specified means change face on all frames. | |
573 Use `set-face-attribute' for finer control of font weight and slant." | |
574 (interactive (list (read-face-name "Make which face bold-italic: "))) | |
575 (set-face-attribute face frame :weight 'bold :slant 'italic)) | |
576 | |
577 | |
578 (defun set-face-font (face font &optional frame) | |
579 "Change font-related attributes of FACE to those of FONT (a string). | |
580 FRAME nil or not specified means change face on all frames. | |
581 This sets the attributes `:family', `:width', `:height', `:weight', | |
582 and `:slant'. When called interactively, prompt for the face and font." | |
583 (interactive (read-face-and-attribute :font)) | |
584 (set-face-attribute face frame :font font)) | |
585 | |
586 | |
587 ;; Implementation note: Emulating gray background colors with a | |
588 ;; stipple pattern is now part of the face realization process, and is | |
589 ;; done in C depending on the frame on which the face is realized. | |
590 | |
591 (defun set-face-background (face color &optional frame) | |
592 "Change the background color of face FACE to COLOR (a string). | |
593 FRAME nil or not specified means change face on all frames. | |
594 When called interactively, prompt for the face and color." | |
595 (interactive (read-face-and-attribute :background)) | |
596 (set-face-attribute face frame :background color)) | |
597 | |
598 | |
599 (defun set-face-foreground (face color &optional frame) | |
600 "Change the foreground color of face FACE to COLOR (a string). | |
601 FRAME nil or not specified means change face on all frames. | |
602 When called interactively, prompt for the face and color." | |
603 (interactive (read-face-and-attribute :foreground)) | |
604 (set-face-attribute face frame :foreground color)) | |
605 | |
606 | |
607 (defun set-face-stipple (face stipple &optional frame) | |
608 "Change the stipple pixmap of face FACE to STIPPLE. | |
609 FRAME nil or not specified means change face on all frames. | |
610 STIPPLE. should be a string, the name of a file of pixmap data. | |
611 The directories listed in the `x-bitmap-file-path' variable are searched. | |
612 | |
613 Alternatively, STIPPLE may be a list of the form (WIDTH HEIGHT DATA) | |
614 where WIDTH and HEIGHT are the size in pixels, | |
615 and DATA is a string, containing the raw bits of the bitmap." | |
616 (interactive (read-face-and-attribute :stipple)) | |
617 (set-face-attribute face frame :stipple stipple)) | |
618 | |
619 | |
620 (defun set-face-underline (face underline &optional frame) | |
621 "Specify whether face FACE is underlined. | |
622 UNDERLINE nil means FACE explicitly doesn't underline. | |
623 UNDERLINE non-nil means FACE explicitly does underlining | |
624 with the same of the foreground color. | |
625 If UNDERLINE is a string, underline with the color named UNDERLINE. | |
626 FRAME nil or not specified means change face on all frames. | |
627 Use `set-face-attribute' to ``unspecify'' underlining." | |
628 (interactive | |
629 (let ((list (read-face-and-attribute :underline))) | |
630 (list (car list) (eq (car (cdr list)) t)))) | |
631 (set-face-attribute face frame :underline underline)) | |
632 | |
633 | |
634 (defun set-face-underline-p (face underline-p &optional frame) | |
635 "Specify whether face FACE is underlined. | |
636 UNDERLINE-P nil means FACE explicitly doesn't underline. | |
637 UNDERLINE-P non-nil means FACE explicitly does underlining. | |
638 FRAME nil or not specified means change face on all frames. | |
639 Use `set-face-attribute' to ``unspecify'' underlining." | |
640 (interactive | |
641 (let ((list (read-face-and-attribute :underline))) | |
642 (list (car list) (eq (car (cdr list)) t)))) | |
643 (set-face-attribute face frame :underline underline-p)) | |
644 | |
645 | |
646 (defun set-face-inverse-video-p (face inverse-video-p &optional frame) | |
647 "Specify whether face FACE is in inverse video. | |
648 INVERSE-VIDEO-P non-nil means FACE displays explicitly in inverse video. | |
649 INVERSE-VIDEO-P nil means FACE explicitly is not in inverse video. | |
650 FRAME nil or not specified means change face on all frames. | |
651 Use `set-face-attribute' to ``unspecify'' the inverse video attribute." | |
652 (interactive | |
653 (let ((list (read-face-and-attribute :inverse-video))) | |
654 (list (car list) (eq (car (cdr list)) t)))) | |
655 (set-face-attribute face frame :inverse-video inverse-video-p)) | |
656 | |
657 | |
658 (defun set-face-bold-p (face bold-p &optional frame) | |
659 "Specify whether face FACE is bold. | |
660 BOLD-P non-nil means FACE should explicitly display bold. | |
661 BOLD-P nil means FACE should explicitly display non-bold. | |
662 FRAME nil or not specified means change face on all frames. | |
663 Use `set-face-attribute' or `modify-face' for finer control." | |
664 (if (null bold-p) | |
665 (make-face-unbold face frame) | |
666 (make-face-bold face frame))) | |
667 | |
668 | |
669 (defun set-face-italic-p (face italic-p &optional frame) | |
670 "Specify whether face FACE is italic. | |
671 ITALIC-P non-nil means FACE should explicitly display italic. | |
672 ITALIC-P nil means FACE should explicitly display non-italic. | |
673 FRAME nil or not specified means change face on all frames. | |
674 Use `set-face-attribute' or `modify-face' for finer control." | |
675 (if (null italic-p) | |
676 (make-face-unitalic face frame) | |
677 (make-face-italic face frame))) | |
678 | |
679 | |
680 (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
|
681 |
2456 | 682 |
683 (defun invert-face (face &optional frame) | |
25012 | 684 "Swap the foreground and background colors of FACE. |
685 FRAME nil or not specified means change face on all frames. | |
686 If FACE specifies neither foreground nor background color, | |
687 set its foreground and background to the background and foreground | |
688 of the default face. Value is FACE." | |
2456 | 689 (interactive (list (read-face-name "Invert face: "))) |
25012 | 690 (let ((fg (face-attribute face :foreground frame)) |
691 (bg (face-attribute face :background frame))) | |
2456 | 692 (if (or fg bg) |
25012 | 693 (set-face-attribute face frame :foreground bg :background fg) |
694 (set-face-attribute face frame | |
695 :foreground | |
696 (face-attribute 'default :background frame) | |
697 :background | |
698 (face-attribute 'default :foreground frame)))) | |
2456 | 699 face) |
700 | |
25012 | 701 |
702 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
703 ;;; Interactively modifying faces. | |
704 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
2456 | 705 |
25012 | 706 (defun read-face-name (prompt) |
707 "Read and return a face symbol, prompting with PROMPT. | |
708 Value is a symbol naming a known face." | |
709 (let ((face-list (mapcar #'(lambda (x) (cons (symbol-name x) x)) | |
710 (face-list))) | |
711 face) | |
712 (while (equal "" (setq face (completing-read prompt face-list nil t)))) | |
713 (intern face))) | |
714 | |
715 | |
716 (defun face-valid-attribute-values (attribute &optional frame) | |
717 "Return valid values for face attribute ATTRIBUTE. | |
718 The optional argument FRAME is used to determine available fonts | |
719 and colors. If it is nil or not specified, the selected frame is | |
720 used. Value is an alist of (NAME . VALUE) if ATTRIBUTE expects a value | |
721 out of a set of discrete values. Value is `integerp' if ATTRIBUTE expects | |
722 an integer value." | |
25245
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
723 (let (valid) |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
724 (setq valid |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
725 (case attribute |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
726 (:family |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
727 (if window-system |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
728 (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
|
729 (x-font-family-list)) |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
730 ;; Only one font on TTYs. |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
731 (list (cons "default" "default")))) |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
732 ((:width :weight :slant :inverse-video) |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
733 (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
|
734 (internal-lisp-face-attribute-values attribute))) |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
735 ((:underline :overline :strike-through :box) |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
736 (if window-system |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
737 (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
|
738 (internal-lisp-face-attribute-values attribute)) |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
739 (mapcar #'(lambda (c) (cons c c)) |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
740 (x-defined-colors frame))) |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
741 (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
|
742 (internal-lisp-face-attribute-values attribute)))) |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
743 ((:foreground :background) |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
744 (mapcar #'(lambda (c) (cons c c)) |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
745 (or (and window-system (x-defined-colors frame)) |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
746 (tty-defined-colors)))) |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
747 ((:height) |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
748 'integerp) |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
749 (:stipple |
25265
3aba9b200c5f
(face-valid-attribute-values): Look in
Eli Zaretskii <eliz@gnu.org>
parents:
25245
diff
changeset
|
750 (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
|
751 (mapcar #'list |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
752 (apply #'nconc (mapcar #'directory-files |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
753 x-bitmap-file-path))))) |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
754 (t |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
755 (error "Internal error")))) |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
756 (if (listp valid) |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
757 (nconc (list (cons "unspecified" 'unspecified)) valid) |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
758 valid))) |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
759 |
25012 | 760 |
761 | |
762 (defvar face-attribute-name-alist | |
763 '((:family . "font family") | |
764 (:width . "character set width") | |
765 (:height . "height in 1/10 pt") | |
766 (:weight . "weight") | |
767 (:slant . "slant") | |
768 (:underline . "underline") | |
769 (:overline . "overline") | |
770 (:strike-through . "strike-through") | |
771 (:box . "box") | |
772 (:inverse-video . "inverse-video display") | |
773 (:foreground . "foreground color") | |
774 (:background . "background color") | |
775 (:stipple . "background stipple")) | |
776 "An alist of descriptive names for face attributes. | |
777 Each element has the form (ATTRIBUTE-NAME . DESCRIPTION) where | |
778 ATTRIBUTE-NAME is a face attribute name (a keyword symbol), and | |
779 DESCRIPTION is a descriptive name for ATTRIBUTE-NAME.") | |
780 | |
781 | |
782 (defun face-descriptive-attribute-name (attribute) | |
783 "Return a descriptive name for ATTRIBUTE." | |
784 (cdr (assq attribute face-attribute-name-alist))) | |
785 | |
786 | |
787 (defun face-read-string (face default name &optional completion-alist) | |
788 "Interactively read a face attribute string value. | |
789 FACE is the face whose attribute is read. DEFAULT is the default | |
790 value to return if no new value is entered. NAME is a descriptive | |
791 name of the attribute for prompting. COMPLETION-ALIST is an alist | |
792 of valid values, if non-nil. | |
793 | |
25245
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
794 Entering nothing accepts the default value DEFAULT. |
25012 | 795 Value is the new attribute value." |
796 (let* ((completion-ignore-case t) | |
797 (value (completing-read | |
798 (if default | |
799 (format "Set face %s %s (default %s): " | |
800 face name (downcase (if (symbolp default) | |
801 (symbol-name default) | |
802 default))) | |
803 (format "Set face %s %s: " face name)) | |
804 completion-alist))) | |
25245
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
805 (if (equal value "") default value))) |
25012 | 806 |
807 | |
808 (defun face-read-integer (face default name) | |
809 "Interactively read an integer face attribute value. | |
810 FACE is the face whose attribute is read. DEFAULT is the default | |
811 value to return if no new value is entered. NAME is a descriptive | |
812 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
|
813 (let ((new-value |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
814 (face-read-string face |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
815 (if (eq default 'unspecified) |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
816 'unspecified |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
817 (int-to-string default)) |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
818 name |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
819 (list (cons "unspecified" 'unspecified))))) |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
820 (if (eq new-value 'unspecified) |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
821 new-value |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
822 (string-to-int new-value)))) |
25012 | 823 |
824 | |
825 (defun read-face-attribute (face attribute &optional frame) | |
826 "Interactively read a new value for FACE's ATTRIBUTE. | |
827 Optional argument FRAME nil or unspecified means read an attribute value | |
828 of a global face. Value is the new attribute value." | |
829 (let* ((old-value (face-attribute face attribute frame)) | |
830 (attribute-name (face-descriptive-attribute-name attribute)) | |
831 (valid (face-valid-attribute-values attribute frame)) | |
832 new-value) | |
833 ;; Represent complex attribute values as strings by printing them | |
834 ;; out. Stipple can be a vector; (WIDTH HEIGHT DATA). Box can be | |
835 ;; a list `(:width WIDTH :color COLOR)' or `(:width WIDTH :shadow | |
836 ;; SHADOW)'. | |
837 (when (and (or (eq attribute :stipple) | |
838 (eq attribute :box)) | |
839 (or (consp old-value) | |
840 (vectorp old-value))) | |
841 (setq old-value (prin1-to-string old-value))) | |
842 (cond ((listp valid) | |
843 (setq new-value | |
25245
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
844 (face-read-string face old-value attribute-name valid)) |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
845 (unless (eq new-value 'unspecified) |
ef080d2576f9
(face-valid-attribute-values): Return an alist for
Gerd Moellmann <gerd@gnu.org>
parents:
25210
diff
changeset
|
846 (setq new-value (cdr (assoc new-value valid))))) |
25012 | 847 ((eq valid 'integerp) |
848 (setq new-value (face-read-integer face old-value attribute-name))) | |
849 (t (error "Internal error"))) | |
850 ;; Convert stipple and box value text we read back to a list or | |
851 ;; vector if it looks like one. This makes the assumption that a | |
852 ;; pixmap file name won't start with an open-paren. | |
853 (when (and (or (eq attribute :stipple) | |
854 (eq attribute :box)) | |
855 (stringp new-value) | |
856 (string-match "^[[(]" new-value)) | |
857 (setq new-value (read new-value))) | |
858 new-value)) | |
859 | |
860 | |
861 (defun read-face-font (face &optional frame) | |
862 "Read the name of a font for FACE on FRAME. | |
863 If optional argument FRAME Is nil or omitted, use the selected frame." | |
864 (let ((completion-ignore-case t)) | |
865 (completing-read "Set font attributes of face %s from font: " | |
866 face (x-list-fonts "*" nil frame)))) | |
867 | |
868 | |
869 (defun read-all-face-attributes (face &optional frame) | |
870 "Interactively read all attributes for FACE. | |
871 If optional argument FRAME Is nil or omitted, use the selected frame. | |
872 Value is a property list of attribute names and new values." | |
873 (let (result) | |
874 (dolist (attribute face-attribute-name-alist result) | |
875 (setq result (cons (car attribute) | |
876 (cons (read-face-attribute face (car attribute) frame) | |
877 result)))))) | |
878 | |
879 | |
880 (defun modify-face (&optional frame) | |
881 "Modify attributes of faces interactively. | |
882 If optional argument FRAME is nil or omitted, modify the face used | |
883 for newly created frame, i.e. the global face." | |
884 (interactive) | |
885 (let ((face (read-face-name "Modify face: "))) | |
886 (apply #'set-face-attribute face frame | |
887 (read-all-face-attributes face frame)))) | |
888 | |
889 | |
890 (defun read-face-and-attribute (attribute &optional frame) | |
891 "Read face name and face attribute value. | |
892 ATTRIBUTE is the attribute whose new value is read. | |
893 FRAME nil or unspecified means read attribute value of global face. | |
894 Value is a list (FACE NEW-VALUE) where FACE is the face read | |
895 (a symbol), and NEW-VALUE is value read." | |
896 (cond ((eq attribute :font) | |
897 (let* ((prompt (format "Set font-related attributes of face: ")) | |
898 (face (read-face-name prompt)) | |
899 (font (read-face-font face frame))) | |
900 (list face font))) | |
901 (t | |
902 (let* ((attribute-name (face-descriptive-attribute-name attribute)) | |
903 (prompt (format "Set %s of face: " attribute-name)) | |
904 (face (read-face-name prompt)) | |
905 (new-value (read-face-attribute face attribute frame))) | |
906 (list face new-value))))) | |
907 | |
908 | |
909 | |
910 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
911 ;;; Listing faces. | |
912 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
913 | |
914 (defvar list-faces-sample-text | |
915 "abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ" | |
916 "*Text string to display as the sample text for `list-faces-display'.") | |
917 | |
918 | |
919 ;; The name list-faces would be more consistent, but let's avoid a | |
920 ;; conflict with Lucid, which uses that name differently. | |
921 | |
922 (defun list-faces-display () | |
923 "List all faces, using the same sample text in each. | |
924 The sample text is a string that comes from the variable | |
925 `list-faces-sample-text'." | |
926 (interactive) | |
927 (let ((faces (sort (face-list) #'string-lessp)) | |
928 (face nil) | |
929 (frame (selected-frame)) | |
930 disp-frame window) | |
931 (with-output-to-temp-buffer "*Faces*" | |
932 (save-excursion | |
933 (set-buffer standard-output) | |
934 (setq truncate-lines t) | |
935 (while faces | |
936 (setq face (car faces)) | |
937 (setq faces (cdr faces)) | |
938 (insert (format "%25s " (face-name face))) | |
939 (let ((beg (point))) | |
940 (insert list-faces-sample-text) | |
941 (insert "\n") | |
942 (put-text-property beg (1- (point)) 'face face) | |
943 ;; If the sample text has multiple lines, line up all of them. | |
944 (goto-char beg) | |
945 (forward-line 1) | |
946 (while (not (eobp)) | |
947 (insert " ") | |
948 (forward-line 1)))) | |
949 (goto-char (point-min))) | |
950 (print-help-return-message)) | |
951 ;; If the *Faces* buffer appears in a different frame, | |
952 ;; copy all the face definitions from FRAME, | |
953 ;; so that the display will reflect the frame that was selected. | |
954 (setq window (get-buffer-window (get-buffer "*Faces*") t)) | |
955 (setq disp-frame (if window (window-frame window) | |
956 (car (frame-list)))) | |
957 (or (eq frame disp-frame) | |
958 (let ((faces (face-list))) | |
959 (while faces | |
960 (copy-face (car faces) (car faces) frame disp-frame) | |
961 (setq faces (cdr faces))))))) | |
962 | |
963 | |
964 (defun describe-face (face &optional frame) | |
965 "Display the properties of face FACE on FRAME. | |
966 If the optional argument FRAME is given, report on face FACE in that frame. | |
967 If FRAME is t, report on the defaults for face FACE (for new frames). | |
968 If FRAME is omitted or nil, use the selected frame." | |
969 (interactive (list (read-face-name "Describe face: "))) | |
970 (let* ((attrs '((:family . "Family") | |
971 (:width . "Width") | |
972 (:height . "Height") | |
973 (:weight . "Weight") | |
974 (:slant . "Slant") | |
975 (:foreground . "Foreground") | |
976 (:background . "Background") | |
977 (:underline . "Underline") | |
978 (:overline . "Overline") | |
979 (:strike-through . "Strike-through") | |
980 (:box . "Box") | |
981 (:inverse-video . "Inverse") | |
982 (:stipple . "Stipple"))) | |
983 (max-width (apply #'max (mapcar #'(lambda (x) (length (cdr x))) | |
984 attrs)))) | |
985 (with-output-to-temp-buffer "*Help*" | |
986 (save-excursion | |
987 (set-buffer standard-output) | |
988 (dolist (a attrs) | |
989 (let ((attr (face-attribute face (car a) frame))) | |
990 (insert (make-string (- max-width (length (cdr a))) ?\ ) | |
991 (cdr a) ": " (format "%s" attr) "\n"))) | |
992 (insert "\nDocumentation:\n\n" | |
993 (or (face-documentation face) | |
994 "not documented as a face."))) | |
995 (print-help-return-message)))) | |
996 | |
997 | |
998 | |
2456 | 999 |
25012 | 1000 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1001 ;;; Face specifications (defface). | |
1002 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
1003 | |
1004 ;; Parameter FRAME Is kept for call compatibility to with previous | |
1005 ;; face implementation. | |
1006 | |
1007 (defun face-attr-construct (face &optional frame) | |
1008 "Return a defface-style attribute list for FACE on FRAME. | |
1009 Value is a property list of pairs ATTRIBUTE VALUE for all specified | |
1010 face attributes of FACE where ATTRIBUTE is the attribute name and | |
1011 VALUE is the specified value of that attribute." | |
1012 (let (result) | |
1013 (dolist (entry face-attribute-name-alist result) | |
1014 (let* ((attribute (car entry)) | |
1015 (value (face-attribute face attribute))) | |
1016 (unless (eq value 'unspecified) | |
1017 (setq result (nconc (list attribute value) result))))))) | |
1018 | |
1019 | |
1020 (defun face-spec-set-match-display (display frame) | |
1021 "Non-nil if DISPLAY matches FRAME. | |
1022 DISPLAY is part of a spec such as can be used in `defface'. | |
1023 If FRAME is nil, the current FRAME is used." | |
1024 (let* ((conjuncts display) | |
1025 conjunct req options | |
1026 ;; t means we have succeeded against all the conjuncts in | |
1027 ;; DISPLAY that have been tested so far. | |
1028 (match t)) | |
1029 (if (eq conjuncts t) | |
1030 (setq conjuncts nil)) | |
1031 (while (and conjuncts match) | |
1032 (setq conjunct (car conjuncts) | |
1033 conjuncts (cdr conjuncts) | |
1034 req (car conjunct) | |
1035 options (cdr conjunct) | |
1036 match (cond ((eq req 'type) | |
1037 (or (memq window-system options) | |
1038 (and (null window-system) | |
1039 (memq 'tty options)))) | |
1040 ((eq req 'class) | |
1041 (memq (frame-parameter frame 'display-type) options)) | |
1042 ((eq req 'background) | |
1043 (memq (frame-parameter frame 'background-mode) | |
1044 options)) | |
1045 (t (error "Unknown req `%S' with options `%S'" | |
1046 req options))))) | |
1047 match)) | |
1048 | |
1049 | |
1050 (defun face-spec-choose (spec &optional frame) | |
1051 "Choose the proper attributes for FRAME, out of SPEC." | |
1052 (unless frame | |
1053 (setq frame (selected-frame))) | |
1054 (let ((tail spec) | |
1055 result) | |
1056 (while tail | |
1057 (let* ((entry (car tail)) | |
1058 (display (nth 0 entry)) | |
1059 (attrs (nth 1 entry))) | |
1060 (setq tail (cdr tail)) | |
1061 (when (face-spec-set-match-display display frame) | |
1062 (setq result attrs tail nil)))) | |
1063 result)) | |
1064 | |
1065 | |
1066 (defun face-spec-reset-face (face &optional frame) | |
1067 "Reset all attributes of FACE on FRAME to unspecified." | |
1068 (let ((attrs face-attribute-name-alist) | |
1069 params) | |
1070 (while attrs | |
1071 (let ((attr-and-name (car attrs))) | |
1072 (setq params (cons (car attr-and-name) (cons 'unspecified params)))) | |
1073 (setq attrs (cdr attrs))) | |
1074 (apply #'set-face-attribute face frame params))) | |
1075 | |
1076 | |
1077 (defun face-spec-set (face spec &optional frame) | |
1078 "Set FACE's attributes according to the first matching entry in SPEC. | |
1079 FRAME is the frame whose frame-local face is set. FRAME nil means | |
1080 do it on all frames. See `defface' for information about SPEC." | |
1081 (let ((attrs (face-spec-choose spec frame)) | |
1082 params) | |
1083 (while attrs | |
1084 (let ((attribute (car attrs)) | |
1085 (value (car (cdr attrs)))) | |
1086 ;; Support some old-style attribute names and values. | |
1087 (case attribute | |
1088 (:bold (setq attribute :weight value (if value 'bold 'normal))) | |
1089 (:italic (setq attribute :slant value (if value 'italic 'normal)))) | |
1090 (setq params (cons attribute (cons value params)))) | |
1091 (setq attrs (cdr (cdr attrs)))) | |
1092 (face-spec-reset-face face frame) | |
1093 (apply #'set-face-attribute face frame params))) | |
1094 | |
1095 | |
1096 (defun face-attr-match-p (face attrs &optional frame) | |
1097 "Value is non-nil if attributes of FACE match values in plist ATTRS. | |
1098 Optional parameter FRAME is the frame whose definition of FACE | |
1099 is used. If nil or omitted, use the selected frame." | |
1100 (unless frame | |
1101 (setq frame (selected-frame))) | |
1102 (let ((list face-attribute-name-alist) | |
1103 (match t)) | |
1104 (while (and match (not (null list))) | |
1105 (let* ((attr (car (car list))) | |
1106 (specified-value (plist-get attrs attr)) | |
1107 (value-now (face-attribute face attr frame))) | |
1108 (when specified-value | |
1109 (setq match (equal specified-value value-now))) | |
1110 (setq list (cdr list)))) | |
1111 match)) | |
1112 | |
1113 | |
1114 (defun face-spec-match-p (face spec &optional frame) | |
1115 "Return t if FACE, on FRAME, matches what SPEC says it should look like." | |
1116 (face-attr-match-p face (face-spec-choose spec frame) frame)) | |
1117 | |
1118 | |
1119 | |
1120 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
1121 ;;; Background mode. | |
1122 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
1123 | |
1124 (defcustom frame-background-mode nil | |
1125 "*The brightness of the background. | |
1126 Set this to the symbol `dark' if your background color is dark, `light' if | |
1127 your background is light, or nil (default) if you want Emacs to | |
1128 examine the brightness for you." | |
1129 :group 'faces | |
1130 :set #'(lambda (var value) | |
1131 (set var value) | |
1132 (mapcar 'frame-set-background-mode (frame-list))) | |
1133 :initialize 'custom-initialize-changed | |
1134 :type '(choice (choice-item dark) | |
1135 (choice-item light) | |
1136 (choice-item :tag "default" nil))) | |
1137 | |
1138 | |
1139 (defun frame-set-background-mode (frame) | |
1140 "Set up the `background-mode' and `display-type' frame parameters for FRAME." | |
1141 (let* ((bg-resource | |
1142 (and window-system | |
1143 (x-get-resource ".backgroundMode" "BackgroundMode"))) | |
1144 (params (frame-parameters frame)) | |
1145 (bg-mode (cond (frame-background-mode) | |
1146 ((null window-system) | |
1147 ;; No way to determine this automatically (?). | |
1148 'dark) | |
1149 (bg-resource | |
1150 (intern (downcase bg-resource))) | |
1151 ((< (apply '+ (x-color-values | |
1152 (cdr (assq 'background-color | |
1153 params)) | |
1154 frame)) | |
1155 ;; Just looking at the screen, colors whose | |
1156 ;; values add up to .6 of the white total | |
1157 ;; still look dark to me. | |
1158 (* (apply '+ (x-color-values "white" frame)) .6)) | |
1159 'dark) | |
1160 (t 'light))) | |
1161 (display-type (cond ((null window-system) | |
1162 (if (tty-display-color-p) 'color 'mono)) | |
1163 ((x-display-color-p frame) | |
1164 'color) | |
1165 ((x-display-grayscale-p frame) | |
1166 'grayscale) | |
1167 (t 'mono)))) | |
1168 (modify-frame-parameters frame | |
1169 (list (cons 'background-mode bg-mode) | |
1170 (cons 'display-type display-type)))) | |
1171 | |
1172 ;; For all named faces, choose face specs matching the new frame | |
1173 ;; parameters. | |
1174 (let ((face-list (face-list))) | |
1175 (while face-list | |
1176 (let* ((face (car face-list)) | |
1177 (spec (get face 'face-defface-spec))) | |
1178 (when spec | |
1179 (face-spec-set face spec frame)) | |
1180 (setq face-list (cdr face-list)))))) | |
1181 | |
1182 | |
1183 | |
1184 | |
1185 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
1186 ;;; Frame creation. | |
1187 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
1188 | |
1189 (defun x-handle-named-frame-geometry (parameters) | |
1190 "Add geometry parameters for a named frame to parameter list PARAMETERS. | |
1191 Value is the new parameter list." | |
1192 (let* ((name (or (cdr (assq 'name parameters)) | |
1193 (cdr (assq 'name default-frame-alist)))) | |
1194 (x-resource-name name) | |
1195 (res-geometry (if name (x-get-resource "geometry" "Geometry")))) | |
1196 (when res-geometry | |
1197 (let ((parsed (x-parse-geometry res-geometry))) | |
1198 ;; If the resource specifies a position, call the position | |
1199 ;; and size "user-specified". | |
1200 (when (or (assq 'top parsed) | |
1201 (assq 'left parsed)) | |
1202 (setq parsed (append '((user-position . t) (user-size . t)) parsed))) | |
1203 ;; Put the geometry parameters at the end. Copy | |
1204 ;; default-frame-alist so that they go after it. | |
1205 (setq parameters (append parameters default-frame-alist parsed)))) | |
1206 parameters)) | |
1207 | |
1208 | |
1209 (defun x-handle-reverse-video (frame parameters) | |
1210 "Handle the reverse-video frame parameter and X resource. | |
1211 `x-create-frame' does not handle this one." | |
1212 (when (cdr (or (assq 'reverse parameters) | |
1213 (assq 'reverse default-frame-alist) | |
1214 (let ((resource (x-get-resource "reverseVideo" | |
1215 "ReverseVideo"))) | |
1216 (if resource | |
1217 (cons nil (member (downcase resource) | |
1218 '("on" "true"))))))) | |
1219 (let* ((params (frame-parameters frame)) | |
1220 (bg (cdr (assq 'foreground-color params))) | |
1221 (fg (cdr (assq 'background-color params)))) | |
1222 (modify-frame-parameters frame | |
1223 (list (cons 'foreground-color fg) | |
1224 (cons 'background-color bg))) | |
1225 (if (equal bg (cdr (assq 'border-color params))) | |
1226 (modify-frame-parameters frame | |
1227 (list (cons 'border-color fg)))) | |
1228 (if (equal bg (cdr (assq 'mouse-color params))) | |
1229 (modify-frame-parameters frame | |
1230 (list (cons 'mouse-color fg)))) | |
1231 (if (equal bg (cdr (assq 'cursor-color params))) | |
1232 (modify-frame-parameters frame | |
1233 (list (cons 'cursor-color fg))))))) | |
1234 | |
1235 | |
1236 (defun x-create-frame-with-faces (&optional parameters) | |
1237 "Create a frame from optional frame parameters PARAMETERS. | |
1238 Parameters not specified by PARAMETERS are taken from | |
1239 `default-frame-alist'. If PARAMETERS specify a frame name, | |
1240 handle X geometry resources for that name. If either PARAMETERS | |
1241 or `default-frame-alist' contains a `reverse' parameter, or | |
1242 the X resource ``reverseVideo'' is present, handle that. | |
1243 Value is the new frame created." | |
1244 (setq parameters (x-handle-named-frame-geometry parameters)) | |
1245 (let ((visibility-spec (assq 'visibility parameters)) | |
1246 (frame-list (frame-list)) | |
1247 (frame (x-create-frame (cons '(visibility . nil) parameters))) | |
1248 success) | |
1249 (unwind-protect | |
1250 (progn | |
1251 (x-handle-reverse-video frame parameters) | |
1252 (frame-set-background-mode frame) | |
1253 (face-set-after-frame-default frame) | |
1254 (if (or (null frame-list) (null visibility-spec)) | |
1255 (make-frame-visible frame) | |
1256 (modify-frame-parameters frame (list visibility-spec))) | |
1257 (setq success t)) | |
1258 (unless success | |
1259 (delete-frame frame))) | |
1260 frame)) | |
1261 | |
1262 | |
1263 (defun face-set-after-frame-default (frame) | |
1264 "Set frame-local faces of FRAME from face specs and resources." | |
1265 (dolist (face (face-list)) | |
1266 (let ((spec (or (get face 'saved-face) | |
1267 (get face 'face-defface-spec)))) | |
1268 (when spec | |
1269 (face-spec-set face spec frame)) | |
1270 (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
|
1271 (when (memq window-system '(x w32)) |
25012 | 1272 (make-face-x-resource-internal face frame))))) |
1273 | |
1274 | |
1275 (defun tty-create-frame-with-faces (&optional parameters) | |
1276 "Create a frame from optional frame parameters PARAMETERS. | |
1277 Parameters not specified by PARAMETERS are taken from | |
1278 `default-frame-alist'. If either PARAMETERS or `default-frame-alist' | |
1279 contains a `reverse' parameter, handle that. Value is the new frame | |
1280 created." | |
1281 (let ((frame (make-terminal-frame parameters)) | |
1282 success) | |
1283 (unwind-protect | |
1284 (progn | |
1285 (frame-set-background-mode frame) | |
1286 (face-set-after-frame-default frame) | |
1287 (setq success t)) | |
1288 (unless success | |
1289 (delete-frame frame))) | |
1290 frame)) | |
1291 | |
1292 | |
1293 ;; Called from C function init_display to initialize faces of the | |
1294 ;; dumped terminal frame on startup. | |
1295 | |
1296 (defun tty-set-up-initial-frame-faces () | |
1297 (let ((frame (selected-frame))) | |
1298 (frame-set-background-mode frame) | |
1299 (face-set-after-frame-default frame))) | |
1300 | |
1301 | |
1302 | |
1303 | |
1304 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
1305 ;;; Compatiblity with 20.2 | |
1306 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
1307 | |
1308 ;; Update a frame's faces when we change its default font. | |
1309 | |
1310 (defun frame-update-faces (frame) | |
1311 nil) | |
1312 | |
1313 | |
1314 ;; Update the colors of FACE, after FRAME's own colors have been | |
1315 ;; changed. | |
1316 | |
1317 (defun frame-update-face-colors (frame) | |
1318 (frame-set-background-mode frame)) | |
1319 | |
1320 | |
1321 | |
1322 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
1323 ;;; Standard faces. | |
1324 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
1325 | |
1326 ;; Make the standard faces. The C code knows faces `default', | |
1327 ;; `modeline', `toolbar' and `region', so they must be the first faces | |
1328 ;; made. Unspecified attributes of these three faces are filled-in | |
1329 ;; from frame parameters in the C code. | |
1330 | |
1331 (defgroup basic-faces nil | |
1332 "The standard faces of Emacs." | |
1333 :group 'faces) | |
1334 | |
1335 | |
1336 (defface default | |
1337 '((t nil)) | |
1338 "Basic default face." | |
1339 :group 'basic-faces) | |
1340 | |
1341 | |
1342 (defface modeline | |
1343 '((((type x) (class color)) | |
1344 (:box (:line-width 2 :style released-button) :background "grey75")) | |
1345 (t | |
1346 (:inverse-video t))) | |
1347 "Basic mode line face." | |
1348 :group 'basic-faces) | |
1349 | |
1350 | |
1351 (defface top-line | |
1352 '((((type x) (class color)) | |
1353 (:box (:line-width 2 :style released-button) :background "grey75")) | |
1354 (t | |
1355 (:inverse-video t))) | |
1356 "Basic top line face." | |
1357 :group 'basic-faces) | |
1358 | |
1359 | |
1360 (defface toolbar | |
1361 '((((type x) (class color)) | |
1362 (: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
|
1363 (((type x) (class mono)) |
4cd409210c7f
(toolbar): Add face definition for mono displays.
Gerd Moellmann <gerd@gnu.org>
parents:
25070
diff
changeset
|
1364 (:box (:line-width 1 :style released-button) :background "grey")) |
25012 | 1365 (t |
1366 ())) | |
1367 "Basic toolbar face." | |
1368 :group 'basic-faces) | |
1369 | |
1370 | |
1371 (defface region | |
1372 '((((type tty) (class color)) | |
1373 (:background "blue" :foreground "white")) | |
1374 (((type tty) (class mono)) | |
1375 (:inverse-video t)) | |
1376 (((class color) (background dark)) | |
1377 (:background "blue")) | |
1378 (((class color) (background light)) | |
1379 (:background "lightblue")) | |
1380 (t (:background "gray"))) | |
1381 "Basic face for highlight the region." | |
1382 :group 'basic-faces) | |
1383 | |
1384 | |
25384
fdefa56606aa
(margin): Renamed from bitmap-area.
Gerd Moellmann <gerd@gnu.org>
parents:
25265
diff
changeset
|
1385 (defface margin |
25012 | 1386 '((((class color)) |
1387 (:background "grey95")) | |
25070
b4b6828139fd
(bitmap-area): Change background to white for mono displays.
Gerd Moellmann <gerd@gnu.org>
parents:
25012
diff
changeset
|
1388 (((class mono)) |
b4b6828139fd
(bitmap-area): Change background to white for mono displays.
Gerd Moellmann <gerd@gnu.org>
parents:
25012
diff
changeset
|
1389 (:background "white")) |
b4b6828139fd
(bitmap-area): Change background to white for mono displays.
Gerd Moellmann <gerd@gnu.org>
parents:
25012
diff
changeset
|
1390 (t |
b4b6828139fd
(bitmap-area): Change background to white for mono displays.
Gerd Moellmann <gerd@gnu.org>
parents:
25012
diff
changeset
|
1391 (:background "gray"))) |
25384
fdefa56606aa
(margin): Renamed from bitmap-area.
Gerd Moellmann <gerd@gnu.org>
parents:
25265
diff
changeset
|
1392 "Basic face for the margins to the left and right of windows under X." |
25137 | 1393 :version "21.1" |
25012 | 1394 :group 'basic-faces) |
1395 | |
1396 | |
1397 (defface bold '((t (:weight bold))) | |
1398 "Basic bold face." | |
1399 :group 'basic-faces) | |
1400 | |
1401 | |
1402 (defface italic '((t (:slant italic))) | |
1403 "Basic italic font." | |
1404 :group 'basic-faces) | |
1405 | |
1406 | |
1407 (defface bold-italic '((t (:weight bold :slant italic))) | |
1408 "Basic bold-italic face." | |
1409 :group 'basic-faces) | |
1410 | |
1411 | |
1412 (defface underline '((t (:underline t))) | |
1413 "Basic underlined face." | |
1414 :group 'basic-faces) | |
1415 | |
1416 | |
1417 (defface highlight | |
1418 '((((type tty) (class color)) | |
1419 (:background "green")) | |
1420 (((class color) (background light)) | |
1421 (:background "darkseagreen2")) | |
1422 (((class color) (background dark)) | |
1423 (:background "darkolivegreen")) | |
1424 (t (:inverse-video t))) | |
1425 "Basic face for highlighting.") | |
1426 | |
1427 | |
1428 (defface secondary-selection | |
1429 '((((type tty) (class color)) | |
1430 (:background "cyan")) | |
1431 (((class color) (background light)) | |
1432 (:background "paleturquoise")) | |
1433 (((class color) (background dark)) | |
1434 (:background "darkslateblue")) | |
1435 (t (:inverse-video t))) | |
1436 "Basic face for displaying the secondary selection.") | |
1437 | |
1438 | |
1439 (defface fixed-pitch '((t (:family "courier*"))) | |
1440 "The basic fixed-pitch face." | |
1441 :group 'basic-faces) | |
1442 | |
1443 | |
1444 (defface variable-pitch '((t (:family "helv*"))) | |
1445 "The basic variable-pitch face." | |
1446 :group 'basic-faces) | |
1447 | |
1448 | |
1449 (defface trailing-whitespace | |
1450 '((((class color) (background light)) | |
1451 (:background "red")) | |
1452 (((class color) (background dark)) | |
1453 (:background "red")) | |
1454 (t (:inverse-video t))) | |
1455 "Basic face for highlighting trailing whitespace.") | |
1456 | |
1457 | |
1458 | |
1459 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
1460 ;;; Manipulating font names. | |
1461 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
1462 | |
1463 ;; This is here for compatibilty with Emacs 20.2. For example, | |
1464 ;; international/fontset.el uses these functions to manipulate font | |
1465 ;; names. The following functions are not used in the face | |
1466 ;; implementation itself. | |
2456 | 1467 |
16687
049c87a96dca
Change defconsts to defvars.
Richard M. Stallman <rms@gnu.org>
parents:
16590
diff
changeset
|
1468 (defvar x-font-regexp nil) |
049c87a96dca
Change defconsts to defvars.
Richard M. Stallman <rms@gnu.org>
parents:
16590
diff
changeset
|
1469 (defvar x-font-regexp-head nil) |
049c87a96dca
Change defconsts to defvars.
Richard M. Stallman <rms@gnu.org>
parents:
16590
diff
changeset
|
1470 (defvar x-font-regexp-weight nil) |
049c87a96dca
Change defconsts to defvars.
Richard M. Stallman <rms@gnu.org>
parents:
16590
diff
changeset
|
1471 (defvar x-font-regexp-slant nil) |
2456 | 1472 |
12668
7660e82d0346
(x-font-regexp-weight-subnum, x-font-regexp-slant-subnum)
Karl Heuer <kwzh@gnu.org>
parents:
12651
diff
changeset
|
1473 (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
|
1474 (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
|
1475 (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
|
1476 (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
|
1477 |
2456 | 1478 ;;; Regexps matching font names in "Host Portable Character Representation." |
1479 ;;; | |
1480 (let ((- "[-?]") | |
1481 (foundry "[^-]+") | |
1482 (family "[^-]+") | |
1483 (weight "\\(bold\\|demibold\\|medium\\)") ; 1 | |
1484 ; (weight\? "\\(\\*\\|bold\\|demibold\\|medium\\|\\)") ; 1 | |
1485 (weight\? "\\([^-]*\\)") ; 1 | |
1486 (slant "\\([ior]\\)") ; 2 | |
1487 ; (slant\? "\\([ior?*]?\\)") ; 2 | |
1488 (slant\? "\\([^-]?\\)") ; 2 | |
1489 ; (swidth "\\(\\*\\|normal\\|semicondensed\\|\\)") ; 3 | |
1490 (swidth "\\([^-]*\\)") ; 3 | |
1491 ; (adstyle "\\(\\*\\|sans\\|\\)") ; 4 | |
12690
e2d3fa52d100
(x-font-regexp): Add \\(\\) for substring extraction.
Karl Heuer <kwzh@gnu.org>
parents:
12668
diff
changeset
|
1492 (adstyle "\\([^-]*\\)") ; 4 |
2456 | 1493 (pixelsize "[0-9]+") |
1494 (pointsize "[0-9][0-9]+") | |
1495 (resx "[0-9][0-9]+") | |
1496 (resy "[0-9][0-9]+") | |
1497 (spacing "[cmp?*]") | |
1498 (avgwidth "[0-9]+") | |
1499 (registry "[^-]+") | |
1500 (encoding "[^-]+") | |
1501 ) | |
1502 (setq x-font-regexp | |
1503 (concat "\\`\\*?[-?*]" | |
1504 foundry - family - weight\? - slant\? - swidth - adstyle - | |
12475
eb436b0c4ab3
(x-font-regexp): Include the avgwidth.
Richard M. Stallman <rms@gnu.org>
parents:
12460
diff
changeset
|
1505 pixelsize - pointsize - resx - resy - spacing - avgwidth - |
eb436b0c4ab3
(x-font-regexp): Include the avgwidth.
Richard M. Stallman <rms@gnu.org>
parents:
12460
diff
changeset
|
1506 registry - encoding "\\*?\\'" |
2456 | 1507 )) |
1508 (setq x-font-regexp-head | |
1509 (concat "\\`[-?*]" foundry - family - weight\? - slant\? | |
1510 "\\([-*?]\\|\\'\\)")) | |
1511 (setq x-font-regexp-slant (concat - slant -)) | |
1512 (setq x-font-regexp-weight (concat - weight -)) | |
1513 nil) | |
1514 | |
25012 | 1515 |
3071
68de05fb5751
* faces.el (set-face-font): Call x-resolve-font-name on the font
Jim Blandy <jimb@redhat.com>
parents:
3049
diff
changeset
|
1516 (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
|
1517 "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
|
1518 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
|
1519 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
|
1520 contains wildcards. |
10170
5fc240a3e4a0
(face-initialize): Test for framep not t or nil.
Richard M. Stallman <rms@gnu.org>
parents:
10107
diff
changeset
|
1521 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
|
1522 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
|
1523 (or (symbolp face) |
28b2df35c33e
(x-resolve-font-name): Allow symbol as FACE arg.
Richard M. Stallman <rms@gnu.org>
parents:
3182
diff
changeset
|
1524 (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
|
1525 (and (eq frame t) |
28b2df35c33e
(x-resolve-font-name): Allow symbol as FACE arg.
Richard M. Stallman <rms@gnu.org>
parents:
3182
diff
changeset
|
1526 (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
|
1527 (if pattern |
5092
36508a7c0a3f
(x-resolve-font-name): Undo previous change.
Richard M. Stallman <rms@gnu.org>
parents:
5081
diff
changeset
|
1528 ;; 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
|
1529 (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
|
1530 (or fonts |
82c29bacb6b3
* faces.el (x-resolve-font-name): If PATTERN is nil, return the
Jim Blandy <jimb@redhat.com>
parents:
3071
diff
changeset
|
1531 (if face |
10584 | 1532 (if (string-match "\\*" pattern) |
1533 (if (null (face-font face)) | |
1534 (error "No matching fonts are the same height as the frame default font") | |
1535 (error "No matching fonts are the same height as face `%s'" face)) | |
1536 (if (null (face-font face)) | |
1537 (error "Height of font `%s' doesn't match the frame default font" | |
1538 pattern) | |
1539 (error "Height of font `%s' doesn't match face `%s'" | |
1540 pattern face))) | |
3353
8cbd38886eef
(x-resolve-font-name): Clean up error messages.
Richard M. Stallman <rms@gnu.org>
parents:
3298
diff
changeset
|
1541 (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
|
1542 (car fonts)) |
82c29bacb6b3
* faces.el (x-resolve-font-name): If PATTERN is nil, return the
Jim Blandy <jimb@redhat.com>
parents:
3071
diff
changeset
|
1543 (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
|
1544 |
25012 | 1545 |
2456 | 1546 (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
|
1547 (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
|
1548 (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
|
1549 (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
|
1550 (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
|
1551 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
|
1552 (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
|
1553 (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
|
1554 ;; 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
|
1555 ;; 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
|
1556 ;; 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
|
1557 "*" |
3dcaddea344a
Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents:
13609
diff
changeset
|
1558 (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
|
1559 ((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
|
1560 (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
|
1561 (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
|
1562 ((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
|
1563 (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
|
1564 (substring font (match-end 1))))))) |
2456 | 1565 |
25012 | 1566 |
2456 | 1567 (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
|
1568 (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
|
1569 (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
|
1570 (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
|
1571 (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
|
1572 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
|
1573 (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
|
1574 (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
|
1575 ;; 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
|
1576 ;; 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
|
1577 ;; 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
|
1578 "*" |
3dcaddea344a
Wrap case-fold-search for x-frob-font-weight and x-frob-font-slant.
Simon Marshall <simon@gnu.org>
parents:
13609
diff
changeset
|
1579 (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
|
1580 ((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
|
1581 (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
|
1582 (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
|
1583 ((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
|
1584 (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
|
1585 (substring font (match-end 1))))))) |
2456 | 1586 |
25012 | 1587 |
2456 | 1588 (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
|
1589 "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
|
1590 If that can't be done, return nil." |
2456 | 1591 (x-frob-font-weight font "bold")) |
1592 | |
25012 | 1593 |
2456 | 1594 (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
|
1595 "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
|
1596 If that can't be done, return nil." |
2456 | 1597 (x-frob-font-weight font "demibold")) |
1598 | |
25012 | 1599 |
2456 | 1600 (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
|
1601 "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
|
1602 If that can't be done, return nil." |
2456 | 1603 (x-frob-font-weight font "medium")) |
1604 | |
25012 | 1605 |
2456 | 1606 (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
|
1607 "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
|
1608 If that can't be done, return nil." |
2456 | 1609 (x-frob-font-slant font "i")) |
1610 | |
25012 | 1611 |
2456 | 1612 (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
|
1613 "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
|
1614 If that can't be done, return nil." |
2456 | 1615 (x-frob-font-slant font "o")) |
1616 | |
25012 | 1617 |
2456 | 1618 (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
|
1619 "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
|
1620 If that can't be done, return nil." |
2456 | 1621 (x-frob-font-slant font "r")) |
17752
2687f3d7c191
(x-make-font-bold-italic): New function.
Kenichi Handa <handa@m17n.org>
parents:
17560
diff
changeset
|
1622 |
25012 | 1623 |
17752
2687f3d7c191
(x-make-font-bold-italic): New function.
Kenichi Handa <handa@m17n.org>
parents:
17560
diff
changeset
|
1624 (defun x-make-font-bold-italic (font) |
2687f3d7c191
(x-make-font-bold-italic): New function.
Kenichi Handa <handa@m17n.org>
parents:
17560
diff
changeset
|
1625 "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
|
1626 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
|
1627 (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
|
1628 (x-make-font-italic font))) |
2456 | 1629 |
1630 | |
2715
9caee9338229
* faces.el: Call internal-set-face-1, not internat-set-face-1.
Jim Blandy <jimb@redhat.com>
parents:
2714
diff
changeset
|
1631 (provide 'faces) |
9caee9338229
* faces.el: Call internal-set-face-1, not internat-set-face-1.
Jim Blandy <jimb@redhat.com>
parents:
2714
diff
changeset
|
1632 |
25012 | 1633 ;;; end of faces.el |