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