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