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