Commit | Line | Data |
---|---|---|
5f5c8ee5 | 1 | ;;; faces.el --- Lisp faces |
465fceed | 2 | |
ba318903 | 3 | ;; Copyright (C) 1992-1996, 1998-2014 Free Software Foundation, Inc. |
465fceed | 4 | |
34dc21db | 5 | ;; Maintainer: emacs-devel@gnu.org |
30764597 | 6 | ;; Keywords: internal |
bd78fa1d | 7 | ;; Package: emacs |
6228c05b | 8 | |
465fceed ER |
9 | ;; This file is part of GNU Emacs. |
10 | ||
eb3fa2cf | 11 | ;; GNU Emacs is free software: you can redistribute it and/or modify |
465fceed | 12 | ;; it under the terms of the GNU General Public License as published by |
eb3fa2cf GM |
13 | ;; the Free Software Foundation, either version 3 of the License, or |
14 | ;; (at your option) any later version. | |
465fceed ER |
15 | |
16 | ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 | ;; GNU General Public License for more details. | |
20 | ||
21 | ;; You should have received a copy of the GNU General Public License | |
eb3fa2cf | 22 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
465fceed ER |
23 | |
24 | ;;; Commentary: | |
25 | ||
465fceed ER |
26 | ;;; Code: |
27 | ||
f18b81e6 GM |
28 | (defcustom term-file-prefix (purecopy "term/") |
29 | "If non-nil, Emacs startup performs terminal-specific initialization. | |
30 | It does this by: (load (concat term-file-prefix (getenv \"TERM\"))) | |
31 | ||
32 | You may set this variable to nil in your init file if you do not wish | |
33 | the terminal-initialization file to be loaded." | |
34 | :type '(choice (const :tag "No terminal-specific initialization" nil) | |
35 | (string :tag "Name of directory with term files")) | |
36 | :group 'terminals) | |
37 | ||
6638d67c GM |
38 | (defcustom term-file-aliases |
39 | '(("apollo" . "vt100") | |
40 | ("vt102" . "vt100") | |
41 | ("vt125" . "vt100") | |
42 | ("vt201" . "vt200") | |
43 | ("vt220" . "vt200") | |
44 | ("vt240" . "vt200") | |
45 | ("vt300" . "vt200") | |
46 | ("vt320" . "vt200") | |
47 | ("vt400" . "vt200") | |
48 | ("vt420" . "vt200") | |
49 | ) | |
50 | "Alist of terminal type aliases. | |
51 | Entries are of the form (TYPE . ALIAS), where both elements are strings. | |
52 | This means to treat a terminal of type TYPE as if it were of type ALIAS." | |
53 | :type '(alist :key-type (string :tag "Terminal") | |
54 | :value-type (string :tag "Alias")) | |
55 | :group 'terminals | |
56 | :version "24.5") | |
57 | ||
c8ccffb1 | 58 | (declare-function xw-defined-colors "term/common-win" (&optional frame)) |
5f5c8ee5 | 59 | |
b782a458 | 60 | (defvar help-xref-stack-item) |
2aef0850 JL |
61 | |
62 | (defvar face-name-history nil | |
63 | "History list for some commands that read face names. | |
64 | Maximum length of the history list is determined by the value | |
65 | of `history-length', which see.") | |
66 | ||
5f5c8ee5 GM |
67 | \f |
68 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
69 | ;;; Font selection. | |
70 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
71 | ||
72 | (defgroup font-selection nil | |
73 | "Influencing face font selection." | |
74 | :group 'faces) | |
75 | ||
76 | ||
77 | (defcustom face-font-selection-order | |
78 | '(:width :height :weight :slant) | |
9201cc28 | 79 | "A list specifying how face font selection chooses fonts. |
5f5c8ee5 GM |
80 | Each of the four symbols `:width', `:height', `:weight', and `:slant' |
81 | must appear once in the list, and the list must not contain any other | |
7c626e9d | 82 | elements. Font selection first tries to find a best matching font |
b73f65b6 | 83 | for those face attributes that appear before in the list. For |
5f5c8ee5 GM |
84 | example, if `:slant' appears before `:height', font selection first |
85 | tries to find a font with a suitable slant, even if this results in | |
86 | a font height that isn't optimal." | |
239ad97f | 87 | :tag "Font selection order" |
94354bdd | 88 | :type '(list symbol symbol symbol symbol) |
5f5c8ee5 GM |
89 | :group 'font-selection |
90 | :set #'(lambda (symbol value) | |
91 | (set-default symbol value) | |
92 | (internal-set-font-selection-order value))) | |
93 | ||
18f1dcb4 | 94 | |
ed008205 | 95 | ;; In the absence of Fontconfig support, Monospace and Sans Serif are |
80073c33 CY |
96 | ;; unavailable, and we fall back on the courier and helv families, |
97 | ;; which are generally available. | |
5f5c8ee5 | 98 | (defcustom face-font-family-alternatives |
1e8780b1 | 99 | (mapcar (lambda (arg) (mapcar 'purecopy arg)) |
d5f57335 | 100 | '(("Monospace" "courier" "fixed") |
f37a389e | 101 | ("courier" "CMU Typewriter Text" "fixed") |
ed008205 | 102 | ("Sans Serif" "helv" "helvetica" "arial" "fixed") |
1e8780b1 | 103 | ("helv" "helvetica" "arial" "fixed"))) |
9201cc28 | 104 | "Alist of alternative font family names. |
86886bce | 105 | Each element has the form (FAMILY ALTERNATIVE1 ALTERNATIVE2 ...). |
5f5c8ee5 GM |
106 | If fonts of family FAMILY can't be loaded, try ALTERNATIVE1, then |
107 | ALTERNATIVE2 etc." | |
239ad97f | 108 | :tag "Alternative font families to try" |
94354bdd | 109 | :type '(repeat (repeat string)) |
5f5c8ee5 GM |
110 | :group 'font-selection |
111 | :set #'(lambda (symbol value) | |
112 | (set-default symbol value) | |
113 | (internal-set-alternative-font-family-alist value))) | |
114 | ||
115 | ||
18f1dcb4 GM |
116 | ;; This is defined originally in xfaces.c. |
117 | (defcustom face-font-registry-alternatives | |
1e8780b1 | 118 | (mapcar (lambda (arg) (mapcar 'purecopy arg)) |
0fda9b75 | 119 | (if (featurep 'w32) |
990d68dd | 120 | '(("iso8859-1" "ms-oemlatin") |
e38c812e | 121 | ("gb2312.1980" "gb2312" "gbk" "gb18030") |
c97db4e4 AI |
122 | ("jisx0208.1990" "jisx0208.1983" "jisx0208.1978") |
123 | ("ksc5601.1989" "ksx1001.1992" "ksc5601.1987") | |
124 | ("muletibetan-2" "muletibetan-0")) | |
e38c812e | 125 | '(("gb2312.1980" "gb2312.80&gb8565.88" "gbk" "gb18030") |
c97db4e4 AI |
126 | ("jisx0208.1990" "jisx0208.1983" "jisx0208.1978") |
127 | ("ksc5601.1989" "ksx1001.1992" "ksc5601.1987") | |
1e8780b1 | 128 | ("muletibetan-2" "muletibetan-0")))) |
9201cc28 | 129 | "Alist of alternative font registry names. |
86886bce | 130 | Each element has the form (REGISTRY ALTERNATIVE1 ALTERNATIVE2 ...). |
8ac2d32f KH |
131 | If fonts of registry REGISTRY can be loaded, font selection |
132 | tries to find a best matching font among all fonts of registry | |
133 | REGISTRY, ALTERNATIVE1, ALTERNATIVE2, and etc." | |
239ad97f | 134 | :tag "Alternative font registries to try" |
18f1dcb4 | 135 | :type '(repeat (repeat string)) |
f676894c | 136 | :version "21.1" |
18f1dcb4 GM |
137 | :group 'font-selection |
138 | :set #'(lambda (symbol value) | |
139 | (set-default symbol value) | |
140 | (internal-set-alternative-font-registry-alist value))) | |
141 | ||
bdda3754 | 142 | \f |
5f5c8ee5 GM |
143 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
144 | ;;; Creation, copying. | |
145 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
146 | ||
147 | ||
148 | (defun face-list () | |
94ab793f | 149 | "Return a list of all defined faces." |
5f5c8ee5 GM |
150 | (mapcar #'car face-new-frame-defaults)) |
151 | ||
7f0f4c25 | 152 | (defun make-face (face) |
5f5c8ee5 | 153 | "Define a new face with name FACE, a symbol. |
fb5b8aca CY |
154 | Do not call this directly from Lisp code; use `defface' instead. |
155 | ||
7f0f4c25 | 156 | If FACE is already known as a face, leave it unmodified. Return FACE." |
2aef0850 JL |
157 | (interactive (list (read-from-minibuffer |
158 | "Make face: " nil nil t 'face-name-history))) | |
5f5c8ee5 GM |
159 | (unless (facep face) |
160 | ;; Make frame-local faces (this also makes the global one). | |
161 | (dolist (frame (frame-list)) | |
162 | (internal-make-lisp-face face frame)) | |
163 | ;; Add the face to the face menu. | |
164 | (when (fboundp 'facemenu-add-new-face) | |
165 | (facemenu-add-new-face face)) | |
166 | ;; Define frame-local faces for all frames from X resources. | |
7f0f4c25 | 167 | (make-face-x-resource-internal face)) |
5f5c8ee5 GM |
168 | face) |
169 | ||
5f5c8ee5 GM |
170 | (defun make-empty-face (face) |
171 | "Define a new, empty face with name FACE. | |
fb5b8aca | 172 | Do not call this directly from Lisp code; use `defface' instead." |
2aef0850 JL |
173 | (interactive (list (read-from-minibuffer |
174 | "Make empty face: " nil nil t 'face-name-history))) | |
3197074e | 175 | (make-face face)) |
5f5c8ee5 | 176 | |
5f5c8ee5 | 177 | (defun copy-face (old-face new-face &optional frame new-frame) |
fb5b8aca CY |
178 | "Define a face named NEW-FACE, which is a copy of OLD-FACE. |
179 | This function does not copy face customization data, so NEW-FACE | |
180 | will not be made customizable. Most Lisp code should not call | |
181 | this function; use `defface' with :inherit instead. | |
182 | ||
183 | If NEW-FACE already exists as a face, modify it to be like | |
184 | OLD-FACE. If NEW-FACE doesn't already exist, create it. | |
185 | ||
186 | If the optional argument FRAME is a frame, change NEW-FACE on | |
187 | FRAME only. If FRAME is t, copy the frame-independent default | |
188 | specification for OLD-FACE to NEW-FACE. If FRAME is nil, copy | |
189 | the defaults as well as the faces on each existing frame. | |
190 | ||
191 | If the optional fourth argument NEW-FRAME is given, copy the | |
192 | information from face OLD-FACE on frame FRAME to NEW-FACE on | |
193 | frame NEW-FRAME. In this case, FRAME must not be nil." | |
5f5c8ee5 GM |
194 | (let ((inhibit-quit t)) |
195 | (if (null frame) | |
196 | (progn | |
341a1bfb RS |
197 | (when new-frame |
198 | (error "Copying face %s from all frames to one frame" | |
199 | old-face)) | |
200 | (make-empty-face new-face) | |
5f5c8ee5 GM |
201 | (dolist (frame (frame-list)) |
202 | (copy-face old-face new-face frame)) | |
203 | (copy-face old-face new-face t)) | |
341a1bfb | 204 | (make-empty-face new-face) |
5f5c8ee5 GM |
205 | (internal-copy-lisp-face old-face new-face frame new-frame)) |
206 | new-face)) | |
207 | ||
5f5c8ee5 GM |
208 | \f |
209 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
210 | ;;; Predicates, type checks. | |
211 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
212 | ||
213 | (defun facep (face) | |
20d29b0b RS |
214 | "Return non-nil if FACE is a face name; nil otherwise. |
215 | A face name can be a string or a symbol." | |
5f5c8ee5 GM |
216 | (internal-lisp-face-p face)) |
217 | ||
218 | ||
219 | (defun check-face (face) | |
220 | "Signal an error if FACE doesn't name a face. | |
221 | Value is FACE." | |
222 | (unless (facep face) | |
223 | (error "Not a face: %s" face)) | |
224 | face) | |
225 | ||
226 | ||
227 | ;; The ID returned is not to be confused with the internally used IDs | |
228 | ;; of realized faces. The ID assigned to Lisp faces is used to | |
229 | ;; support faces in display table entries. | |
230 | ||
06b60517 | 231 | (defun face-id (face &optional _frame) |
2df447f2 | 232 | "Return the internal ID of face with name FACE. |
b2d5aa46 | 233 | If FACE is a face-alias, return the ID of the target face. |
9ae89a1a RS |
234 | The optional argument FRAME is ignored, since the internal face ID |
235 | of a face name is the same for all frames." | |
5f5c8ee5 | 236 | (check-face face) |
b2d5aa46 JB |
237 | (or (get face 'face) |
238 | (face-id (get face 'face-alias)))) | |
5f5c8ee5 GM |
239 | |
240 | (defun face-equal (face1 face2 &optional frame) | |
241 | "Non-nil if faces FACE1 and FACE2 are equal. | |
242 | Faces are considered equal if all their attributes are equal. | |
a09be93a JB |
243 | If the optional argument FRAME is given, report on FACE1 and FACE2 in that frame. |
244 | If FRAME is t, report on the defaults for FACE1 and FACE2 (for new frames). | |
5f5c8ee5 GM |
245 | If FRAME is omitted or nil, use the selected frame." |
246 | (internal-lisp-face-equal-p face1 face2 frame)) | |
247 | ||
248 | ||
249 | (defun face-differs-from-default-p (face &optional frame) | |
7e07a66d | 250 | "Return non-nil if FACE displays differently from the default face. |
5f5c8ee5 GM |
251 | If the optional argument FRAME is given, report on face FACE in that frame. |
252 | If FRAME is t, report on the defaults for face FACE (for new frames). | |
7e07a66d | 253 | If FRAME is omitted or nil, use the selected frame." |
1151d617 | 254 | (let ((attrs |
833547aa | 255 | (delq :inherit (mapcar 'car face-attribute-name-alist))) |
1151d617 MB |
256 | (differs nil)) |
257 | (while (and attrs (not differs)) | |
258 | (let* ((attr (pop attrs)) | |
259 | (attr-val (face-attribute face attr frame t))) | |
260 | (when (and | |
261 | (not (eq attr-val 'unspecified)) | |
262 | (display-supports-face-attributes-p (list attr attr-val) | |
263 | frame)) | |
264 | (setq differs attr)))) | |
265 | differs)) | |
5f5c8ee5 GM |
266 | |
267 | ||
268 | (defun face-nontrivial-p (face &optional frame) | |
269 | "True if face FACE has some non-nil attribute. | |
270 | If the optional argument FRAME is given, report on face FACE in that frame. | |
271 | If FRAME is t, report on the defaults for face FACE (for new frames). | |
272 | If FRAME is omitted or nil, use the selected frame." | |
273 | (not (internal-lisp-face-empty-p face frame))) | |
274 | ||
275 | ||
276 | \f | |
277 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
278 | ;;; Setting face attributes from X resources. | |
279 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
280 | ||
281 | (defcustom face-x-resources | |
1e8780b1 DN |
282 | (mapcar |
283 | (lambda (arg) | |
284 | ;; FIXME; can we purecopy some of the conses too? | |
e8e4d5c8 SS |
285 | (cons (car arg) |
286 | (cons (purecopy (car (cdr arg))) (purecopy (cdr (cdr arg)))))) | |
5f5c8ee5 | 287 | '((:family (".attributeFamily" . "Face.AttributeFamily")) |
fcea6e23 | 288 | (:foundry (".attributeFoundry" . "Face.AttributeFoundry")) |
5f5c8ee5 GM |
289 | (:width (".attributeWidth" . "Face.AttributeWidth")) |
290 | (:height (".attributeHeight" . "Face.AttributeHeight")) | |
291 | (:weight (".attributeWeight" . "Face.AttributeWeight")) | |
292 | (:slant (".attributeSlant" . "Face.AttributeSlant")) | |
293 | (:foreground (".attributeForeground" . "Face.AttributeForeground")) | |
3c334c14 JD |
294 | (:distant-foreground |
295 | (".attributeDistantForeground" . "Face.AttributeDistantForeground")) | |
5f5c8ee5 GM |
296 | (:background (".attributeBackground" . "Face.AttributeBackground")) |
297 | (:overline (".attributeOverline" . "Face.AttributeOverline")) | |
298 | (:strike-through (".attributeStrikeThrough" . "Face.AttributeStrikeThrough")) | |
299 | (:box (".attributeBox" . "Face.AttributeBox")) | |
300 | (:underline (".attributeUnderline" . "Face.AttributeUnderline")) | |
301 | (:inverse-video (".attributeInverse" . "Face.AttributeInverse")) | |
302 | (:stipple | |
303 | (".attributeStipple" . "Face.AttributeStipple") | |
304 | (".attributeBackgroundPixmap" . "Face.AttributeBackgroundPixmap")) | |
5f5c8ee5 GM |
305 | (:bold (".attributeBold" . "Face.AttributeBold")) |
306 | (:italic (".attributeItalic" . "Face.AttributeItalic")) | |
a0e5a5a4 | 307 | (:font (".attributeFont" . "Face.AttributeFont")) |
1e8780b1 | 308 | (:inherit (".attributeInherit" . "Face.AttributeInherit")))) |
9201cc28 | 309 | "List of X resources and classes for face attributes. |
5f5c8ee5 GM |
310 | Each element has the form (ATTRIBUTE ENTRY1 ENTRY2...) where ATTRIBUTE is |
311 | the name of a face attribute, and each ENTRY is a cons of the form | |
2cb95d1b | 312 | \(RESOURCE . CLASS) with RESOURCE being the resource and CLASS being the |
5f5c8ee5 | 313 | X resource class for the attribute." |
b5325e78 | 314 | :type '(repeat (cons symbol (repeat (cons string string)))) |
5f5c8ee5 GM |
315 | :group 'faces) |
316 | ||
317 | ||
aa360da1 | 318 | (declare-function internal-face-x-get-resource "xfaces.c" |
f20def1f | 319 | (resource class &optional frame)) |
aa360da1 GM |
320 | |
321 | (declare-function internal-set-lisp-face-attribute-from-resource "xfaces.c" | |
322 | (face attr value &optional frame)) | |
323 | ||
5f5c8ee5 GM |
324 | (defun set-face-attribute-from-resource (face attribute resource class frame) |
325 | "Set FACE's ATTRIBUTE from X resource RESOURCE, class CLASS on FRAME. | |
326 | Value is the attribute value specified by the resource, or nil | |
327 | if not present. This function displays a message if the resource | |
328 | specifies an invalid attribute." | |
329 | (let* ((face-name (face-name face)) | |
330 | (value (internal-face-x-get-resource (concat face-name resource) | |
331 | class frame))) | |
332 | (when value | |
333 | (condition-case () | |
334 | (internal-set-lisp-face-attribute-from-resource | |
335 | face attribute (downcase value) frame) | |
336 | (error | |
337 | (message "Face %s, frame %s: invalid attribute %s %s from X resource" | |
338 | face-name frame attribute value)))) | |
339 | value)) | |
340 | ||
341 | ||
342 | (defun set-face-attributes-from-resources (face frame) | |
343 | "Set attributes of FACE from X resources for FRAME." | |
e51fe00a | 344 | (when (memq (framep frame) '(x w32)) |
5f5c8ee5 GM |
345 | (dolist (definition face-x-resources) |
346 | (let ((attribute (car definition))) | |
347 | (dolist (entry (cdr definition)) | |
348 | (set-face-attribute-from-resource face attribute (car entry) | |
349 | (cdr entry) frame)))))) | |
00f51890 SS |
350 | |
351 | ||
5f5c8ee5 GM |
352 | (defun make-face-x-resource-internal (face &optional frame) |
353 | "Fill frame-local FACE on FRAME from X resources. | |
f5e4494c MD |
354 | FRAME nil or not specified means do it for all frames. |
355 | ||
356 | If `inhibit-x-resources' is non-nil, this function does nothing." | |
357 | (unless inhibit-x-resources | |
358 | (dolist (frame (if (null frame) (frame-list) (list frame))) | |
359 | ;; `x-create-frame' already took care of correctly handling | |
360 | ;; the reverse video case-- do _not_ touch the default face | |
361 | (unless (and (eq face 'default) | |
362 | (frame-parameter frame 'reverse)) | |
363 | (set-face-attributes-from-resources face frame))))) | |
5f5c8ee5 GM |
364 | |
365 | ||
366 | \f | |
367 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
368 | ;;; Retrieving face attributes. | |
369 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
370 | ||
feaad827 | 371 | (defun face-name (face) |
465fceed | 372 | "Return the name of face FACE." |
5f5c8ee5 GM |
373 | (symbol-name (check-face face))) |
374 | ||
375 | ||
833547aa RS |
376 | (defun face-all-attributes (face &optional frame) |
377 | "Return an alist stating the attributes of FACE. | |
378 | Each element of the result has the form (ATTR-NAME . ATTR-VALUE). | |
37766706 | 379 | If FRAME is omitted or nil the value describes the default attributes, |
833547aa RS |
380 | but if you specify FRAME, the value describes the attributes |
381 | of FACE on FRAME." | |
606c9f59 RS |
382 | (mapcar (lambda (pair) |
383 | (let ((attr (car pair))) | |
384 | (cons attr (face-attribute face attr (or frame t))))) | |
833547aa RS |
385 | face-attribute-name-alist)) |
386 | ||
c7f814cb | 387 | (defun face-attribute (face attribute &optional frame inherit) |
5f5c8ee5 GM |
388 | "Return the value of FACE's ATTRIBUTE on FRAME. |
389 | If the optional argument FRAME is given, report on face FACE in that frame. | |
390 | If FRAME is t, report on the defaults for face FACE (for new frames). | |
c7f814cb | 391 | If FRAME is omitted or nil, use the selected frame. |
5f5c8ee5 | 392 | |
c7f814cb MB |
393 | If INHERIT is nil, only attributes directly defined by FACE are considered, |
394 | so the return value may be `unspecified', or a relative value. | |
395 | If INHERIT is non-nil, FACE's definition of ATTRIBUTE is merged with the | |
396 | faces specified by its `:inherit' attribute; however the return value | |
397 | may still be `unspecified' or relative. | |
398 | If INHERIT is a face or a list of faces, then the result is further merged | |
399 | with that face (or faces), until it becomes specified and absolute. | |
400 | ||
401 | To ensure that the return value is always specified and absolute, use a | |
402 | value of `default' for INHERIT; this will resolve any unspecified or | |
403 | relative values by merging with the `default' face (which is always | |
404 | completely specified)." | |
405 | (let ((value (internal-get-lisp-face-attribute face attribute frame))) | |
406 | (when (and inherit (face-attribute-relative-p attribute value)) | |
407 | ;; VALUE is relative, so merge with inherited faces | |
408 | (let ((inh-from (face-attribute face :inherit frame))) | |
409 | (unless (or (null inh-from) (eq inh-from 'unspecified)) | |
621e71ee SM |
410 | (condition-case nil |
411 | (setq value | |
412 | (face-attribute-merged-with attribute value inh-from frame)) | |
413 | ;; The `inherit' attribute may point to non existent faces. | |
414 | (error nil))))) | |
c7f814cb MB |
415 | (when (and inherit |
416 | (not (eq inherit t)) | |
417 | (face-attribute-relative-p attribute value)) | |
b6b90dfc | 418 | ;; We should merge with INHERIT as well |
c7f814cb MB |
419 | (setq value (face-attribute-merged-with attribute value inherit frame))) |
420 | value)) | |
5f5c8ee5 | 421 | |
c7f814cb MB |
422 | (defun face-attribute-merged-with (attribute value faces &optional frame) |
423 | "Merges ATTRIBUTE, initially VALUE, with faces from FACES until absolute. | |
424 | FACES may be either a single face or a list of faces. | |
522fb950 | 425 | \[This is an internal function.]" |
c7f814cb MB |
426 | (cond ((not (face-attribute-relative-p attribute value)) |
427 | value) | |
428 | ((null faces) | |
429 | value) | |
430 | ((consp faces) | |
431 | (face-attribute-merged-with | |
432 | attribute | |
433 | (face-attribute-merged-with attribute value (car faces) frame) | |
434 | (cdr faces) | |
435 | frame)) | |
436 | (t | |
437 | (merge-face-attribute attribute | |
438 | value | |
439 | (face-attribute faces attribute frame t))))) | |
440 | ||
441 | ||
442 | (defmacro face-attribute-specified-or (value &rest body) | |
443 | "Return VALUE, unless it's `unspecified', in which case evaluate BODY and return the result." | |
444 | (let ((temp (make-symbol "value"))) | |
445 | `(let ((,temp ,value)) | |
446 | (if (not (eq ,temp 'unspecified)) | |
447 | ,temp | |
448 | ,@body)))) | |
449 | ||
450 | (defun face-foreground (face &optional frame inherit) | |
5f5c8ee5 GM |
451 | "Return the foreground color name of FACE, or nil if unspecified. |
452 | If the optional argument FRAME is given, report on face FACE in that frame. | |
453 | If FRAME is t, report on the defaults for face FACE (for new frames). | |
c7f814cb | 454 | If FRAME is omitted or nil, use the selected frame. |
5f5c8ee5 | 455 | |
c7f814cb MB |
456 | If INHERIT is nil, only a foreground color directly defined by FACE is |
457 | considered, so the return value may be nil. | |
458 | If INHERIT is t, and FACE doesn't define a foreground color, then any | |
459 | foreground color that FACE inherits through its `:inherit' attribute | |
460 | is considered as well; however the return value may still be nil. | |
461 | If INHERIT is a face or a list of faces, then it is used to try to | |
462 | resolve an unspecified foreground color. | |
463 | ||
464 | To ensure that a valid color is always returned, use a value of | |
465 | `default' for INHERIT; this will resolve any unspecified values by | |
466 | merging with the `default' face (which is always completely specified)." | |
467 | (face-attribute-specified-or (face-attribute face :foreground frame inherit) | |
468 | nil)) | |
469 | ||
470 | (defun face-background (face &optional frame inherit) | |
5f5c8ee5 GM |
471 | "Return the background color name of FACE, or nil if unspecified. |
472 | If the optional argument FRAME is given, report on face FACE in that frame. | |
473 | If FRAME is t, report on the defaults for face FACE (for new frames). | |
c7f814cb | 474 | If FRAME is omitted or nil, use the selected frame. |
5f5c8ee5 | 475 | |
c7f814cb MB |
476 | If INHERIT is nil, only a background color directly defined by FACE is |
477 | considered, so the return value may be nil. | |
478 | If INHERIT is t, and FACE doesn't define a background color, then any | |
479 | background color that FACE inherits through its `:inherit' attribute | |
480 | is considered as well; however the return value may still be nil. | |
481 | If INHERIT is a face or a list of faces, then it is used to try to | |
482 | resolve an unspecified background color. | |
483 | ||
484 | To ensure that a valid color is always returned, use a value of | |
485 | `default' for INHERIT; this will resolve any unspecified values by | |
486 | merging with the `default' face (which is always completely specified)." | |
487 | (face-attribute-specified-or (face-attribute face :background frame inherit) | |
488 | nil)) | |
489 | ||
490 | (defun face-stipple (face &optional frame inherit) | |
5f5c8ee5 GM |
491 | "Return the stipple pixmap name of FACE, or nil if unspecified. |
492 | If the optional argument FRAME is given, report on face FACE in that frame. | |
493 | If FRAME is t, report on the defaults for face FACE (for new frames). | |
c7f814cb MB |
494 | If FRAME is omitted or nil, use the selected frame. |
495 | ||
496 | If INHERIT is nil, only a stipple directly defined by FACE is | |
497 | considered, so the return value may be nil. | |
498 | If INHERIT is t, and FACE doesn't define a stipple, then any stipple | |
499 | that FACE inherits through its `:inherit' attribute is considered as | |
500 | well; however the return value may still be nil. | |
501 | If INHERIT is a face or a list of faces, then it is used to try to | |
502 | resolve an unspecified stipple. | |
503 | ||
504 | To ensure that a valid stipple or nil is always returned, use a value of | |
505 | `default' for INHERIT; this will resolve any unspecified values by merging | |
506 | with the `default' face (which is always completely specified)." | |
507 | (face-attribute-specified-or (face-attribute face :stipple frame inherit) | |
508 | nil)) | |
5f5c8ee5 GM |
509 | |
510 | ||
511 | (defalias 'face-background-pixmap 'face-stipple) | |
512 | ||
513 | ||
1bf335cf | 514 | (defun face-underline-p (face &optional frame inherit) |
bde3c6c0 | 515 | "Return non-nil if FACE specifies a non-nil underlining. |
5f5c8ee5 GM |
516 | If the optional argument FRAME is given, report on face FACE in that frame. |
517 | If FRAME is t, report on the defaults for face FACE (for new frames). | |
1bf335cf GM |
518 | If FRAME is omitted or nil, use the selected frame. |
519 | Optional argument INHERIT is passed to `face-attribute'." | |
520 | (face-attribute-specified-or | |
521 | (face-attribute face :underline frame inherit) nil)) | |
5f5c8ee5 GM |
522 | |
523 | ||
1bf335cf | 524 | (defun face-inverse-video-p (face &optional frame inherit) |
bde3c6c0 | 525 | "Return non-nil if FACE specifies a non-nil inverse-video. |
5f5c8ee5 GM |
526 | If the optional argument FRAME is given, report on face FACE in that frame. |
527 | If FRAME is t, report on the defaults for face FACE (for new frames). | |
1bf335cf GM |
528 | If FRAME is omitted or nil, use the selected frame. |
529 | Optional argument INHERIT is passed to `face-attribute'." | |
530 | (eq (face-attribute face :inverse-video frame inherit) t)) | |
5f5c8ee5 GM |
531 | |
532 | ||
1bf335cf | 533 | (defun face-bold-p (face &optional frame inherit) |
5f5c8ee5 GM |
534 | "Return non-nil if the font of FACE is bold on FRAME. |
535 | If the optional argument FRAME is given, report on face FACE in that frame. | |
536 | If FRAME is t, report on the defaults for face FACE (for new frames). | |
537 | If FRAME is omitted or nil, use the selected frame. | |
1bf335cf | 538 | Optional argument INHERIT is passed to `face-attribute'. |
5f5c8ee5 | 539 | Use `face-attribute' for finer control." |
1bf335cf | 540 | (let ((bold (face-attribute face :weight frame inherit))) |
da2c7b8c | 541 | (memq bold '(semi-bold bold extra-bold ultra-bold)))) |
5f5c8ee5 GM |
542 | |
543 | ||
1bf335cf | 544 | (defun face-italic-p (face &optional frame inherit) |
5f5c8ee5 GM |
545 | "Return non-nil if the font of FACE is italic on FRAME. |
546 | If the optional argument FRAME is given, report on face FACE in that frame. | |
547 | If FRAME is t, report on the defaults for face FACE (for new frames). | |
548 | If FRAME is omitted or nil, use the selected frame. | |
1bf335cf | 549 | Optional argument INHERIT is passed to `face-attribute'. |
5f5c8ee5 | 550 | Use `face-attribute' for finer control." |
1bf335cf | 551 | (let ((italic (face-attribute face :slant frame inherit))) |
a48f6020 | 552 | (memq italic '(italic oblique)))) |
00f51890 | 553 | |
5f5c8ee5 | 554 | |
5f5c8ee5 GM |
555 | \f |
556 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
557 | ;;; Face documentation. | |
558 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
559 | ||
560 | (defun face-documentation (face) | |
9a558a07 GM |
561 | "Get the documentation string for FACE. |
562 | If FACE is a face-alias, get the documentation for the target face." | |
5e400cb3 | 563 | (let ((alias (get face 'face-alias))) |
9a558a07 | 564 | (if alias |
5e400cb3 | 565 | (let ((doc (get alias 'face-documentation))) |
3446bfc8 | 566 | (format "%s is an alias for the face `%s'.%s" face alias |
9a558a07 GM |
567 | (if doc (format "\n%s" doc) |
568 | ""))) | |
569 | (get face 'face-documentation)))) | |
5f5c8ee5 GM |
570 | |
571 | ||
572 | (defun set-face-documentation (face string) | |
573 | "Set the documentation string for FACE to STRING." | |
291cfb96 | 574 | ;; Perhaps the text should go in DOC. |
49435801 | 575 | (put face 'face-documentation (purecopy string))) |
5f5c8ee5 GM |
576 | |
577 | ||
578 | (defalias 'face-doc-string 'face-documentation) | |
579 | (defalias 'set-face-doc-string 'set-face-documentation) | |
580 | ||
581 | ||
582 | \f | |
583 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
584 | ;; Setting face attributes. | |
585 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
586 | ||
587 | ||
588 | (defun set-face-attribute (face frame &rest args) | |
589 | "Set attributes of FACE on FRAME from ARGS. | |
4b56d0fe CY |
590 | This function overrides the face attributes specified by FACE's |
591 | face spec. It is mostly intended for internal use only. | |
5f5c8ee5 | 592 | |
4b56d0fe CY |
593 | If FRAME is nil, set the attributes for all existing frames, as |
594 | well as the default for new frames. If FRAME is t, change the | |
595 | default for new frames only. | |
5f5c8ee5 | 596 | |
4b56d0fe CY |
597 | ARGS must come in pairs ATTRIBUTE VALUE. ATTRIBUTE must be a |
598 | valid face attribute name. All attributes can be set to | |
599 | `unspecified'; this fact is not further mentioned below. | |
5f5c8ee5 GM |
600 | |
601 | The following attributes are recognized: | |
602 | ||
603 | `:family' | |
604 | ||
4b56d0fe CY |
605 | VALUE must be a string specifying the font family |
606 | \(e.g. \"Monospace\") or a fontset. | |
5f5c8ee5 | 607 | |
fcea6e23 KH |
608 | `:foundry' |
609 | ||
610 | VALUE must be a string specifying the font foundry, | |
611 | e.g. ``adobe''. If a font foundry is specified, wild-cards `*' | |
612 | and `?' are allowed. | |
613 | ||
5f5c8ee5 GM |
614 | `:width' |
615 | ||
616 | VALUE specifies the relative proportionate width of the font to use. | |
617 | It must be one of the symbols `ultra-condensed', `extra-condensed', | |
618 | `condensed', `semi-condensed', `normal', `semi-expanded', `expanded', | |
619 | `extra-expanded', or `ultra-expanded'. | |
620 | ||
621 | `:height' | |
622 | ||
4b56d0fe CY |
623 | VALUE specifies the relative or absolute height of the font. An |
624 | absolute height is an integer, and specifies font height in units | |
625 | of 1/10 pt. A relative height is either a floating point number, | |
95838641 | 626 | which specifies a scaling factor for the underlying face height; |
4b56d0fe CY |
627 | or a function that takes a single argument (the underlying face |
628 | height) and returns the new height. Note that for the `default' | |
629 | face, you must specify an absolute height (since there is nothing | |
95838641 | 630 | for it to be relative to). |
5f5c8ee5 GM |
631 | |
632 | `:weight' | |
633 | ||
634 | VALUE specifies the weight of the font to use. It must be one of the | |
635 | symbols `ultra-bold', `extra-bold', `bold', `semi-bold', `normal', | |
636 | `semi-light', `light', `extra-light', `ultra-light'. | |
637 | ||
638 | `:slant' | |
639 | ||
640 | VALUE specifies the slant of the font to use. It must be one of the | |
641 | symbols `italic', `oblique', `normal', `reverse-italic', or | |
642 | `reverse-oblique'. | |
643 | ||
644 | `:foreground', `:background' | |
645 | ||
646 | VALUE must be a color name, a string. | |
647 | ||
648 | `:underline' | |
649 | ||
9b0e3eba AA |
650 | VALUE specifies whether characters in FACE should be underlined. |
651 | If VALUE is t, underline with foreground color of the face. | |
652 | If VALUE is a string, underline with that color. | |
653 | If VALUE is nil, explicitly don't underline. | |
654 | ||
655 | Otherwise, VALUE must be a property list of the form: | |
656 | ||
657 | `(:color COLOR :style STYLE)'. | |
658 | ||
659 | COLOR can be a either a color name string or `foreground-color'. | |
660 | STYLE can be either `line' or `wave'. | |
661 | If a keyword/value pair is missing from the property list, a | |
662 | default value will be used for the value. | |
663 | The default value of COLOR is the foreground color of the face. | |
664 | The default value of STYLE is `line'. | |
5f5c8ee5 GM |
665 | |
666 | `:overline' | |
667 | ||
668 | VALUE specifies whether characters in FACE should be overlined. If | |
669 | VALUE is t, overline with foreground color of the face. If VALUE is a | |
670 | string, overline with that color. If VALUE is nil, explicitly don't | |
671 | overline. | |
672 | ||
673 | `:strike-through' | |
674 | ||
675 | VALUE specifies whether characters in FACE should be drawn with a line | |
676 | striking through them. If VALUE is t, use the foreground color of the | |
677 | face. If VALUE is a string, strike-through with that color. If VALUE | |
678 | is nil, explicitly don't strike through. | |
679 | ||
680 | `:box' | |
681 | ||
682 | VALUE specifies whether characters in FACE should have a box drawn | |
683 | around them. If VALUE is nil, explicitly don't draw boxes. If | |
684 | VALUE is t, draw a box with lines of width 1 in the foreground color | |
685 | of the face. If VALUE is a string, the string must be a color name, | |
686 | and the box is drawn in that color with a line width of 1. Otherwise, | |
687 | VALUE must be a property list of the form `(:line-width WIDTH | |
688 | :color COLOR :style STYLE)'. If a keyword/value pair is missing from | |
689 | the property list, a default value will be used for the value, as | |
690 | specified below. WIDTH specifies the width of the lines to draw; it | |
0f937ebd KH |
691 | defaults to 1. If WIDTH is negative, the absolute value is the width |
692 | of the lines, and draw top/bottom lines inside the characters area, | |
693 | not around it. COLOR is the name of the color to draw in, default is | |
5f5c8ee5 GM |
694 | the foreground color of the face for simple boxes, and the background |
695 | color of the face for 3D boxes. STYLE specifies whether a 3D box | |
696 | should be draw. If STYLE is `released-button', draw a box looking | |
697 | like a released 3D button. If STYLE is `pressed-button' draw a box | |
698 | that appears like a pressed button. If STYLE is nil, the default if | |
699 | the property list doesn't contain a style specification, draw a 2D | |
700 | box. | |
701 | ||
702 | `:inverse-video' | |
703 | ||
704 | VALUE specifies whether characters in FACE should be displayed in | |
70d0c3b0 | 705 | inverse video. VALUE must be one of t or nil. |
5f5c8ee5 GM |
706 | |
707 | `:stipple' | |
708 | ||
709 | If VALUE is a string, it must be the name of a file of pixmap data. | |
710 | The directories listed in the `x-bitmap-file-path' variable are | |
711 | searched. Alternatively, VALUE may be a list of the form (WIDTH | |
712 | HEIGHT DATA) where WIDTH and HEIGHT are the size in pixels, and DATA | |
713 | is a string containing the raw bits of the bitmap. VALUE nil means | |
714 | explicitly don't use a stipple pattern. | |
715 | ||
fcea6e23 KH |
716 | For convenience, attributes `:family', `:foundry', `:width', |
717 | `:height', `:weight', and `:slant' may also be set in one step | |
718 | from an X font name: | |
5f5c8ee5 GM |
719 | |
720 | `:font' | |
721 | ||
4b56d0fe CY |
722 | Set font-related face attributes from VALUE. VALUE must be a |
723 | valid font name or font object. Setting this attribute will also | |
724 | set the `:family', `:foundry', `:width', `:height', `:weight', | |
725 | and `:slant' attributes. | |
19feb949 MB |
726 | |
727 | `:inherit' | |
728 | ||
4b56d0fe CY |
729 | VALUE is the name of a face from which to inherit attributes, or |
730 | a list of face names. Attributes from inherited faces are merged | |
731 | into the face like an underlying face would be, with higher | |
732 | priority than underlying faces. | |
733 | ||
734 | For backward compatibility, the keywords `:bold' and `:italic' | |
735 | can be used to specify weight and slant respectively. This usage | |
736 | is considered obsolete. For these two keywords, the VALUE must | |
737 | be either t or nil. A value of t for `:bold' is equivalent to | |
738 | setting `:weight' to `bold', and a value of t for `:italic' is | |
739 | equivalent to setting `:slant' to `italic'. But if `:weight' is | |
740 | specified in the face spec, `:bold' is ignored, and if `:slant' | |
741 | is specified, `:italic' is ignored." | |
61ab9392 CY |
742 | (setq args (purecopy args)) |
743 | (let ((where (if (null frame) 0 frame)) | |
744 | (spec args) | |
745 | family foundry) | |
680da3f8 RS |
746 | ;; If we set the new-frame defaults, this face is modified outside Custom. |
747 | (if (memq where '(0 t)) | |
9a558a07 | 748 | (put (or (get face 'face-alias) face) 'face-modified t)) |
61ab9392 CY |
749 | ;; If family and/or foundry are specified, set it first. Certain |
750 | ;; face attributes, e.g. :weight semi-condensed, are not supported | |
751 | ;; in every font. See bug#1127. | |
752 | (while spec | |
753 | (cond ((eq (car spec) :family) | |
754 | (setq family (cadr spec))) | |
755 | ((eq (car spec) :foundry) | |
756 | (setq foundry (cadr spec)))) | |
757 | (setq spec (cddr spec))) | |
758 | (when (or family foundry) | |
759 | (when (and (stringp family) | |
760 | (string-match "\\([^-]*\\)-\\([^-]*\\)" family)) | |
761 | (unless foundry | |
3a92c095 KH |
762 | (setq foundry (match-string 1 family))) |
763 | (setq family (match-string 2 family))) | |
c917476d | 764 | (when (or (stringp family) (eq family 'unspecified)) |
61ab9392 CY |
765 | (internal-set-lisp-face-attribute face :family (purecopy family) |
766 | where)) | |
c917476d | 767 | (when (or (stringp foundry) (eq foundry 'unspecified)) |
61ab9392 CY |
768 | (internal-set-lisp-face-attribute face :foundry (purecopy foundry) |
769 | where))) | |
70a267c9 | 770 | (while args |
61ab9392 | 771 | (unless (memq (car args) '(:family :foundry)) |
96c1a800 CY |
772 | (internal-set-lisp-face-attribute face (car args) |
773 | (purecopy (cadr args)) | |
774 | where)) | |
61ab9392 | 775 | (setq args (cddr args))))) |
5f5c8ee5 | 776 | |
06b60517 | 777 | (defun make-face-bold (face &optional frame _noerror) |
5f5c8ee5 GM |
778 | "Make the font of FACE be bold, if possible. |
779 | FRAME nil or not specified means change face on all frames. | |
39cac3e7 | 780 | Argument NOERROR is ignored and retained for compatibility. |
5f5c8ee5 | 781 | Use `set-face-attribute' for finer control of the font weight." |
011cddd6 RW |
782 | (interactive (list (read-face-name "Make which face bold" |
783 | (face-at-point t)))) | |
5f5c8ee5 GM |
784 | (set-face-attribute face frame :weight 'bold)) |
785 | ||
786 | ||
06b60517 | 787 | (defun make-face-unbold (face &optional frame _noerror) |
5f5c8ee5 | 788 | "Make the font of FACE be non-bold, if possible. |
39cac3e7 GM |
789 | FRAME nil or not specified means change face on all frames. |
790 | Argument NOERROR is ignored and retained for compatibility." | |
011cddd6 RW |
791 | (interactive (list (read-face-name "Make which face non-bold" |
792 | (face-at-point t)))) | |
5f5c8ee5 GM |
793 | (set-face-attribute face frame :weight 'normal)) |
794 | ||
00f51890 | 795 | |
06b60517 | 796 | (defun make-face-italic (face &optional frame _noerror) |
5f5c8ee5 GM |
797 | "Make the font of FACE be italic, if possible. |
798 | FRAME nil or not specified means change face on all frames. | |
39cac3e7 | 799 | Argument NOERROR is ignored and retained for compatibility. |
5f5c8ee5 | 800 | Use `set-face-attribute' for finer control of the font slant." |
011cddd6 RW |
801 | (interactive (list (read-face-name "Make which face italic" |
802 | (face-at-point t)))) | |
5f5c8ee5 GM |
803 | (set-face-attribute face frame :slant 'italic)) |
804 | ||
805 | ||
06b60517 | 806 | (defun make-face-unitalic (face &optional frame _noerror) |
5f5c8ee5 | 807 | "Make the font of FACE be non-italic, if possible. |
70d0c3b0 DL |
808 | FRAME nil or not specified means change face on all frames. |
809 | Argument NOERROR is ignored and retained for compatibility." | |
011cddd6 RW |
810 | (interactive (list (read-face-name "Make which face non-italic" |
811 | (face-at-point t)))) | |
5f5c8ee5 GM |
812 | (set-face-attribute face frame :slant 'normal)) |
813 | ||
00f51890 | 814 | |
06b60517 | 815 | (defun make-face-bold-italic (face &optional frame _noerror) |
5f5c8ee5 GM |
816 | "Make the font of FACE be bold and italic, if possible. |
817 | FRAME nil or not specified means change face on all frames. | |
39cac3e7 | 818 | Argument NOERROR is ignored and retained for compatibility. |
5f5c8ee5 | 819 | Use `set-face-attribute' for finer control of font weight and slant." |
011cddd6 RW |
820 | (interactive (list (read-face-name "Make which face bold-italic" |
821 | (face-at-point t)))) | |
5f5c8ee5 GM |
822 | (set-face-attribute face frame :weight 'bold :slant 'italic)) |
823 | ||
824 | ||
825 | (defun set-face-font (face font &optional frame) | |
826 | "Change font-related attributes of FACE to those of FONT (a string). | |
827 | FRAME nil or not specified means change face on all frames. | |
fcea6e23 KH |
828 | This sets the attributes `:family', `:foundry', `:width', |
829 | `:height', `:weight', and `:slant'. When called interactively, | |
830 | prompt for the face and font." | |
5f5c8ee5 GM |
831 | (interactive (read-face-and-attribute :font)) |
832 | (set-face-attribute face frame :font font)) | |
833 | ||
834 | ||
835 | ;; Implementation note: Emulating gray background colors with a | |
836 | ;; stipple pattern is now part of the face realization process, and is | |
837 | ;; done in C depending on the frame on which the face is realized. | |
838 | ||
839 | (defun set-face-background (face color &optional frame) | |
840 | "Change the background color of face FACE to COLOR (a string). | |
841 | FRAME nil or not specified means change face on all frames. | |
72e6f142 RS |
842 | COLOR can be a system-defined color name (see `list-colors-display') |
843 | or a hex spec of the form #RRGGBB. | |
844 | When called interactively, prompts for the face and color." | |
5f5c8ee5 | 845 | (interactive (read-face-and-attribute :background)) |
78ad1cd5 | 846 | (set-face-attribute face frame :background (or color 'unspecified))) |
5f5c8ee5 GM |
847 | |
848 | ||
849 | (defun set-face-foreground (face color &optional frame) | |
850 | "Change the foreground color of face FACE to COLOR (a string). | |
851 | FRAME nil or not specified means change face on all frames. | |
72e6f142 RS |
852 | COLOR can be a system-defined color name (see `list-colors-display') |
853 | or a hex spec of the form #RRGGBB. | |
854 | When called interactively, prompts for the face and color." | |
5f5c8ee5 | 855 | (interactive (read-face-and-attribute :foreground)) |
78ad1cd5 | 856 | (set-face-attribute face frame :foreground (or color 'unspecified))) |
5f5c8ee5 GM |
857 | |
858 | ||
859 | (defun set-face-stipple (face stipple &optional frame) | |
860 | "Change the stipple pixmap of face FACE to STIPPLE. | |
861 | FRAME nil or not specified means change face on all frames. | |
70d0c3b0 | 862 | STIPPLE should be a string, the name of a file of pixmap data. |
5f5c8ee5 GM |
863 | The directories listed in the `x-bitmap-file-path' variable are searched. |
864 | ||
865 | Alternatively, STIPPLE may be a list of the form (WIDTH HEIGHT DATA) | |
866 | where WIDTH and HEIGHT are the size in pixels, | |
867 | and DATA is a string, containing the raw bits of the bitmap." | |
868 | (interactive (read-face-and-attribute :stipple)) | |
78ad1cd5 | 869 | (set-face-attribute face frame :stipple (or stipple 'unspecified))) |
5f5c8ee5 GM |
870 | |
871 | ||
bde3c6c0 | 872 | (defun set-face-underline (face underline &optional frame) |
5f5c8ee5 GM |
873 | "Specify whether face FACE is underlined. |
874 | UNDERLINE nil means FACE explicitly doesn't underline. | |
bde3c6c0 GM |
875 | UNDERLINE t means FACE underlines with its foreground color. |
876 | If UNDERLINE is a string, underline with that color. | |
877 | ||
878 | UNDERLINE may also be a list of the form (:color COLOR :style STYLE), | |
879 | where COLOR is a string or `foreground-color', and STYLE is either | |
880 | `line' or `wave'. :color may be omitted, which means to use the | |
881 | foreground color. :style may be omitted, which means to use a line. | |
882 | ||
5f5c8ee5 | 883 | FRAME nil or not specified means change face on all frames. |
5f5c8ee5 | 884 | Use `set-face-attribute' to ``unspecify'' underlining." |
bde3c6c0 | 885 | (interactive (read-face-and-attribute :underline)) |
a61afeac | 886 | (set-face-attribute face frame :underline underline)) |
5f5c8ee5 | 887 | |
bde3c6c0 GM |
888 | (define-obsolete-function-alias 'set-face-underline-p |
889 | 'set-face-underline "24.3") | |
9b82fc01 | 890 | |
5f5c8ee5 | 891 | |
3ca2f1bf | 892 | (defun set-face-inverse-video (face inverse-video-p &optional frame) |
5f5c8ee5 GM |
893 | "Specify whether face FACE is in inverse video. |
894 | INVERSE-VIDEO-P non-nil means FACE displays explicitly in inverse video. | |
895 | INVERSE-VIDEO-P nil means FACE explicitly is not in inverse video. | |
896 | FRAME nil or not specified means change face on all frames. | |
897 | Use `set-face-attribute' to ``unspecify'' the inverse video attribute." | |
898 | (interactive | |
899 | (let ((list (read-face-and-attribute :inverse-video))) | |
3ca2f1bf | 900 | (list (car list) (if (cadr list) t)))) |
5f5c8ee5 GM |
901 | (set-face-attribute face frame :inverse-video inverse-video-p)) |
902 | ||
3ca2f1bf GM |
903 | (define-obsolete-function-alias 'set-face-inverse-video-p |
904 | 'set-face-inverse-video "24.4") | |
5f5c8ee5 | 905 | |
3ca2f1bf | 906 | (defun set-face-bold (face bold-p &optional frame) |
5f5c8ee5 GM |
907 | "Specify whether face FACE is bold. |
908 | BOLD-P non-nil means FACE should explicitly display bold. | |
909 | BOLD-P nil means FACE should explicitly display non-bold. | |
910 | FRAME nil or not specified means change face on all frames. | |
911 | Use `set-face-attribute' or `modify-face' for finer control." | |
912 | (if (null bold-p) | |
913 | (make-face-unbold face frame) | |
914 | (make-face-bold face frame))) | |
915 | ||
3ca2f1bf | 916 | (define-obsolete-function-alias 'set-face-bold-p 'set-face-bold "24.4") |
5f5c8ee5 | 917 | |
3ca2f1bf GM |
918 | |
919 | (defun set-face-italic (face italic-p &optional frame) | |
5f5c8ee5 GM |
920 | "Specify whether face FACE is italic. |
921 | ITALIC-P non-nil means FACE should explicitly display italic. | |
922 | ITALIC-P nil means FACE should explicitly display non-italic. | |
923 | FRAME nil or not specified means change face on all frames. | |
924 | Use `set-face-attribute' or `modify-face' for finer control." | |
925 | (if (null italic-p) | |
926 | (make-face-unitalic face frame) | |
927 | (make-face-italic face frame))) | |
928 | ||
3ca2f1bf GM |
929 | (define-obsolete-function-alias 'set-face-italic-p 'set-face-italic "24.4") |
930 | ||
5f5c8ee5 GM |
931 | |
932 | (defalias 'set-face-background-pixmap 'set-face-stipple) | |
933 | ||
934 | ||
935 | (defun invert-face (face &optional frame) | |
936 | "Swap the foreground and background colors of FACE. | |
e458cb49 | 937 | If FRAME is omitted or nil, it means change face on all frames. |
5f5c8ee5 GM |
938 | If FACE specifies neither foreground nor background color, |
939 | set its foreground and background to the background and foreground | |
940 | of the default face. Value is FACE." | |
011cddd6 | 941 | (interactive (list (read-face-name "Invert face" (face-at-point t)))) |
5f5c8ee5 GM |
942 | (let ((fg (face-attribute face :foreground frame)) |
943 | (bg (face-attribute face :background frame))) | |
e458cb49 | 944 | (if (not (and (eq fg 'unspecified) (eq bg 'unspecified))) |
5f5c8ee5 GM |
945 | (set-face-attribute face frame :foreground bg :background fg) |
946 | (set-face-attribute face frame | |
947 | :foreground | |
948 | (face-attribute 'default :background frame) | |
949 | :background | |
950 | (face-attribute 'default :foreground frame)))) | |
951 | face) | |
952 | ||
953 | \f | |
954 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
955 | ;;; Interactively modifying faces. | |
956 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
957 | ||
5cb15713 JB |
958 | (defvar crm-separator) ; from crm.el |
959 | ||
c91e692b | 960 | (defun read-face-name (prompt &optional default multiple) |
011cddd6 RW |
961 | "Read one or more face names, prompting with PROMPT. |
962 | PROMPT should not end in a space or a colon. | |
bccffa83 | 963 | |
011cddd6 | 964 | Return DEFAULT if the user enters the empty string. |
c46da669 RW |
965 | If DEFAULT is non-nil, it should be a single face or a list of face names |
966 | \(symbols or strings). In the latter case, return the `car' of DEFAULT | |
967 | \(if MULTIPLE is nil, see below), or DEFAULT (if MULTIPLE is non-nil). | |
968 | ||
969 | If MULTIPLE is non-nil, this function uses `completing-read-multiple' | |
970 | to read multiple faces with \"[ \\t]*,[ \\t]*\" as the separator regexp | |
971 | and it returns a list of face names. Otherwise, it reads and returns | |
972 | a single face name." | |
011cddd6 RW |
973 | (if (and default (not (stringp default))) |
974 | (setq default | |
975 | (cond ((symbolp default) | |
976 | (symbol-name default)) | |
977 | (multiple | |
978 | (mapconcat (lambda (f) (if (symbolp f) (symbol-name f) f)) | |
979 | default ", ")) | |
980 | ;; If we only want one, and the default is more than one, | |
981 | ;; discard the unwanted ones. | |
982 | (t (symbol-name (car default)))))) | |
e0eb0550 JB |
983 | (when (and default (not multiple)) |
984 | (require 'crm) | |
985 | ;; For compatibility with `completing-read-multiple' use `crm-separator' | |
986 | ;; to define DEFAULT if MULTIPLE is nil. | |
987 | (setq default (car (split-string default crm-separator t)))) | |
c46da669 RW |
988 | |
989 | (let ((prompt (if default | |
990 | (format "%s (default `%s'): " prompt default) | |
991 | (format "%s: " prompt))) | |
992 | aliasfaces nonaliasfaces faces) | |
011cddd6 | 993 | ;; Build up the completion tables. |
e3b5b35b | 994 | (mapatoms (lambda (s) |
011cddd6 | 995 | (if (facep s) |
e3b5b35b SM |
996 | (if (get s 'face-alias) |
997 | (push (symbol-name s) aliasfaces) | |
998 | (push (symbol-name s) nonaliasfaces))))) | |
c46da669 RW |
999 | (if multiple |
1000 | (progn | |
1001 | (dolist (face (completing-read-multiple | |
1002 | prompt | |
1003 | (completion-table-in-turn nonaliasfaces aliasfaces) | |
1004 | nil t nil 'face-name-history default)) | |
1005 | ;; Ignore elements that are not faces | |
1006 | ;; (for example, because DEFAULT was "all faces") | |
1007 | (if (facep face) (push (intern face) faces))) | |
1008 | (nreverse faces)) | |
1009 | (let ((face (completing-read | |
1010 | prompt | |
011cddd6 | 1011 | (completion-table-in-turn nonaliasfaces aliasfaces) |
c46da669 RW |
1012 | nil t nil 'face-name-history default))) |
1013 | (if (facep face) (intern face)))))) | |
a482f364 | 1014 | |
aa360da1 GM |
1015 | ;; Not defined without X, but behind window-system test. |
1016 | (defvar x-bitmap-file-path) | |
a482f364 | 1017 | |
5f5c8ee5 GM |
1018 | (defun face-valid-attribute-values (attribute &optional frame) |
1019 | "Return valid values for face attribute ATTRIBUTE. | |
1020 | The optional argument FRAME is used to determine available fonts | |
c6f3804c JB |
1021 | and colors. If it is nil or not specified, the selected frame is used. |
1022 | Value is an alist of (NAME . VALUE) if ATTRIBUTE expects a value out | |
1023 | of a set of discrete values. Value is `integerp' if ATTRIBUTE expects | |
5f5c8ee5 | 1024 | an integer value." |
00f51890 | 1025 | (let ((valid |
36cec983 SM |
1026 | (pcase attribute |
1027 | (`:family | |
428a555e | 1028 | (if (window-system frame) |
95ac8fbd | 1029 | (mapcar (lambda (x) (cons x x)) |
6e783e91 | 1030 | (font-family-list)) |
00f51890 SS |
1031 | ;; Only one font on TTYs. |
1032 | (list (cons "default" "default")))) | |
36cec983 | 1033 | (`:foundry |
fcea6e23 | 1034 | (list nil)) |
36cec983 | 1035 | (`:width |
e83eedbf | 1036 | (mapcar #'(lambda (x) (cons (symbol-name (aref x 1)) (aref x 1))) |
6e783e91 | 1037 | font-width-table)) |
36cec983 | 1038 | (`:weight |
e83eedbf | 1039 | (mapcar #'(lambda (x) (cons (symbol-name (aref x 1)) (aref x 1))) |
6e783e91 | 1040 | font-weight-table)) |
36cec983 | 1041 | (`:slant |
e83eedbf | 1042 | (mapcar #'(lambda (x) (cons (symbol-name (aref x 1)) (aref x 1))) |
6e783e91 | 1043 | font-slant-table)) |
36cec983 | 1044 | (`:inverse-video |
6e783e91 KH |
1045 | (mapcar #'(lambda (x) (cons (symbol-name x) x)) |
1046 | (internal-lisp-face-attribute-values attribute))) | |
36cec983 | 1047 | ((or `:underline `:overline `:strike-through `:box) |
428a555e | 1048 | (if (window-system frame) |
00f51890 SS |
1049 | (nconc (mapcar #'(lambda (x) (cons (symbol-name x) x)) |
1050 | (internal-lisp-face-attribute-values attribute)) | |
1051 | (mapcar #'(lambda (c) (cons c c)) | |
b533d0ae | 1052 | (defined-colors frame))) |
00f51890 SS |
1053 | (mapcar #'(lambda (x) (cons (symbol-name x) x)) |
1054 | (internal-lisp-face-attribute-values attribute)))) | |
36cec983 | 1055 | ((or `:foreground `:background) |
00f51890 SS |
1056 | (mapcar #'(lambda (c) (cons c c)) |
1057 | (defined-colors frame))) | |
36cec983 | 1058 | (`:height |
00f51890 | 1059 | 'integerp) |
36cec983 | 1060 | (`:stipple |
0db2e6af | 1061 | (and (memq (window-system frame) '(x ns)) ; No stipple on w32 |
00f51890 SS |
1062 | (mapcar #'list |
1063 | (apply #'nconc | |
1064 | (mapcar (lambda (dir) | |
1065 | (and (file-readable-p dir) | |
1066 | (file-directory-p dir) | |
1067 | (directory-files dir))) | |
1068 | x-bitmap-file-path))))) | |
36cec983 | 1069 | (`:inherit |
00f51890 SS |
1070 | (cons '("none" . nil) |
1071 | (mapcar #'(lambda (c) (cons (symbol-name c) c)) | |
1072 | (face-list)))) | |
36cec983 | 1073 | (_ |
00f51890 | 1074 | (error "Internal error"))))) |
19feb949 | 1075 | (if (and (listp valid) (not (memq attribute '(:inherit)))) |
fbd5f1cc GM |
1076 | (nconc (list (cons "unspecified" 'unspecified)) valid) |
1077 | valid))) | |
5f5c8ee5 GM |
1078 | |
1079 | ||
2f7f4bee | 1080 | (defconst face-attribute-name-alist |
5f5c8ee5 | 1081 | '((:family . "font family") |
fcea6e23 | 1082 | (:foundry . "font foundry") |
5f5c8ee5 GM |
1083 | (:width . "character set width") |
1084 | (:height . "height in 1/10 pt") | |
1085 | (:weight . "weight") | |
1086 | (:slant . "slant") | |
1087 | (:underline . "underline") | |
1088 | (:overline . "overline") | |
1089 | (:strike-through . "strike-through") | |
1090 | (:box . "box") | |
1091 | (:inverse-video . "inverse-video display") | |
1092 | (:foreground . "foreground color") | |
1093 | (:background . "background color") | |
19feb949 MB |
1094 | (:stipple . "background stipple") |
1095 | (:inherit . "inheritance")) | |
5f5c8ee5 GM |
1096 | "An alist of descriptive names for face attributes. |
1097 | Each element has the form (ATTRIBUTE-NAME . DESCRIPTION) where | |
1098 | ATTRIBUTE-NAME is a face attribute name (a keyword symbol), and | |
1099 | DESCRIPTION is a descriptive name for ATTRIBUTE-NAME.") | |
1100 | ||
1101 | ||
1102 | (defun face-descriptive-attribute-name (attribute) | |
1103 | "Return a descriptive name for ATTRIBUTE." | |
1104 | (cdr (assq attribute face-attribute-name-alist))) | |
1105 | ||
1106 | ||
1107 | (defun face-read-string (face default name &optional completion-alist) | |
1108 | "Interactively read a face attribute string value. | |
19feb949 MB |
1109 | FACE is the face whose attribute is read. If non-nil, DEFAULT is the |
1110 | default string to return if no new value is entered. NAME is a | |
1111 | descriptive name of the attribute for prompting. COMPLETION-ALIST is an | |
1112 | alist of valid values, if non-nil. | |
5f5c8ee5 | 1113 | |
19feb949 | 1114 | Entering nothing accepts the default string DEFAULT. |
5f5c8ee5 | 1115 | Value is the new attribute value." |
19feb949 MB |
1116 | ;; Capitalize NAME (we don't use `capitalize' because that capitalizes |
1117 | ;; each word in a string separately). | |
1118 | (setq name (concat (upcase (substring name 0 1)) (substring name 1))) | |
5f5c8ee5 GM |
1119 | (let* ((completion-ignore-case t) |
1120 | (value (completing-read | |
1121 | (if default | |
19feb949 MB |
1122 | (format "%s for face `%s' (default %s): " |
1123 | name face default) | |
1124 | (format "%s for face `%s': " name face)) | |
d69ab4ba | 1125 | completion-alist nil nil nil nil default))) |
fbd5f1cc | 1126 | (if (equal value "") default value))) |
5f5c8ee5 GM |
1127 | |
1128 | ||
1129 | (defun face-read-integer (face default name) | |
1130 | "Interactively read an integer face attribute value. | |
1131 | FACE is the face whose attribute is read. DEFAULT is the default | |
1132 | value to return if no new value is entered. NAME is a descriptive | |
1133 | name of the attribute for prompting. Value is the new attribute value." | |
fbd5f1cc GM |
1134 | (let ((new-value |
1135 | (face-read-string face | |
19feb949 | 1136 | (format "%s" default) |
fbd5f1cc GM |
1137 | name |
1138 | (list (cons "unspecified" 'unspecified))))) | |
19feb949 MB |
1139 | (cond ((equal new-value "unspecified") |
1140 | 'unspecified) | |
1141 | ((member new-value '("unspecified-fg" "unspecified-bg")) | |
1142 | new-value) | |
1143 | (t | |
027a4b6b | 1144 | (string-to-number new-value))))) |
5f5c8ee5 GM |
1145 | |
1146 | ||
bde3c6c0 GM |
1147 | ;; FIXME this does allow you to enter the list forms of :box, |
1148 | ;; :stipple, or :underline, because face-valid-attribute-values does | |
1149 | ;; not return those forms. | |
5f5c8ee5 GM |
1150 | (defun read-face-attribute (face attribute &optional frame) |
1151 | "Interactively read a new value for FACE's ATTRIBUTE. | |
1152 | Optional argument FRAME nil or unspecified means read an attribute value | |
1153 | of a global face. Value is the new attribute value." | |
1154 | (let* ((old-value (face-attribute face attribute frame)) | |
1155 | (attribute-name (face-descriptive-attribute-name attribute)) | |
1156 | (valid (face-valid-attribute-values attribute frame)) | |
1157 | new-value) | |
1158 | ;; Represent complex attribute values as strings by printing them | |
1159 | ;; out. Stipple can be a vector; (WIDTH HEIGHT DATA). Box can be | |
1160 | ;; a list `(:width WIDTH :color COLOR)' or `(:width WIDTH :shadow | |
bde3c6c0 GM |
1161 | ;; SHADOW)'. Underline can be `(:color COLOR :style STYLE)'. |
1162 | (and (memq attribute '(:box :stipple :underline)) | |
1163 | (or (consp old-value) | |
1164 | (vectorp old-value)) | |
1165 | (setq old-value (prin1-to-string old-value))) | |
5f5c8ee5 | 1166 | (cond ((listp valid) |
19feb949 MB |
1167 | (let ((default |
1168 | (or (car (rassoc old-value valid)) | |
1169 | (format "%s" old-value)))) | |
1170 | (setq new-value | |
1171 | (face-read-string face default attribute-name valid)) | |
1172 | (if (equal new-value default) | |
1173 | ;; Nothing changed, so don't bother with all the stuff | |
1174 | ;; below. In particular, this avoids a non-tty color | |
1175 | ;; from being canonicalized for a tty when the user | |
1176 | ;; just uses the default. | |
1177 | (setq new-value old-value) | |
1178 | ;; Terminal frames can support colors that don't appear | |
1179 | ;; explicitly in VALID, using color approximation code | |
1180 | ;; in tty-colors.el. | |
f9056dd9 | 1181 | (when (and (memq attribute '(:foreground :background)) |
9e2a2647 | 1182 | (not (memq (window-system frame) '(x w32 ns))) |
f9056dd9 MB |
1183 | (not (member new-value |
1184 | '("unspecified" | |
1185 | "unspecified-fg" "unspecified-bg")))) | |
4385f1b0 | 1186 | (setq new-value (car (tty-color-desc new-value frame)))) |
f9056dd9 MB |
1187 | (when (assoc new-value valid) |
1188 | (setq new-value (cdr (assoc new-value valid))))))) | |
5f5c8ee5 GM |
1189 | ((eq valid 'integerp) |
1190 | (setq new-value (face-read-integer face old-value attribute-name))) | |
1191 | (t (error "Internal error"))) | |
1192 | ;; Convert stipple and box value text we read back to a list or | |
1193 | ;; vector if it looks like one. This makes the assumption that a | |
1194 | ;; pixmap file name won't start with an open-paren. | |
bde3c6c0 GM |
1195 | (and (memq attribute '(:stipple :box :underline)) |
1196 | (stringp new-value) | |
5e400cb3 | 1197 | (string-match-p "^[[(]" new-value) |
bde3c6c0 | 1198 | (setq new-value (read new-value))) |
5f5c8ee5 GM |
1199 | new-value)) |
1200 | ||
aa360da1 GM |
1201 | (declare-function fontset-list "fontset.c" ()) |
1202 | (declare-function x-list-fonts "xfaces.c" | |
1203 | (pattern &optional face frame maximum width)) | |
5f5c8ee5 GM |
1204 | |
1205 | (defun read-face-font (face &optional frame) | |
1206 | "Read the name of a font for FACE on FRAME. | |
522fb950 | 1207 | If optional argument FRAME is nil or omitted, use the selected frame." |
5f5c8ee5 | 1208 | (let ((completion-ignore-case t)) |
48ec9939 | 1209 | (completing-read (format "Set font attributes of face `%s' from font: " face) |
6b61353c | 1210 | (append (fontset-list) (x-list-fonts "*" nil frame))))) |
5f5c8ee5 GM |
1211 | |
1212 | ||
1213 | (defun read-all-face-attributes (face &optional frame) | |
1214 | "Interactively read all attributes for FACE. | |
522fb950 | 1215 | If optional argument FRAME is nil or omitted, use the selected frame. |
5f5c8ee5 GM |
1216 | Value is a property list of attribute names and new values." |
1217 | (let (result) | |
1218 | (dolist (attribute face-attribute-name-alist result) | |
1219 | (setq result (cons (car attribute) | |
1220 | (cons (read-face-attribute face (car attribute) frame) | |
1221 | result)))))) | |
1222 | ||
7cd512f2 | 1223 | (defun modify-face (&optional face foreground background stipple |
a61afeac | 1224 | bold-p italic-p underline inverse-p frame) |
5f5c8ee5 GM |
1225 | "Modify attributes of faces interactively. |
1226 | If optional argument FRAME is nil or omitted, modify the face used | |
7cd512f2 SM |
1227 | for newly created frame, i.e. the global face. |
1228 | For non-interactive use, `set-face-attribute' is preferred. | |
522fb950 | 1229 | When called from Lisp, if FACE is nil, all arguments but FRAME are ignored |
7cd512f2 | 1230 | and the face and its settings are obtained by querying the user." |
5f5c8ee5 | 1231 | (interactive) |
7cd512f2 SM |
1232 | (if face |
1233 | (set-face-attribute face frame | |
1234 | :foreground (or foreground 'unspecified) | |
1235 | :background (or background 'unspecified) | |
1236 | :stipple stipple | |
4b56d0fe CY |
1237 | :weight (if bold-p 'bold 'normal) |
1238 | :slant (if italic-p 'italic 'normal) | |
a61afeac | 1239 | :underline underline |
7cd512f2 | 1240 | :inverse-video inverse-p) |
011cddd6 | 1241 | (setq face (read-face-name "Modify face" (face-at-point t))) |
5f5c8ee5 GM |
1242 | (apply #'set-face-attribute face frame |
1243 | (read-all-face-attributes face frame)))) | |
1244 | ||
5f5c8ee5 GM |
1245 | (defun read-face-and-attribute (attribute &optional frame) |
1246 | "Read face name and face attribute value. | |
1247 | ATTRIBUTE is the attribute whose new value is read. | |
1248 | FRAME nil or unspecified means read attribute value of global face. | |
1249 | Value is a list (FACE NEW-VALUE) where FACE is the face read | |
7cd512f2 | 1250 | \(a symbol), and NEW-VALUE is value read." |
5f5c8ee5 | 1251 | (cond ((eq attribute :font) |
48ec9939 | 1252 | (let* ((prompt "Set font-related attributes of face") |
011cddd6 | 1253 | (face (read-face-name prompt (face-at-point t))) |
5f5c8ee5 GM |
1254 | (font (read-face-font face frame))) |
1255 | (list face font))) | |
1256 | (t | |
1257 | (let* ((attribute-name (face-descriptive-attribute-name attribute)) | |
19feb949 | 1258 | (prompt (format "Set %s of face" attribute-name)) |
011cddd6 | 1259 | (face (read-face-name prompt (face-at-point t))) |
5f5c8ee5 GM |
1260 | (new-value (read-face-attribute face attribute frame))) |
1261 | (list face new-value))))) | |
1262 | ||
1263 | ||
1264 | \f | |
5f5c8ee5 GM |
1265 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1266 | ;;; Face specifications (defface). | |
1267 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
1268 | ||
1269 | ;; Parameter FRAME Is kept for call compatibility to with previous | |
1270 | ;; face implementation. | |
1271 | ||
06b60517 JB |
1272 | (defun face-attr-construct (face &optional _frame) |
1273 | "Return a `defface'-style attribute list for FACE. | |
5f5c8ee5 GM |
1274 | Value is a property list of pairs ATTRIBUTE VALUE for all specified |
1275 | face attributes of FACE where ATTRIBUTE is the attribute name and | |
06b60517 JB |
1276 | VALUE is the specified value of that attribute. |
1277 | Argument FRAME is ignored and retained for compatibility." | |
5f5c8ee5 GM |
1278 | (let (result) |
1279 | (dolist (entry face-attribute-name-alist result) | |
1280 | (let* ((attribute (car entry)) | |
1281 | (value (face-attribute face attribute))) | |
1282 | (unless (eq value 'unspecified) | |
1283 | (setq result (nconc (list attribute value) result))))))) | |
00f51890 | 1284 | |
5f5c8ee5 GM |
1285 | |
1286 | (defun face-spec-set-match-display (display frame) | |
1287 | "Non-nil if DISPLAY matches FRAME. | |
1288 | DISPLAY is part of a spec such as can be used in `defface'. | |
1289 | If FRAME is nil, the current FRAME is used." | |
1290 | (let* ((conjuncts display) | |
1291 | conjunct req options | |
1292 | ;; t means we have succeeded against all the conjuncts in | |
1293 | ;; DISPLAY that have been tested so far. | |
1294 | (match t)) | |
1295 | (if (eq conjuncts t) | |
1296 | (setq conjuncts nil)) | |
1297 | (while (and conjuncts match) | |
1298 | (setq conjunct (car conjuncts) | |
1299 | conjuncts (cdr conjuncts) | |
1300 | req (car conjunct) | |
1301 | options (cdr conjunct) | |
1302 | match (cond ((eq req 'type) | |
428a555e | 1303 | (or (memq (window-system frame) options) |
ee0e9f11 LMI |
1304 | (and (memq 'graphic options) |
1305 | (memq (window-system frame) '(x w32 ns))) | |
1695ca2b EZ |
1306 | ;; FIXME: This should be revisited to use |
1307 | ;; display-graphic-p, provided that the | |
1308 | ;; color selection depends on the number | |
1309 | ;; of supported colors, and all defface's | |
1310 | ;; are changed to look at number of colors | |
1311 | ;; instead of (type graphic) etc. | |
dcb79f20 AS |
1312 | (if (null (window-system frame)) |
1313 | (memq 'tty options) | |
1314 | (or (and (memq 'motif options) | |
1315 | (featurep 'motif)) | |
1316 | (and (memq 'gtk options) | |
1317 | (featurep 'gtk)) | |
1318 | (and (memq 'lucid options) | |
1319 | (featurep 'x-toolkit) | |
1320 | (not (featurep 'motif)) | |
1321 | (not (featurep 'gtk))) | |
1322 | (and (memq 'x-toolkit options) | |
1323 | (featurep 'x-toolkit)))))) | |
6b61353c KH |
1324 | ((eq req 'min-colors) |
1325 | (>= (display-color-cells frame) (car options))) | |
5f5c8ee5 GM |
1326 | ((eq req 'class) |
1327 | (memq (frame-parameter frame 'display-type) options)) | |
1328 | ((eq req 'background) | |
1329 | (memq (frame-parameter frame 'background-mode) | |
1330 | options)) | |
16320ac7 MB |
1331 | ((eq req 'supports) |
1332 | (display-supports-face-attributes-p options frame)) | |
70d0c3b0 | 1333 | (t (error "Unknown req `%S' with options `%S'" |
5f5c8ee5 GM |
1334 | req options))))) |
1335 | match)) | |
1336 | ||
1337 | ||
fdafd487 MD |
1338 | (defun face-spec-choose (spec &optional frame no-match-retval) |
1339 | "Return the proper attributes for FRAME, out of SPEC. | |
1340 | ||
1341 | If no match is found or SPEC is nil, return nil, unless NO-MATCH-RETVAL | |
1342 | is given, in which case return its value instead." | |
5f5c8ee5 GM |
1343 | (unless frame |
1344 | (setq frame (selected-frame))) | |
1345 | (let ((tail spec) | |
fdafd487 | 1346 | result defaults match-found) |
5f5c8ee5 | 1347 | (while tail |
073f69e6 MB |
1348 | (let* ((entry (pop tail)) |
1349 | (display (car entry)) | |
cf459bb7 RS |
1350 | (attrs (cdr entry)) |
1351 | thisval) | |
1352 | ;; Get the attributes as actually specified by this alternative. | |
1353 | (setq thisval | |
1354 | (if (null (cdr attrs)) ;; was (listp (car attrs)) | |
1355 | ;; Old-style entry, the attribute list is the | |
1356 | ;; first element. | |
1357 | (car attrs) | |
1358 | attrs)) | |
1359 | ||
1360 | ;; If the condition is `default', that sets the default | |
1361 | ;; for following conditions. | |
1362 | (if (eq display 'default) | |
1363 | (setq defaults thisval) | |
1364 | ;; Otherwise, if it matches, use it. | |
1365 | (when (face-spec-set-match-display display frame) | |
fdafd487 MD |
1366 | (setq result thisval |
1367 | tail nil | |
1368 | match-found t))))) | |
1369 | ;; If defaults have been found, it's safe to just append those to the result | |
1370 | ;; list (which at this point will be either nil or contain actual specs) and | |
1371 | ;; return it to the caller. Since there will most definitely be something to | |
1372 | ;; return in this case, there's no need to know/check if a match was found. | |
1373 | (if defaults | |
1374 | (append result defaults) | |
1375 | (if match-found | |
1376 | result | |
1377 | no-match-retval)))) | |
5f5c8ee5 GM |
1378 | |
1379 | ||
1380 | (defun face-spec-reset-face (face &optional frame) | |
1381 | "Reset all attributes of FACE on FRAME to unspecified." | |
c349f4e6 CY |
1382 | (apply 'set-face-attribute face frame |
1383 | (if (eq face 'default) | |
1384 | ;; For the default face, avoid making any attribute | |
f003f294 | 1385 | ;; unspecified. Instead, set attributes to default values |
c349f4e6 CY |
1386 | ;; (see also realize_default_face in xfaces.c). |
1387 | (append | |
1388 | '(:underline nil :overline nil :strike-through nil | |
1389 | :box nil :inverse-video nil :stipple nil :inherit nil) | |
4c5779ab CY |
1390 | ;; `display-graphic-p' is unavailable when running |
1391 | ;; temacs, prior to loading frame.el. | |
aac2b673 CY |
1392 | (when (fboundp 'display-graphic-p) |
1393 | (unless (display-graphic-p frame) | |
1394 | `(:family "default" :foundry "default" :width normal | |
1395 | :height 1 :weight normal :slant normal | |
1396 | :foreground ,(if (frame-parameter nil 'reverse) | |
1397 | "unspecified-bg" | |
1398 | "unspecified-fg") | |
1399 | :background ,(if (frame-parameter nil 'reverse) | |
1400 | "unspecified-fg" | |
1401 | "unspecified-bg"))))) | |
c349f4e6 CY |
1402 | ;; For all other faces, unspecify all attributes. |
1403 | (apply 'append | |
1404 | (mapcar (lambda (x) (list (car x) 'unspecified)) | |
1405 | face-attribute-name-alist))))) | |
5f5c8ee5 | 1406 | |
1c4f115d CY |
1407 | (defun face-spec-set (face spec &optional spec-type) |
1408 | "Set the face spec SPEC for FACE. | |
1409 | See `defface' for the format of SPEC. | |
1410 | ||
aac2b673 CY |
1411 | The appearance of each face is controlled by its specs (set via |
1412 | this function), and by the internal frame-specific face | |
1413 | attributes (set via `set-face-attribute'). | |
bacb0e77 | 1414 | |
aac2b673 CY |
1415 | This function also defines FACE as a valid face name if it is not |
1416 | already one, and (re)calculates its attributes on existing | |
1417 | frames. | |
1c4f115d CY |
1418 | |
1419 | The argument SPEC-TYPE determines which spec to set: | |
1420 | nil or `face-override-spec' means the override spec (which is | |
1421 | usually what you want if calling this function outside of | |
1422 | Custom code); | |
1423 | `customized-face' or `saved-face' means the customized spec or | |
1424 | the saved custom spec; | |
1425 | `face-defface-spec' means the default spec | |
1426 | (usually set only via `defface'); | |
1427 | `reset' means to ignore SPEC, but clear the `customized-face' | |
1428 | and `face-override-spec' specs; | |
1429 | Any other value means not to set any spec, but to run the | |
bacb0e77 | 1430 | function for its other effects." |
1c4f115d CY |
1431 | (if (get face 'face-alias) |
1432 | (setq face (get face 'face-alias))) | |
1433 | ;; Save SPEC to the relevant symbol property. | |
1434 | (unless spec-type | |
1435 | (setq spec-type 'face-override-spec)) | |
1436 | (if (memq spec-type '(face-defface-spec face-override-spec | |
1437 | customized-face saved-face)) | |
1438 | (put face spec-type spec)) | |
1439 | (if (memq spec-type '(reset saved-face)) | |
1440 | (put face 'customized-face nil)) | |
1441 | ;; Setting the face spec via Custom empties out any override spec, | |
f24f2e22 | 1442 | ;; similar to how setting a variable via Custom changes its values. |
1c4f115d CY |
1443 | (if (memq spec-type '(customized-face saved-face reset)) |
1444 | (put face 'face-override-spec nil)) | |
1445 | ;; If we reset the face based on its custom spec, it is unmodified | |
1446 | ;; as far as Custom is concerned. | |
1447 | (unless (eq face 'face-override-spec) | |
1448 | (put face 'face-modified nil)) | |
aac2b673 CY |
1449 | ;; Initialize the face if it does not exist, then recalculate. |
1450 | (make-empty-face face) | |
1451 | (dolist (frame (frame-list)) | |
1452 | (face-spec-recalc face frame))) | |
24837f13 RS |
1453 | |
1454 | (defun face-spec-recalc (face frame) | |
1455 | "Reset the face attributes of FACE on FRAME according to its specs. | |
bc6953b3 MD |
1456 | The following sources are applied in this order: |
1457 | ||
1458 | face reset to default values if it's the default face, otherwise set | |
426b5daf | 1459 | to unspecified (through `face-spec-reset-face') |
eb7a03cc MD |
1460 | | |
1461 | (theme and user customization) | |
426b5daf PE |
1462 | or: if none of the above exist, and none match the current frame or |
1463 | inherited from the defface spec instead of overwriting it | |
bc6953b3 | 1464 | entirely, the following is applied instead: |
eb7a03cc | 1465 | (defface default spec) |
bc6953b3 | 1466 | (X resources (if applicable)) |
eb7a03cc MD |
1467 | | |
1468 | defface override spec" | |
1c4f115d CY |
1469 | (while (get face 'face-alias) |
1470 | (setq face (get face 'face-alias))) | |
24837f13 | 1471 | (face-spec-reset-face face frame) |
1c4f115d | 1472 | ;; If FACE is customized or themed, set the custom spec from |
dca38cf9 CY |
1473 | ;; `theme-face' records. |
1474 | (let ((theme-faces (get face 'theme-face)) | |
fdafd487 | 1475 | (no-match-found 0) |
dca38cf9 | 1476 | spec theme-face-applied) |
1c4f115d | 1477 | (if theme-faces |
dca38cf9 | 1478 | (dolist (elt (reverse theme-faces)) |
fdafd487 MD |
1479 | (setq spec (face-spec-choose (cadr elt) frame no-match-found)) |
1480 | (unless (eq spec no-match-found) | |
dca38cf9 CY |
1481 | (face-spec-set-2 face frame spec) |
1482 | (setq theme-face-applied t)))) | |
1483 | ;; If there was a spec applicable to FRAME, that overrides the | |
1484 | ;; defface spec entirely (rather than inheriting from it). If | |
bc6953b3 MD |
1485 | ;; there was no spec applicable to FRAME, apply the defface spec |
1486 | ;; as well as any applicable X resources. | |
dca38cf9 CY |
1487 | (unless theme-face-applied |
1488 | (setq spec (face-spec-choose (face-default-spec face) frame)) | |
bc6953b3 MD |
1489 | (face-spec-set-2 face frame spec) |
1490 | (make-face-x-resource-internal face frame)) | |
dca38cf9 | 1491 | (setq spec (face-spec-choose (get face 'face-override-spec) frame)) |
eb7a03cc | 1492 | (face-spec-set-2 face frame spec))) |
24837f13 RS |
1493 | |
1494 | (defun face-spec-set-2 (face frame spec) | |
1495 | "Set the face attributes of FACE on FRAME according to SPEC." | |
dca38cf9 | 1496 | (let (attrs) |
4f77c25d CY |
1497 | (while spec |
1498 | (when (assq (car spec) face-x-resources) | |
1499 | (push (car spec) attrs) | |
1500 | (push (cadr spec) attrs)) | |
1501 | (setq spec (cddr spec))) | |
1502 | (apply 'set-face-attribute face frame (nreverse attrs)))) | |
5f5c8ee5 GM |
1503 | |
1504 | (defun face-attr-match-p (face attrs &optional frame) | |
a9de7d29 | 1505 | "Return t if attributes of FACE match values in plist ATTRS. |
5f5c8ee5 GM |
1506 | Optional parameter FRAME is the frame whose definition of FACE |
1507 | is used. If nil or omitted, use the selected frame." | |
1508 | (unless frame | |
1509 | (setq frame (selected-frame))) | |
8a6f24e5 GM |
1510 | (let* ((list face-attribute-name-alist) |
1511 | (match t) | |
1512 | (bold (and (plist-member attrs :bold) | |
1513 | (not (plist-member attrs :weight)))) | |
1514 | (italic (and (plist-member attrs :italic) | |
1515 | (not (plist-member attrs :slant)))) | |
1516 | (plist (if (or bold italic) | |
1517 | (copy-sequence attrs) | |
1518 | attrs))) | |
1519 | ;; Handle the Emacs 20 :bold and :italic properties. | |
1520 | (if bold | |
1521 | (plist-put plist :weight (if bold 'bold 'normal))) | |
1522 | (if italic | |
1523 | (plist-put plist :slant (if italic 'italic 'normal))) | |
4983ddea CY |
1524 | (while (and match list) |
1525 | (let* ((attr (caar list)) | |
a9de7d29 | 1526 | (specified-value |
8a6f24e5 GM |
1527 | (if (plist-member plist attr) |
1528 | (plist-get plist attr) | |
a9de7d29 | 1529 | 'unspecified)) |
5f5c8ee5 | 1530 | (value-now (face-attribute face attr frame))) |
a9de7d29 | 1531 | (setq match (equal specified-value value-now)) |
5f5c8ee5 GM |
1532 | (setq list (cdr list)))) |
1533 | match)) | |
1534 | ||
4983ddea | 1535 | (defsubst face-spec-match-p (face spec &optional frame) |
5f5c8ee5 GM |
1536 | "Return t if FACE, on FRAME, matches what SPEC says it should look like." |
1537 | (face-attr-match-p face (face-spec-choose spec frame) frame)) | |
1538 | ||
94fe8a31 | 1539 | (defsubst face-default-spec (face) |
96c2938f MB |
1540 | "Return the default face-spec for FACE, ignoring any user customization. |
1541 | If there is no default for FACE, return nil." | |
1542 | (get face 'face-defface-spec)) | |
5f5c8ee5 | 1543 | |
94fe8a31 MB |
1544 | (defsubst face-user-default-spec (face) |
1545 | "Return the user's customized face-spec for FACE, or the default if none. | |
7cd512f2 | 1546 | If there is neither a user setting nor a default for FACE, return nil." |
e44d251c JL |
1547 | (or (get face 'customized-face) |
1548 | (get face 'saved-face) | |
94fe8a31 MB |
1549 | (face-default-spec face))) |
1550 | ||
5f5c8ee5 | 1551 | \f |
f795f633 EZ |
1552 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1553 | ;;; Frame-type independent color support. | |
1554 | ;;; We keep the old x-* names as aliases for back-compatibility. | |
1555 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
1556 | ||
1557 | (defun defined-colors (&optional frame) | |
1558 | "Return a list of colors supported for a particular frame. | |
1559 | The argument FRAME specifies which frame to try. | |
1560 | The value may be different for frames on different display types. | |
43c58260 RS |
1561 | If FRAME doesn't support colors, the value is nil. |
1562 | If FRAME is nil, that stands for the selected frame." | |
9e2a2647 | 1563 | (if (memq (framep (or frame (selected-frame))) '(x w32 ns)) |
f795f633 | 1564 | (xw-defined-colors frame) |
37462f4c | 1565 | (mapcar 'car (tty-color-alist frame)))) |
f795f633 EZ |
1566 | (defalias 'x-defined-colors 'defined-colors) |
1567 | ||
aa360da1 GM |
1568 | (declare-function xw-color-defined-p "xfns.c" (color &optional frame)) |
1569 | ||
f795f633 | 1570 | (defun color-defined-p (color &optional frame) |
bccffa83 CY |
1571 | "Return non-nil if COLOR is supported on frame FRAME. |
1572 | COLOR should be a string naming a color (e.g. \"white\"), or a | |
1573 | string specifying a color's RGB components (e.g. \"#ff12ec\"), or | |
1574 | the symbol `unspecified'. | |
1575 | ||
1576 | This function returns nil if COLOR is the symbol `unspecified', | |
1577 | or one of the strings \"unspecified-fg\" or \"unspecified-bg\". | |
1578 | ||
1579 | If FRAME is omitted or nil, use the selected frame." | |
1580 | (unless (member color '(unspecified "unspecified-bg" "unspecified-fg")) | |
9e2a2647 | 1581 | (if (member (framep (or frame (selected-frame))) '(x w32 ns)) |
f795f633 | 1582 | (xw-color-defined-p color frame) |
37462f4c | 1583 | (numberp (tty-color-translate color frame))))) |
f795f633 EZ |
1584 | (defalias 'x-color-defined-p 'color-defined-p) |
1585 | ||
aa360da1 GM |
1586 | (declare-function xw-color-values "xfns.c" (color &optional frame)) |
1587 | ||
f795f633 EZ |
1588 | (defun color-values (color &optional frame) |
1589 | "Return a description of the color named COLOR on frame FRAME. | |
6d713256 CY |
1590 | COLOR should be a string naming a color (e.g. \"white\"), or a |
1591 | string specifying a color's RGB components (e.g. \"#ff12ec\"). | |
1592 | ||
1593 | Return a list of three integers, (RED GREEN BLUE), each between 0 | |
1594 | and either 65280 or 65535 (the maximum depends on the system). | |
1595 | Use `color-name-to-rgb' if you want RGB floating-point values | |
1596 | normalized to 1.0. | |
1597 | ||
f795f633 EZ |
1598 | If FRAME is omitted or nil, use the selected frame. |
1599 | If FRAME cannot display COLOR, the value is nil. | |
6d713256 CY |
1600 | |
1601 | COLOR can also be the symbol `unspecified' or one of the strings | |
1602 | \"unspecified-fg\" or \"unspecified-bg\", in which case the | |
1603 | return value is nil." | |
1604 | (cond | |
1605 | ((member color '(unspecified "unspecified-fg" "unspecified-bg")) | |
1606 | nil) | |
1607 | ((memq (framep (or frame (selected-frame))) '(x w32 ns)) | |
1608 | (xw-color-values color frame)) | |
1609 | (t | |
1610 | (tty-color-values color frame)))) | |
1611 | ||
f795f633 EZ |
1612 | (defalias 'x-color-values 'color-values) |
1613 | ||
aa360da1 GM |
1614 | (declare-function xw-display-color-p "xfns.c" (&optional terminal)) |
1615 | ||
f795f633 EZ |
1616 | (defun display-color-p (&optional display) |
1617 | "Return t if DISPLAY supports color. | |
1618 | The optional argument DISPLAY specifies which display to ask about. | |
1619 | DISPLAY should be either a frame or a display name (a string). | |
1620 | If omitted or nil, that stands for the selected frame's display." | |
9e2a2647 | 1621 | (if (memq (framep-on-display display) '(x w32 ns)) |
d5179a01 EZ |
1622 | (xw-display-color-p display) |
1623 | (tty-display-color-p display))) | |
f795f633 EZ |
1624 | (defalias 'x-display-color-p 'display-color-p) |
1625 | ||
aa360da1 GM |
1626 | (declare-function x-display-grayscale-p "xfns.c" (&optional terminal)) |
1627 | ||
d5179a01 EZ |
1628 | (defun display-grayscale-p (&optional display) |
1629 | "Return non-nil if frames on DISPLAY can display shades of gray." | |
1630 | (let ((frame-type (framep-on-display display))) | |
1631 | (cond | |
9e2a2647 | 1632 | ((memq frame-type '(x w32 ns)) |
d5179a01 EZ |
1633 | (x-display-grayscale-p display)) |
1634 | (t | |
1635 | (> (tty-color-gray-shades display) 2))))) | |
1636 | ||
9317e499 | 1637 | (defun read-color (&optional prompt convert-to-RGB allow-empty-name msg) |
315bc30d | 1638 | "Read a color name or RGB triplet. |
9317e499 CY |
1639 | Completion is available for color names, but not for RGB triplets. |
1640 | ||
315bc30d CY |
1641 | RGB triplets have the form \"#RRGGBB\". Each of the R, G, and B |
1642 | components can have one to four digits, but all three components | |
1643 | must have the same number of digits. Each digit is a hex value | |
1644 | between 0 and F; either upper case or lower case for A through F | |
1645 | are acceptable. | |
9317e499 CY |
1646 | |
1647 | In addition to standard color names and RGB hex values, the | |
1648 | following are available as color candidates. In each case, the | |
1649 | corresponding color is used. | |
26c07a69 RS |
1650 | |
1651 | * `foreground at point' - foreground under the cursor | |
1652 | * `background at point' - background under the cursor | |
1653 | ||
9317e499 | 1654 | Optional arg PROMPT is the prompt; if nil, use a default prompt. |
26c07a69 | 1655 | |
9317e499 CY |
1656 | Interactively, or with optional arg CONVERT-TO-RGB-P non-nil, |
1657 | convert an input color name to an RGB hex string. Return the RGB | |
1658 | hex string. | |
26c07a69 | 1659 | |
9317e499 CY |
1660 | If optional arg ALLOW-EMPTY-NAME is non-nil, the user is allowed |
1661 | to enter an empty color name (the empty string). | |
26c07a69 | 1662 | |
9317e499 CY |
1663 | Interactively, or with optional arg MSG non-nil, print the |
1664 | resulting color name in the echo area." | |
26c07a69 RS |
1665 | (interactive "i\np\ni\np") ; Always convert to RGB interactively. |
1666 | (let* ((completion-ignore-case t) | |
9317e499 CY |
1667 | (colors (or facemenu-color-alist |
1668 | (append '("foreground at point" "background at point") | |
1669 | (if allow-empty-name '("")) | |
1670 | (defined-colors)))) | |
1671 | (color (completing-read | |
1672 | (or prompt "Color (name or #RGB triplet): ") | |
1673 | ;; Completing function for reading colors, accepting | |
1674 | ;; both color names and RGB triplets. | |
1675 | (lambda (string pred flag) | |
1676 | (cond | |
1677 | ((null flag) ; Try completion. | |
1678 | (or (try-completion string colors pred) | |
1679 | (if (color-defined-p string) | |
1680 | string))) | |
1681 | ((eq flag t) ; List all completions. | |
1682 | (or (all-completions string colors pred) | |
1683 | (if (color-defined-p string) | |
1684 | (list string)))) | |
1685 | ((eq flag 'lambda) ; Test completion. | |
a9574eb7 | 1686 | (or (member string colors) |
9317e499 | 1687 | (color-defined-p string))))) |
06b60517 | 1688 | nil t))) |
9317e499 CY |
1689 | |
1690 | ;; Process named colors. | |
1691 | (when (member color colors) | |
1692 | (cond ((string-equal color "foreground at point") | |
1693 | (setq color (foreground-color-at-point))) | |
1694 | ((string-equal color "background at point") | |
1695 | (setq color (background-color-at-point)))) | |
1696 | (when (and convert-to-RGB | |
1697 | (not (string-equal color ""))) | |
1698 | (let ((components (x-color-values color))) | |
5e400cb3 | 1699 | (unless (string-match-p "^#\\(?:[a-fA-F0-9][a-fA-F0-9][a-fA-F0-9]\\)+$" color) |
9317e499 CY |
1700 | (setq color (format "#%04X%04X%04X" |
1701 | (logand 65535 (nth 0 components)) | |
1702 | (logand 65535 (nth 1 components)) | |
1703 | (logand 65535 (nth 2 components)))))))) | |
1704 | (when msg (message "Color: `%s'" color)) | |
1705 | color)) | |
1706 | ||
011cddd6 | 1707 | (defun face-at-point (&optional thing multiple) |
26c07a69 RS |
1708 | "Return the face of the character after point. |
1709 | If it has more than one face, return the first one. | |
011cddd6 RW |
1710 | If THING is non-nil try first to get a face name from the buffer. |
1711 | IF MULTIPLE is non-nil, return a list of all faces. | |
1712 | Return nil if there is no face." | |
1713 | (let (faces) | |
1714 | (if thing | |
1715 | ;; Try to get a face name from the buffer. | |
1716 | (let ((face (intern-soft (thing-at-point 'symbol)))) | |
1717 | (if (facep face) | |
1718 | (push face faces)))) | |
1719 | ;; Add the named faces that the `read-face-name' or `face' property uses. | |
1720 | (let ((faceprop (or (get-char-property (point) 'read-face-name) | |
1721 | (get-char-property (point) 'face)))) | |
1722 | (cond ((facep faceprop) | |
1723 | (push faceprop faces)) | |
1724 | ((and (listp faceprop) | |
1725 | ;; Don't treat an attribute spec as a list of faces. | |
1726 | (not (keywordp (car faceprop))) | |
1727 | (not (memq (car faceprop) | |
1728 | '(foreground-color background-color)))) | |
1729 | (dolist (face faceprop) | |
1730 | (if (facep face) | |
1731 | (push face faces)))))) | |
1732 | (setq faces (delete-dups (nreverse faces))) | |
1733 | (if multiple faces (car faces)))) | |
26c07a69 RS |
1734 | |
1735 | (defun foreground-color-at-point () | |
1736 | "Return the foreground color of the character after point." | |
1737 | ;; `face-at-point' alone is not sufficient. It only gets named faces. | |
1738 | ;; Need also pick up any face properties that are not associated with named faces. | |
1739 | (let ((face (or (face-at-point) | |
1740 | (get-char-property (point) 'read-face-name) | |
1741 | (get-char-property (point) 'face)))) | |
1742 | (cond ((and face (symbolp face)) | |
1743 | (let ((value (face-foreground face nil 'default))) | |
1744 | (if (member value '("unspecified-fg" "unspecified-bg")) | |
1745 | nil | |
1746 | value))) | |
1747 | ((consp face) | |
1748 | (cond ((memq 'foreground-color face) (cdr (memq 'foreground-color face))) | |
1749 | ((memq ':foreground face) (cadr (memq ':foreground face))))) | |
1750 | (t nil)))) ; Invalid face value. | |
1751 | ||
1752 | (defun background-color-at-point () | |
1753 | "Return the background color of the character after point." | |
1754 | ;; `face-at-point' alone is not sufficient. It only gets named faces. | |
1755 | ;; Need also pick up any face properties that are not associated with named faces. | |
1756 | (let ((face (or (face-at-point) | |
1757 | (get-char-property (point) 'read-face-name) | |
1758 | (get-char-property (point) 'face)))) | |
1759 | (cond ((and face (symbolp face)) | |
1760 | (let ((value (face-background face nil 'default))) | |
1761 | (if (member value '("unspecified-fg" "unspecified-bg")) | |
1762 | nil | |
1763 | value))) | |
1764 | ((consp face) | |
1765 | (cond ((memq 'background-color face) (cdr (memq 'background-color face))) | |
1766 | ((memq ':background face) (cadr (memq ':background face))))) | |
1767 | (t nil)))) ; Invalid face value. | |
5f5c8ee5 | 1768 | |
5f5c8ee5 GM |
1769 | \f |
1770 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
1771 | ;;; Frame creation. | |
1772 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
1773 | ||
76e69577 GM |
1774 | (declare-function x-display-list "xfns.c" ()) |
1775 | (declare-function x-open-connection "xfns.c" | |
1776 | (display &optional xrm-string must-succeed)) | |
1777 | (declare-function x-get-resource "frame.c" | |
1778 | (attribute class &optional component subclass)) | |
aa360da1 | 1779 | (declare-function x-parse-geometry "frame.c" (string)) |
a88324d4 | 1780 | (defvar x-display-name) |
aa360da1 | 1781 | |
5f5c8ee5 GM |
1782 | (defun x-handle-named-frame-geometry (parameters) |
1783 | "Add geometry parameters for a named frame to parameter list PARAMETERS. | |
1784 | Value is the new parameter list." | |
e8a2b2da | 1785 | ;; Note that `x-resource-name' has a global meaning. |
c1ef4455 | 1786 | (let ((x-resource-name (cdr (assq 'name parameters)))) |
e8a2b2da CY |
1787 | (when x-resource-name |
1788 | ;; Before checking X resources, we must have an X connection. | |
1789 | (or (window-system) | |
1790 | (x-display-list) | |
1791 | (x-open-connection (or (cdr (assq 'display parameters)) | |
1792 | x-display-name))) | |
1793 | (let (res-geometry parsed) | |
1794 | (and (setq res-geometry (x-get-resource "geometry" "Geometry")) | |
1795 | (setq parsed (x-parse-geometry res-geometry)) | |
1796 | (setq parameters | |
c1ef4455 | 1797 | (append parameters parsed |
e8a2b2da CY |
1798 | ;; If the resource specifies a position, |
1799 | ;; take note of that. | |
1800 | (if (or (assq 'top parsed) (assq 'left parsed)) | |
1801 | '((user-position . t) (user-size . t))))))))) | |
1802 | parameters) | |
5f5c8ee5 GM |
1803 | |
1804 | ||
1805 | (defun x-handle-reverse-video (frame parameters) | |
1806 | "Handle the reverse-video frame parameter and X resource. | |
1807 | `x-create-frame' does not handle this one." | |
1808 | (when (cdr (or (assq 'reverse parameters) | |
5f5c8ee5 GM |
1809 | (let ((resource (x-get-resource "reverseVideo" |
1810 | "ReverseVideo"))) | |
1811 | (if resource | |
1812 | (cons nil (member (downcase resource) | |
1813 | '("on" "true"))))))) | |
1814 | (let* ((params (frame-parameters frame)) | |
1815 | (bg (cdr (assq 'foreground-color params))) | |
1816 | (fg (cdr (assq 'background-color params)))) | |
1817 | (modify-frame-parameters frame | |
1818 | (list (cons 'foreground-color fg) | |
1819 | (cons 'background-color bg))) | |
1820 | (if (equal bg (cdr (assq 'border-color params))) | |
1821 | (modify-frame-parameters frame | |
1822 | (list (cons 'border-color fg)))) | |
1823 | (if (equal bg (cdr (assq 'mouse-color params))) | |
1824 | (modify-frame-parameters frame | |
1825 | (list (cons 'mouse-color fg)))) | |
1826 | (if (equal bg (cdr (assq 'cursor-color params))) | |
1827 | (modify-frame-parameters frame | |
1828 | (list (cons 'cursor-color fg))))))) | |
1829 | ||
aa360da1 | 1830 | (declare-function x-create-frame "xfns.c" (parms)) |
c8ccffb1 | 1831 | (declare-function x-setup-function-keys "term/common-win" (frame)) |
5f5c8ee5 GM |
1832 | |
1833 | (defun x-create-frame-with-faces (&optional parameters) | |
c1ef4455 CY |
1834 | "Create and return a frame with frame parameters PARAMETERS. |
1835 | If PARAMETERS specify a frame name, handle X geometry resources | |
1836 | for that name. If PARAMETERS includes a `reverse' parameter, or | |
1837 | the X resource ``reverseVideo'' is present, handle that." | |
5f5c8ee5 | 1838 | (setq parameters (x-handle-named-frame-geometry parameters)) |
41e6403e CY |
1839 | (let* ((params (copy-tree parameters)) |
1840 | (visibility-spec (assq 'visibility parameters)) | |
1841 | (delayed-params '(foreground-color background-color font | |
1842 | border-color cursor-color mouse-color | |
1843 | visibility scroll-bar-foreground | |
1844 | scroll-bar-background)) | |
1845 | frame success) | |
1846 | (dolist (param delayed-params) | |
1847 | (setq params (assq-delete-all param params))) | |
1848 | (setq frame (x-create-frame `((visibility . nil) . ,params))) | |
5f5c8ee5 GM |
1849 | (unwind-protect |
1850 | (progn | |
2bb819d5 | 1851 | (x-setup-function-keys frame) |
5f5c8ee5 | 1852 | (x-handle-reverse-video frame parameters) |
4983ddea | 1853 | (frame-set-background-mode frame t) |
fa7015f4 | 1854 | (face-set-after-frame-default frame parameters) |
095fe281 | 1855 | (if (null visibility-spec) |
5f5c8ee5 GM |
1856 | (make-frame-visible frame) |
1857 | (modify-frame-parameters frame (list visibility-spec))) | |
1858 | (setq success t)) | |
1859 | (unless success | |
1860 | (delete-frame frame))) | |
1861 | frame)) | |
1862 | ||
fa7015f4 CY |
1863 | (defun face-set-after-frame-default (frame &optional parameters) |
1864 | "Initialize the frame-local faces of FRAME. | |
1865 | Calculate the face definitions using the face specs, custom theme | |
41e6403e | 1866 | settings, X resources, and `face-new-frame-defaults'. |
fa7015f4 | 1867 | Finally, apply any relevant face attributes found amongst the |
c1ef4455 | 1868 | frame parameters in PARAMETERS." |
b92583c4 JB |
1869 | ;; The `reverse' is so that `default' goes first. |
1870 | (dolist (face (nreverse (face-list))) | |
1871 | (condition-case () | |
1872 | (progn | |
1873 | ;; Initialize faces from face spec and custom theme. | |
1874 | (face-spec-recalc face frame) | |
1875 | ;; Apply attributes specified by face-new-frame-defaults | |
1876 | (internal-merge-in-global-face face frame)) | |
1877 | ;; Don't let invalid specs prevent frame creation. | |
1878 | (error nil))) | |
4983ddea | 1879 | |
fa7015f4 | 1880 | ;; Apply attributes specified by frame parameters. |
8db9c5ee | 1881 | (let ((face-params '((foreground-color default :foreground) |
fa7015f4 CY |
1882 | (background-color default :background) |
1883 | (font default :font) | |
1884 | (border-color border :background) | |
1885 | (cursor-color cursor :background) | |
1886 | (scroll-bar-foreground scroll-bar :foreground) | |
1887 | (scroll-bar-background scroll-bar :background) | |
1888 | (mouse-color mouse :background)))) | |
8db9c5ee | 1889 | (dolist (param face-params) |
fa7015f4 | 1890 | (let* ((param-name (nth 0 param)) |
c1ef4455 | 1891 | (value (cdr (assq param-name parameters)))) |
fa7015f4 CY |
1892 | (if value |
1893 | (set-face-attribute (nth 1 param) frame | |
1894 | (nth 2 param) value)))))) | |
5f5c8ee5 | 1895 | |
53990c84 EZ |
1896 | (defun tty-handle-reverse-video (frame parameters) |
1897 | "Handle the reverse-video frame parameter for terminal frames." | |
c1ef4455 | 1898 | (when (cdr (assq 'reverse parameters)) |
53990c84 EZ |
1899 | (let* ((params (frame-parameters frame)) |
1900 | (bg (cdr (assq 'foreground-color params))) | |
1901 | (fg (cdr (assq 'background-color params)))) | |
1902 | (modify-frame-parameters frame | |
1903 | (list (cons 'foreground-color fg) | |
1904 | (cons 'background-color bg))) | |
1905 | (if (equal bg (cdr (assq 'mouse-color params))) | |
1906 | (modify-frame-parameters frame | |
1907 | (list (cons 'mouse-color fg)))) | |
1908 | (if (equal bg (cdr (assq 'cursor-color params))) | |
1909 | (modify-frame-parameters frame | |
1910 | (list (cons 'cursor-color fg))))))) | |
1911 | ||
5f5c8ee5 GM |
1912 | |
1913 | (defun tty-create-frame-with-faces (&optional parameters) | |
c1ef4455 CY |
1914 | "Create and return a frame from optional frame parameters PARAMETERS. |
1915 | If PARAMETERS contains a `reverse' parameter, handle that." | |
5f5c8ee5 GM |
1916 | (let ((frame (make-terminal-frame parameters)) |
1917 | success) | |
1918 | (unwind-protect | |
061e4e7f | 1919 | (with-selected-frame frame |
53990c84 | 1920 | (tty-handle-reverse-video frame (frame-parameters frame)) |
cd85984a | 1921 | |
8782c744 SM |
1922 | (unless (terminal-parameter frame 'terminal-initted) |
1923 | (set-terminal-parameter frame 'terminal-initted t) | |
1924 | (set-locale-environment nil frame) | |
1d491ef2 | 1925 | (tty-run-terminal-initialization frame nil t)) |
4983ddea | 1926 | (frame-set-background-mode frame t) |
fa7015f4 | 1927 | (face-set-after-frame-default frame parameters) |
5f5c8ee5 GM |
1928 | (setq success t)) |
1929 | (unless success | |
1930 | (delete-frame frame))) | |
1931 | frame)) | |
465fceed | 1932 | |
b34c34da KL |
1933 | (defun tty-find-type (pred type) |
1934 | "Return the longest prefix of TYPE to which PRED returns non-nil. | |
1935 | TYPE should be a tty type name such as \"xterm-16color\". | |
1936 | ||
1937 | The function tries only those prefixes that are followed by a | |
1938 | dash or underscore in the original type name, like \"xterm\" in | |
1939 | the above example." | |
1940 | (let (hyphend) | |
1941 | (while (and type | |
1942 | (not (funcall pred type))) | |
1943 | ;; Strip off last hyphen and what follows, then try again | |
1944 | (setq type | |
5e400cb3 | 1945 | (if (setq hyphend (string-match-p "[-_][^-_]+$" type)) |
b34c34da KL |
1946 | (substring type 0 hyphend) |
1947 | nil)))) | |
1948 | type) | |
1949 | ||
7fd72e2c SM |
1950 | (defvar tty-setup-hook nil |
1951 | "Hook run after running the initialization function of a new text terminal. | |
98bd6b32 | 1952 | Specifically, `tty-run-terminal-initialization' runs this. |
7fd72e2c SM |
1953 | This can be used to fine tune the `input-decode-map', for example.") |
1954 | ||
1d491ef2 | 1955 | (defun tty-run-terminal-initialization (frame &optional type run-hook) |
8cbd7bed KL |
1956 | "Run the special initialization code for the terminal type of FRAME. |
1957 | The optional TYPE parameter may be used to override the autodetected | |
1d491ef2 GM |
1958 | terminal type to a different value. |
1959 | ||
95de732d GM |
1960 | This consults `term-file-aliases' to map terminal types to their aliases. |
1961 | ||
1d491ef2 GM |
1962 | If optional argument RUN-HOOK is non-nil, then as a final step, |
1963 | this runs the hook `tty-setup-hook'. | |
98bd6b32 GM |
1964 | |
1965 | If you set `term-file-prefix' to nil, this function does nothing." | |
8cbd7bed | 1966 | (setq type (or type (tty-type frame))) |
06940bd0 GM |
1967 | (let ((alias (tty-find-type |
1968 | (lambda (typ) (assoc typ term-file-aliases)) type))) | |
1969 | (if alias (setq type (cdr (assoc alias term-file-aliases))))) | |
cd85984a KL |
1970 | ;; Load library for our terminal type. |
1971 | ;; User init file can set term-file-prefix to nil to prevent this. | |
1972 | (with-selected-frame frame | |
8782c744 | 1973 | (unless (null term-file-prefix) |
b34c34da KL |
1974 | (let* (term-init-func) |
1975 | ;; First, load the terminal initialization file, if it is | |
1976 | ;; available and it hasn't been loaded already. | |
1977 | (tty-find-type #'(lambda (type) | |
1978 | (let ((file (locate-library (concat term-file-prefix type)))) | |
1979 | (and file | |
1980 | (or (assoc file load-history) | |
1981 | (load file t t))))) | |
8cbd7bed | 1982 | type) |
b34c34da KL |
1983 | ;; Next, try to find a matching initialization function, and call it. |
1984 | (tty-find-type #'(lambda (type) | |
1985 | (fboundp (setq term-init-func | |
1986 | (intern (concat "terminal-init-" type))))) | |
8cbd7bed | 1987 | type) |
567c8878 | 1988 | (when (fboundp term-init-func) |
b34c34da | 1989 | (funcall term-init-func)) |
f1e6674b | 1990 | (set-terminal-parameter frame 'terminal-initted term-init-func) |
1d491ef2 | 1991 | (if run-hook (run-hooks 'tty-setup-hook)))))) |
465fceed | 1992 | |
5f5c8ee5 GM |
1993 | ;; Called from C function init_display to initialize faces of the |
1994 | ;; dumped terminal frame on startup. | |
465fceed | 1995 | |
5f5c8ee5 GM |
1996 | (defun tty-set-up-initial-frame-faces () |
1997 | (let ((frame (selected-frame))) | |
4983ddea | 1998 | (frame-set-background-mode frame t) |
5f5c8ee5 | 1999 | (face-set-after-frame-default frame))) |
00f51890 | 2000 | |
bdda3754 | 2001 | \f |
5f5c8ee5 GM |
2002 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2003 | ;;; Standard faces. | |
2004 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
465fceed | 2005 | |
5f5c8ee5 GM |
2006 | (defgroup basic-faces nil |
2007 | "The standard faces of Emacs." | |
2008 | :group 'faces) | |
ef436392 | 2009 | |
bacbbe8f CY |
2010 | (defface default |
2011 | '((t nil)) ; If this were nil, face-defface-spec would not be set. | |
5f5c8ee5 GM |
2012 | "Basic default face." |
2013 | :group 'basic-faces) | |
465fceed | 2014 | |
51d44a36 JL |
2015 | (defface bold |
2016 | '((t :weight bold)) | |
2017 | "Basic bold face." | |
2018 | :group 'basic-faces) | |
2019 | ||
2020 | (defface italic | |
2021 | '((((supports :slant italic)) | |
2022 | :slant italic) | |
2023 | (((supports :underline t)) | |
2024 | :underline t) | |
2025 | (t | |
9aaf2b9c GM |
2026 | ;; Default to italic, even if it doesn't appear to be supported, |
2027 | ;; because in some cases the display engine will do its own | |
2028 | ;; workaround (to `dim' on ttys). | |
51d44a36 JL |
2029 | :slant italic)) |
2030 | "Basic italic face." | |
2031 | :group 'basic-faces) | |
2032 | ||
2033 | (defface bold-italic | |
2034 | '((t :weight bold :slant italic)) | |
2035 | "Basic bold-italic face." | |
2036 | :group 'basic-faces) | |
2037 | ||
2038 | (defface underline | |
2039 | '((((supports :underline t)) | |
2040 | :underline t) | |
2041 | (((supports :weight bold)) | |
2042 | :weight bold) | |
2043 | (t :underline t)) | |
2044 | "Basic underlined face." | |
2045 | :group 'basic-faces) | |
2046 | ||
2047 | (defface fixed-pitch | |
d5f57335 | 2048 | '((t :family "Monospace")) |
51d44a36 JL |
2049 | "The basic fixed-pitch face." |
2050 | :group 'basic-faces) | |
2051 | ||
2052 | (defface variable-pitch | |
ed008205 | 2053 | '((t :family "Sans Serif")) |
51d44a36 JL |
2054 | "The basic variable-pitch face." |
2055 | :group 'basic-faces) | |
2056 | ||
2057 | (defface shadow | |
2058 | '((((class color grayscale) (min-colors 88) (background light)) | |
2059 | :foreground "grey50") | |
2060 | (((class color grayscale) (min-colors 88) (background dark)) | |
2061 | :foreground "grey70") | |
2062 | (((class color) (min-colors 8) (background light)) | |
2063 | :foreground "green") | |
2064 | (((class color) (min-colors 8) (background dark)) | |
2065 | :foreground "yellow")) | |
2066 | "Basic face for shadowed text." | |
2067 | :group 'basic-faces | |
2068 | :version "22.1") | |
2069 | ||
59746720 JL |
2070 | (defface link |
2071 | '((((class color) (min-colors 88) (background light)) | |
fa7c3228 | 2072 | :foreground "RoyalBlue3" :underline t) |
59746720 JL |
2073 | (((class color) (background light)) |
2074 | :foreground "blue" :underline t) | |
2075 | (((class color) (min-colors 88) (background dark)) | |
2076 | :foreground "cyan1" :underline t) | |
2077 | (((class color) (background dark)) | |
2078 | :foreground "cyan" :underline t) | |
2079 | (t :inherit underline)) | |
2080 | "Basic face for unvisited links." | |
2081 | :group 'basic-faces | |
2082 | :version "22.1") | |
2083 | ||
2084 | (defface link-visited | |
2085 | '((default :inherit link) | |
2086 | (((class color) (background light)) :foreground "magenta4") | |
2087 | (((class color) (background dark)) :foreground "violet")) | |
2088 | "Basic face for visited links." | |
2089 | :group 'basic-faces | |
2090 | :version "22.1") | |
2091 | ||
51d44a36 JL |
2092 | (defface highlight |
2093 | '((((class color) (min-colors 88) (background light)) | |
2094 | :background "darkseagreen2") | |
2095 | (((class color) (min-colors 88) (background dark)) | |
2096 | :background "darkolivegreen") | |
2097 | (((class color) (min-colors 16) (background light)) | |
2098 | :background "darkseagreen2") | |
2099 | (((class color) (min-colors 16) (background dark)) | |
2100 | :background "darkolivegreen") | |
2101 | (((class color) (min-colors 8)) | |
2102 | :background "green" :foreground "black") | |
2103 | (t :inverse-video t)) | |
2104 | "Basic face for highlighting." | |
2105 | :group 'basic-faces) | |
2106 | ||
f3e848f4 AR |
2107 | ;; Region face: under NS, default to the system-defined selection |
2108 | ;; color (optimized for the fixed white background of other apps), | |
2109 | ;; if background is light. | |
51d44a36 JL |
2110 | (defface region |
2111 | '((((class color) (min-colors 88) (background dark)) | |
2112 | :background "blue3") | |
3a46642b | 2113 | (((class color) (min-colors 88) (background light) (type gtk)) |
3c334c14 | 2114 | :distant-foreground "gtk_selection_fg_color" |
3a46642b | 2115 | :background "gtk_selection_bg_color") |
f3e848f4 | 2116 | (((class color) (min-colors 88) (background light) (type ns)) |
3c334c14 | 2117 | :distant-foreground "ns_selection_fg_color" |
1610938f | 2118 | :background "ns_selection_bg_color") |
51d44a36 JL |
2119 | (((class color) (min-colors 88) (background light)) |
2120 | :background "lightgoldenrod2") | |
2121 | (((class color) (min-colors 16) (background dark)) | |
2122 | :background "blue3") | |
2123 | (((class color) (min-colors 16) (background light)) | |
2124 | :background "lightgoldenrod2") | |
2125 | (((class color) (min-colors 8)) | |
2126 | :background "blue" :foreground "white") | |
2127 | (((type tty) (class mono)) | |
2128 | :inverse-video t) | |
2129 | (t :background "gray")) | |
2130 | "Basic face for highlighting the region." | |
2131 | :version "21.1" | |
2132 | :group 'basic-faces) | |
2133 | ||
2134 | (defface secondary-selection | |
2135 | '((((class color) (min-colors 88) (background light)) | |
2136 | :background "yellow1") | |
2137 | (((class color) (min-colors 88) (background dark)) | |
2138 | :background "SkyBlue4") | |
2139 | (((class color) (min-colors 16) (background light)) | |
2140 | :background "yellow") | |
2141 | (((class color) (min-colors 16) (background dark)) | |
2142 | :background "SkyBlue4") | |
2143 | (((class color) (min-colors 8)) | |
2144 | :background "cyan" :foreground "black") | |
2145 | (t :inverse-video t)) | |
2146 | "Basic face for displaying the secondary selection." | |
2147 | :group 'basic-faces) | |
2148 | ||
2149 | (defface trailing-whitespace | |
2150 | '((((class color) (background light)) | |
2151 | :background "red1") | |
2152 | (((class color) (background dark)) | |
2153 | :background "red1") | |
2154 | (t :inverse-video t)) | |
2155 | "Basic face for highlighting trailing whitespace." | |
2156 | :version "21.1" | |
51d44a36 JL |
2157 | :group 'basic-faces) |
2158 | ||
2159 | (defface escape-glyph | |
2160 | '((((background dark)) :foreground "cyan") | |
2161 | ;; See the comment in minibuffer-prompt for | |
2162 | ;; the reason not to use blue on MS-DOS. | |
2163 | (((type pc)) :foreground "magenta") | |
2164 | ;; red4 is too dark, but some say blue is too loud. | |
2165 | ;; brown seems to work ok. -- rms. | |
2166 | (t :foreground "brown")) | |
1a77c985 | 2167 | "Face for characters displayed as sequences using `^' or `\\'." |
51d44a36 JL |
2168 | :group 'basic-faces |
2169 | :version "22.1") | |
2170 | ||
2171 | (defface nobreak-space | |
2172 | '((((class color) (min-colors 88)) :inherit escape-glyph :underline t) | |
2173 | (((class color) (min-colors 8)) :background "magenta") | |
2174 | (t :inverse-video t)) | |
2175 | "Face for displaying nobreak space." | |
2176 | :group 'basic-faces | |
2177 | :version "22.1") | |
72418504 | 2178 | |
97bca259 JL |
2179 | (defgroup mode-line-faces nil |
2180 | "Faces used in the mode line." | |
6d968826 | 2181 | :group 'mode-line |
97bca259 JL |
2182 | :group 'faces |
2183 | :version "22.1") | |
2184 | ||
3759f14b | 2185 | (defface mode-line |
11c2175c | 2186 | '((((class color) (min-colors 88)) |
b6b90dfc SM |
2187 | :box (:line-width -1 :style released-button) |
2188 | :background "grey75" :foreground "black") | |
5f5c8ee5 | 2189 | (t |
b6b90dfc | 2190 | :inverse-video t)) |
c5752dcb | 2191 | "Basic mode line face for selected window." |
a4391cf1 | 2192 | :version "21.1" |
97bca259 | 2193 | :group 'mode-line-faces |
5f5c8ee5 | 2194 | :group 'basic-faces) |
465fceed | 2195 | |
c5752dcb | 2196 | (defface mode-line-inactive |
cf459bb7 | 2197 | '((default |
b6b90dfc | 2198 | :inherit mode-line) |
11c2175c | 2199 | (((class color) (min-colors 88) (background light)) |
c5752dcb KS |
2200 | :weight light |
2201 | :box (:line-width -1 :color "grey75" :style nil) | |
2202 | :foreground "grey20" :background "grey90") | |
11c2175c | 2203 | (((class color) (min-colors 88) (background dark) ) |
53a2f6e1 MB |
2204 | :weight light |
2205 | :box (:line-width -1 :color "grey40" :style nil) | |
b6b90dfc | 2206 | :foreground "grey80" :background "grey30")) |
c5752dcb | 2207 | "Basic mode line face for non-selected windows." |
bf247b6e | 2208 | :version "22.1" |
97bca259 JL |
2209 | :group 'mode-line-faces |
2210 | :group 'basic-faces) | |
9f255bc3 | 2211 | (define-obsolete-face-alias 'modeline-inactive 'mode-line-inactive "22.1") |
97bca259 JL |
2212 | |
2213 | (defface mode-line-highlight | |
2214 | '((((class color) (min-colors 88)) | |
2215 | :box (:line-width 2 :color "grey40" :style released-button)) | |
2216 | (t | |
2217 | :inherit highlight)) | |
2218 | "Basic mode line face for highlighting." | |
2219 | :version "22.1" | |
2220 | :group 'mode-line-faces | |
2221 | :group 'basic-faces) | |
9f255bc3 | 2222 | (define-obsolete-face-alias 'modeline-highlight 'mode-line-highlight "22.1") |
97bca259 | 2223 | |
313e2fc4 GM |
2224 | (defface mode-line-emphasis |
2225 | '((t (:weight bold))) | |
2226 | "Face used to emphasize certain mode line features. | |
2227 | Use the face `mode-line-highlight' for features that can be selected." | |
2228 | :version "23.1" | |
2229 | :group 'mode-line-faces | |
2230 | :group 'basic-faces) | |
2231 | ||
97bca259 JL |
2232 | (defface mode-line-buffer-id |
2233 | '((t (:weight bold))) | |
2234 | "Face used for buffer identification parts of the mode line." | |
2235 | :version "22.1" | |
2236 | :group 'mode-line-faces | |
c5752dcb | 2237 | :group 'basic-faces) |
9f255bc3 | 2238 | (define-obsolete-face-alias 'modeline-buffer-id 'mode-line-buffer-id "22.1") |
d11fba25 | 2239 | |
e5e7779f | 2240 | (defface header-line |
cf459bb7 | 2241 | '((default |
6b61353c KH |
2242 | :inherit mode-line) |
2243 | (((type tty)) | |
1cb4393e MB |
2244 | ;; This used to be `:inverse-video t', but that doesn't look very |
2245 | ;; good when combined with inverse-video mode-lines and multiple | |
2246 | ;; windows. Underlining looks better, and is more consistent with | |
2247 | ;; the window-system face variants, which deemphasize the | |
2248 | ;; header-line in relation to the mode-line face. If a terminal | |
2249 | ;; can't underline, then the header-line will end up without any | |
2250 | ;; highlighting; this may be too confusing in general, although it | |
2251 | ;; happens to look good with the only current use of header-lines, | |
2252 | ;; the info browser. XXX | |
6b61353c | 2253 | :inverse-video nil ;Override the value inherited from mode-line. |
a7ac92b6 | 2254 | :underline t) |
98490598 | 2255 | (((class color grayscale) (background light)) |
bdab1d43 | 2256 | :background "grey90" :foreground "grey20" |
6b61353c | 2257 | :box nil) |
98490598 | 2258 | (((class color grayscale) (background dark)) |
bdab1d43 | 2259 | :background "grey20" :foreground "grey90" |
6b61353c | 2260 | :box nil) |
98490598 | 2261 | (((class mono) (background light)) |
bdab1d43 MB |
2262 | :background "white" :foreground "black" |
2263 | :inverse-video nil | |
2264 | :box nil | |
6b61353c | 2265 | :underline t) |
98490598 | 2266 | (((class mono) (background dark)) |
bdab1d43 MB |
2267 | :background "black" :foreground "white" |
2268 | :inverse-video nil | |
2269 | :box nil | |
6b61353c | 2270 | :underline t)) |
e5e7779f | 2271 | "Basic header-line face." |
a4391cf1 | 2272 | :version "21.1" |
5f5c8ee5 | 2273 | :group 'basic-faces) |
e8e4cda0 | 2274 | |
51d44a36 JL |
2275 | (defface vertical-border |
2276 | '((((type tty)) :inherit mode-line-inactive)) | |
2277 | "Face used for vertical window dividers on ttys." | |
2278 | :version "22.1" | |
5f5c8ee5 | 2279 | :group 'basic-faces) |
d11fba25 | 2280 | |
764ec9e5 MR |
2281 | (defface window-divider '((t :foreground "gray60")) |
2282 | "Basic face for window dividers. | |
2283 | When a divider is less than 3 pixels wide, it is drawn solidly | |
2284 | with the foreground of this face. For larger dividers this face | |
2285 | is used for the inner part while the first pixel line/column is | |
2286 | drawn with the `window-divider-first-pixel' face and the last | |
2287 | pixel line/column with the `window-divider-last-pixel' face." | |
2288 | :version "24.4" | |
2289 | :group 'frames | |
2290 | :group 'basic-faces) | |
2291 | ||
2292 | (defface window-divider-first-pixel | |
2293 | '((t :foreground "gray80")) | |
2294 | "Basic face for first pixel line/column of window dividers. | |
2295 | When a divider is at least 3 pixels wide, its first pixel | |
2296 | line/column is drawn with the foreground of this face. If you do | |
2297 | not want to accentuate the first pixel line/column, set this to | |
2298 | the same as `window-divider' face." | |
2299 | :version "24.4" | |
2300 | :group 'frames | |
2301 | :group 'basic-faces) | |
2302 | ||
2303 | (defface window-divider-last-pixel | |
2304 | '((t :foreground "gray40")) | |
2305 | "Basic face for last pixel line/column of window dividers. | |
2306 | When a divider is at least 3 pixels wide, its last pixel | |
2307 | line/column is drawn with the foreground of this face. If you do | |
2308 | not want to accentuate the last pixel line/column, set this to | |
2309 | the same as `window-divider' face." | |
2310 | :version "24.4" | |
2311 | :group 'frames | |
2312 | :group 'basic-faces) | |
2313 | ||
9ed779e8 JL |
2314 | (defface minibuffer-prompt |
2315 | '((((background dark)) :foreground "cyan") | |
2316 | ;; Don't use blue because many users of the MS-DOS port customize | |
2317 | ;; their foreground color to be blue. | |
2318 | (((type pc)) :foreground "magenta") | |
c57a1dc6 | 2319 | (t :foreground "medium blue")) |
9ed779e8 JL |
2320 | "Face for minibuffer prompts. |
2321 | By default, Emacs automatically adds this face to the value of | |
2322 | `minibuffer-prompt-properties', which is a list of text properties | |
2323 | used to display the prompt text." | |
bf247b6e | 2324 | :version "22.1" |
31cf46d3 RS |
2325 | :group 'basic-faces) |
2326 | ||
2327 | (setq minibuffer-prompt-properties | |
2328 | (append minibuffer-prompt-properties (list 'face 'minibuffer-prompt))) | |
2329 | ||
f1cae29e | 2330 | (defface fringe |
d6d59057 | 2331 | '((((class color) (background light)) |
b6b90dfc SM |
2332 | :background "grey95") |
2333 | (((class color) (background dark)) | |
2334 | :background "grey10") | |
2335 | (t | |
2336 | :background "gray")) | |
f1cae29e GM |
2337 | "Basic face for the fringes to the left and right of windows under X." |
2338 | :version "21.1" | |
84fe35f0 | 2339 | :group 'frames |
f1cae29e GM |
2340 | :group 'basic-faces) |
2341 | ||
d390b4d2 | 2342 | (defface scroll-bar '((t nil)) |
f1cae29e GM |
2343 | "Basic face for the scroll bar colors under X." |
2344 | :version "21.1" | |
84fe35f0 | 2345 | :group 'frames |
f1cae29e GM |
2346 | :group 'basic-faces) |
2347 | ||
d390b4d2 | 2348 | (defface border '((t nil)) |
f1cae29e GM |
2349 | "Basic face for the frame border under X." |
2350 | :version "21.1" | |
84fe35f0 | 2351 | :group 'frames |
f1cae29e GM |
2352 | :group 'basic-faces) |
2353 | ||
4983ddea CY |
2354 | (defface cursor |
2355 | '((((background light)) :background "black") | |
2356 | (((background dark)) :background "white")) | |
8d413c2b | 2357 | "Basic face for the cursor color under X. |
08b0fee8 CY |
2358 | Currently, only the `:background' attribute is meaningful; all |
2359 | other attributes are ignored. The cursor foreground color is | |
2360 | taken from the background color of the underlying text. | |
2361 | ||
8d413c2b | 2362 | Note: Other faces cannot inherit from the cursor face." |
f1cae29e | 2363 | :version "21.1" |
84fe35f0 | 2364 | :group 'cursor |
f1cae29e GM |
2365 | :group 'basic-faces) |
2366 | ||
8d413c2b | 2367 | (put 'cursor 'face-no-inherit t) |
f1cae29e | 2368 | |
d390b4d2 | 2369 | (defface mouse '((t nil)) |
f1cae29e | 2370 | "Basic face for the mouse color under X." |
e59176e2 | 2371 | :version "21.1" |
84fe35f0 | 2372 | :group 'mouse |
5f5c8ee5 | 2373 | :group 'basic-faces) |
bdda3754 | 2374 | |
51d44a36 JL |
2375 | (defface tool-bar |
2376 | '((default | |
2377 | :box (:line-width 1 :style released-button) | |
2378 | :foreground "black") | |
9e2a2647 | 2379 | (((type x w32 ns) (class color)) |
51d44a36 JL |
2380 | :background "grey75") |
2381 | (((type x) (class mono)) | |
2382 | :background "grey")) | |
2383 | "Basic tool-bar face." | |
2384 | :version "21.1" | |
5f5c8ee5 | 2385 | :group 'basic-faces) |
bdda3754 | 2386 | |
51d44a36 JL |
2387 | (defface menu |
2388 | '((((type tty)) | |
2389 | :inverse-video t) | |
2390 | (((type x-toolkit)) | |
2391 | ) | |
16320ac7 | 2392 | (t |
51d44a36 JL |
2393 | :inverse-video t)) |
2394 | "Basic face for the font and colors of the menu bar and popup menus." | |
a4391cf1 | 2395 | :version "21.1" |
51d44a36 | 2396 | :group 'menu |
a4391cf1 | 2397 | :group 'basic-faces) |
465fceed | 2398 | |
4c47bd1e | 2399 | (defface help-argument-name '((t :inherit italic)) |
6c58c39c CY |
2400 | "Face to highlight argument names in *Help* buffers." |
2401 | :group 'help) | |
b2cca856 | 2402 | |
b18fad6d KH |
2403 | (defface glyphless-char |
2404 | '((((type tty)) :inherit underline) | |
1cd64aae | 2405 | (((type pc)) :inherit escape-glyph) |
b18fad6d | 2406 | (t :height 0.6)) |
b2cca856 KH |
2407 | "Face for displaying non-graphic characters (e.g. U+202A (LRE)). |
2408 | It is used for characters of no fonts too." | |
2409 | :version "24.1" | |
2410 | :group 'basic-faces) | |
bc987f8b JL |
2411 | |
2412 | (defface error | |
4b56d0fe CY |
2413 | '((default :weight bold) |
2414 | (((class color) (min-colors 88) (background light)) :foreground "Red1") | |
2415 | (((class color) (min-colors 88) (background dark)) :foreground "Pink") | |
2416 | (((class color) (min-colors 16) (background light)) :foreground "Red1") | |
2417 | (((class color) (min-colors 16) (background dark)) :foreground "Pink") | |
2418 | (((class color) (min-colors 8)) :foreground "red") | |
2419 | (t :inverse-video t)) | |
bc987f8b JL |
2420 | "Basic face used to highlight errors and to denote failure." |
2421 | :version "24.1" | |
2422 | :group 'basic-faces) | |
2423 | ||
2424 | (defface warning | |
4b56d0fe CY |
2425 | '((default :weight bold) |
2426 | (((class color) (min-colors 16)) :foreground "DarkOrange") | |
2427 | (((class color)) :foreground "yellow")) | |
bc987f8b JL |
2428 | "Basic face used to highlight warnings." |
2429 | :version "24.1" | |
2430 | :group 'basic-faces) | |
2431 | ||
2432 | (defface success | |
4b56d0fe CY |
2433 | '((default :weight bold) |
2434 | (((class color) (min-colors 16) (background light)) :foreground "ForestGreen") | |
2435 | (((class color) (min-colors 88) (background dark)) :foreground "Green1") | |
2436 | (((class color) (min-colors 16) (background dark)) :foreground "Green") | |
2437 | (((class color)) :foreground "green")) | |
bc987f8b JL |
2438 | "Basic face used to indicate successful operation." |
2439 | :version "24.1" | |
2440 | :group 'basic-faces) | |
2441 | ||
0fe3602a EZ |
2442 | ;; Faces for TTY menus. |
2443 | (defface tty-menu-enabled-face | |
2444 | '((t | |
2445 | :foreground "yellow" :background "blue" :weight bold)) | |
2446 | "Face for displaying enabled items in TTY menus." | |
2447 | :group 'basic-faces) | |
2448 | ||
2449 | (defface tty-menu-disabled-face | |
2450 | '((((class color) (min-colors 16)) | |
2451 | :foreground "lightgray" :background "blue") | |
2452 | (t | |
2453 | :foreground "white" :background "blue")) | |
2454 | "Face for displaying disabled items in TTY menus." | |
2455 | :group 'basic-faces) | |
2456 | ||
2457 | (defface tty-menu-selected-face | |
2458 | '((t :background "red")) | |
2459 | "Face for displaying the currently selected item in TTY menus." | |
2460 | :group 'basic-faces) | |
2461 | ||
84c73ba0 DG |
2462 | (defgroup paren-showing-faces nil |
2463 | "Faces used to highlight paren matches." | |
2464 | :group 'paren-showing | |
2465 | :group 'faces | |
2466 | :version "22.1") | |
2467 | ||
2468 | (defface show-paren-match | |
2469 | '((((class color) (background light)) | |
2470 | :background "turquoise") ; looks OK on tty (becomes cyan) | |
2471 | (((class color) (background dark)) | |
2472 | :background "steelblue3") ; looks OK on tty (becomes blue) | |
2473 | (((background dark)) | |
2474 | :background "grey50") | |
2475 | (t | |
2476 | :background "gray")) | |
2477 | "Face used for a matching paren." | |
2478 | :group 'paren-showing-faces) | |
2479 | ||
2480 | (defface show-paren-mismatch | |
2481 | '((((class color)) (:foreground "white" :background "purple")) | |
2482 | (t (:inverse-video t))) | |
2483 | "Face used for a mismatching paren." | |
2484 | :group 'paren-showing-faces) | |
2485 | ||
465fceed | 2486 | \f |
5f5c8ee5 GM |
2487 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2488 | ;;; Manipulating font names. | |
2489 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
2490 | ||
da6062e6 | 2491 | ;; This is here for compatibility with Emacs 20.2. For example, |
07f27947 DL |
2492 | ;; international/fontset.el uses x-resolve-font-name. The following |
2493 | ;; functions are not used in the face implementation itself. | |
465fceed | 2494 | |
d7fa5aa2 RS |
2495 | (defvar x-font-regexp nil) |
2496 | (defvar x-font-regexp-head nil) | |
2497 | (defvar x-font-regexp-weight nil) | |
2498 | (defvar x-font-regexp-slant nil) | |
465fceed | 2499 | |
021ca129 KH |
2500 | (defconst x-font-regexp-weight-subnum 1) |
2501 | (defconst x-font-regexp-slant-subnum 2) | |
2502 | (defconst x-font-regexp-swidth-subnum 3) | |
2503 | (defconst x-font-regexp-adstyle-subnum 4) | |
2504 | ||
465fceed ER |
2505 | ;;; Regexps matching font names in "Host Portable Character Representation." |
2506 | ;;; | |
2507 | (let ((- "[-?]") | |
2508 | (foundry "[^-]+") | |
2509 | (family "[^-]+") | |
2510 | (weight "\\(bold\\|demibold\\|medium\\)") ; 1 | |
2511 | ; (weight\? "\\(\\*\\|bold\\|demibold\\|medium\\|\\)") ; 1 | |
2512 | (weight\? "\\([^-]*\\)") ; 1 | |
2513 | (slant "\\([ior]\\)") ; 2 | |
2514 | ; (slant\? "\\([ior?*]?\\)") ; 2 | |
2515 | (slant\? "\\([^-]?\\)") ; 2 | |
2516 | ; (swidth "\\(\\*\\|normal\\|semicondensed\\|\\)") ; 3 | |
2517 | (swidth "\\([^-]*\\)") ; 3 | |
2518 | ; (adstyle "\\(\\*\\|sans\\|\\)") ; 4 | |
c8787b81 | 2519 | (adstyle "\\([^-]*\\)") ; 4 |
465fceed ER |
2520 | (pixelsize "[0-9]+") |
2521 | (pointsize "[0-9][0-9]+") | |
2522 | (resx "[0-9][0-9]+") | |
2523 | (resy "[0-9][0-9]+") | |
2524 | (spacing "[cmp?*]") | |
2525 | (avgwidth "[0-9]+") | |
2526 | (registry "[^-]+") | |
2527 | (encoding "[^-]+") | |
2528 | ) | |
2529 | (setq x-font-regexp | |
1e8780b1 | 2530 | (purecopy (concat "\\`\\*?[-?*]" |
465fceed | 2531 | foundry - family - weight\? - slant\? - swidth - adstyle - |
e20d641f RS |
2532 | pixelsize - pointsize - resx - resy - spacing - avgwidth - |
2533 | registry - encoding "\\*?\\'" | |
1e8780b1 | 2534 | ))) |
465fceed | 2535 | (setq x-font-regexp-head |
1e8780b1 DN |
2536 | (purecopy (concat "\\`[-?*]" foundry - family - weight\? - slant\? |
2537 | "\\([-*?]\\|\\'\\)"))) | |
2538 | (setq x-font-regexp-slant (purecopy (concat - slant -))) | |
2539 | (setq x-font-regexp-weight (purecopy (concat - weight -))) | |
70d0c3b0 | 2540 | nil) |
465fceed | 2541 | |
5f5c8ee5 | 2542 | |
281dc1c2 JB |
2543 | (defun x-resolve-font-name (pattern &optional face frame) |
2544 | "Return a font name matching PATTERN. | |
ac4c2e6b | 2545 | All wildcards in PATTERN are instantiated. |
10d89673 JB |
2546 | If PATTERN is nil, return the name of the frame's base font, which never |
2547 | contains wildcards. | |
e17dbede RS |
2548 | Given optional arguments FACE and FRAME, return a font which is |
2549 | also the same size as FACE on FRAME, or fail." | |
14e6867c RS |
2550 | (or (symbolp face) |
2551 | (setq face (face-name face))) | |
2552 | (and (eq frame t) | |
2553 | (setq frame nil)) | |
10d89673 | 2554 | (if pattern |
8db93e45 | 2555 | ;; Note that x-list-fonts has code to handle a face with nil as its font. |
abd89b80 | 2556 | (let ((fonts (x-list-fonts pattern face frame 1))) |
10d89673 JB |
2557 | (or fonts |
2558 | (if face | |
5e400cb3 | 2559 | (if (string-match-p "\\*" pattern) |
962a60aa RS |
2560 | (if (null (face-font face)) |
2561 | (error "No matching fonts are the same height as the frame default font") | |
2562 | (error "No matching fonts are the same height as face `%s'" face)) | |
2563 | (if (null (face-font face)) | |
2564 | (error "Height of font `%s' doesn't match the frame default font" | |
2565 | pattern) | |
2566 | (error "Height of font `%s' doesn't match face `%s'" | |
2567 | pattern face))) | |
7cf6fac1 | 2568 | (error "No fonts match `%s'" pattern))) |
10d89673 JB |
2569 | (car fonts)) |
2570 | (cdr (assq 'font (frame-parameters (selected-frame)))))) | |
281dc1c2 | 2571 | |
49238e7f CY |
2572 | (defcustom font-list-limit 100 |
2573 | "This variable is obsolete and has no effect." | |
2574 | :type 'integer | |
2575 | :group 'display) | |
2576 | (make-obsolete-variable 'font-list-limit nil "24.3") | |
2577 | ||
f0138172 JB |
2578 | (provide 'faces) |
2579 | ||
70d0c3b0 | 2580 | ;;; faces.el ends here |