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