Mercurial > hg > xemacs-beta
annotate lisp/faces.el @ 5441:5d2981eee77e
Added copyright notices and GPLV3 or later license to NEWS files.
author | Mats Lidell <matsl@xemacs.org> |
---|---|
date | Sun, 12 Dec 2010 00:20:02 +0100 |
parents | b9167d522a9a |
children | 0af042a0c116 |
rev | line source |
---|---|
428 | 1 ;;; faces.el --- Lisp interface to the C "face" structure |
2 | |
3 ;; Copyright (C) 1992-4, 1997 Free Software Foundation, Inc. | |
4 ;; Copyright (C) 1995 Board of Trustees, University of Illinois | |
3027 | 5 ;; Copyright (C) 1995, 1996, 2002, 2005 Ben Wing |
5080
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
6 ;; Copyright (C) 2010 Didier Verna |
428 | 7 |
8 ;; Author: Ben Wing <ben@xemacs.org> | |
9 ;; Keywords: faces, internal, dumped | |
10 | |
11 ;; This file is part of XEmacs. | |
12 | |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5080
diff
changeset
|
13 ;; XEmacs is free software: you can redistribute it and/or modify it |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5080
diff
changeset
|
14 ;; under the terms of the GNU General Public License as published by the |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5080
diff
changeset
|
15 ;; Free Software Foundation, either version 3 of the License, or (at your |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5080
diff
changeset
|
16 ;; option) any later version. |
428 | 17 |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5080
diff
changeset
|
18 ;; XEmacs is distributed in the hope that it will be useful, but WITHOUT |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5080
diff
changeset
|
19 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5080
diff
changeset
|
20 ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5080
diff
changeset
|
21 ;; for more details. |
428 | 22 |
23 ;; You should have received a copy of the GNU General Public License | |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5080
diff
changeset
|
24 ;; along with XEmacs. If not, see <http://www.gnu.org/licenses/>. |
428 | 25 |
26 ;;; Synched up with: Not synched with FSF. Almost completely divergent. | |
27 | |
28 ;;; Commentary: | |
29 | |
30 ;; This file is dumped with XEmacs. | |
31 | |
32 ;; face implementation #1 (used Lisp vectors and parallel C vectors; | |
33 ;; FSFmacs still uses this) authored by Jamie Zawinski <jwz@jwz.org> | |
34 ;; pre Lucid-Emacs 19.0. | |
35 | |
36 ;; face implementation #2 (used one face object per frame per face) | |
37 ;; authored by Jamie Zawinski for 19.9. | |
38 | |
39 ;; face implementation #3 (use one face object per face) originally | |
40 ;; authored for 19.12 by Chuck Thompson <cthomp@cs.uiuc.edu>, | |
41 ;; rewritten by Ben Wing with the advent of specifiers. | |
42 | |
43 | |
44 ;;; Some stuff in FSF's faces.el is in our x-faces.el. | |
45 | |
46 ;;; Code: | |
47 | |
771 | 48 ;; To elude the warnings for font functions. (Normally autoloaded when |
49 ;; font-create-object is called) | |
5284
d27c1ee1943b
Make the order of preloaded-file-list more sane.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5080
diff
changeset
|
50 (eval-when-compile (require 'font)) |
771 | 51 |
428 | 52 (defgroup faces nil |
53 "Support for multiple text attributes (fonts, colors, ...) | |
54 Such a collection of attributes is called a \"face\"." | |
55 :group 'emacs) | |
56 | |
57 | |
58 (defun read-face-name (prompt) | |
59 (let (face) | |
60 (while (= (length face) 0) ; nil or "" | |
61 (setq face (completing-read prompt | |
62 (mapcar (lambda (x) (list (symbol-name x))) | |
63 (face-list)) | |
64 nil t))) | |
65 (intern face))) | |
66 | |
67 (defun face-interactive (what &optional bool) | |
68 (let* ((fn (intern (concat "face-" what "-instance"))) | |
69 (face (read-face-name (format "Set %s of face: " what))) | |
70 (default (if (fboundp fn) | |
71 ;; #### we should distinguish here between | |
72 ;; explicitly setting the value to be the | |
73 ;; same as the default face's value, and | |
74 ;; not setting a value at all. | |
75 (funcall fn face))) | |
76 (value (if bool | |
77 (y-or-n-p (format "Should face %s be %s? " | |
78 (symbol-name face) bool)) | |
79 (read-string (format "Set %s of face %s to: " | |
80 what (symbol-name face)) | |
81 (cond ((font-instance-p default) | |
82 (font-instance-name default)) | |
83 ((color-instance-p default) | |
84 (color-instance-name default)) | |
85 ((image-instance-p default) | |
86 (image-instance-file-name default)) | |
5080
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
87 ((face-background-placement-instance-p default) |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
88 (symbol-name default)) |
428 | 89 (t default)))))) |
90 (list face (if (equal value "") nil value)))) | |
91 | |
92 (defconst built-in-face-specifiers | |
93 (built-in-face-specifiers) | |
94 "A list of the built-in face properties that are specifiers.") | |
95 | |
96 (defun face-property (face property &optional locale tag-set exact-p) | |
97 "Return FACE's value of the given PROPERTY. | |
98 | |
3027 | 99 NOTE: If you are looking for the \"value\" of a built-in face property |
100 (`foreground', `background', `font', `background-pixmap', etc.), you | |
101 are probably better off calling `face-property-instance'. The return | |
102 value of `face-property' for built-in properties describes the original | |
103 specification used to determine the face property, which may be nil, | |
104 a list of instantiators, or something else that is unexpected. For | |
105 example, if you ask for a face property in a particular buffer (by | |
106 specifying a buffer for LOCALE), you will get a non-nil return value | |
107 only if a buffer-local specification for that particular buffer had | |
108 previously been given. | |
109 | |
110 For a full list of built-in property names and their semantics, see | |
111 `set-face-property'. | |
428 | 112 |
3027 | 113 If LOCALE is omitted, the FACE's actual value for PROPERTY will be |
114 returned. In this case, this function appears to behave rather | |
115 differently depending on whether PROPERTY is a built-in face property of | |
116 a user-defined face property. This is because the most basic value of a | |
117 user-defined property is simply whatever was set using | |
118 `set-face-property', but for a built-in property it's always a specifier, | |
119 which is an abstract object encapsulating all the specifications for that | |
120 particular property. | |
121 | |
122 LOCALE, if supplied, will generally be a buffer, frame or | |
123 `global' (for the global value), but there are other possibilities -- see | |
124 the following paragraph. This mostly applies to built-in properties. In | |
125 this case, the return value will not be a specifier object but the | |
126 specification(s) for the given locale or locale type will be returned | |
127 (equivalent to calling `specifier-specs' on the specifier). | |
128 (Technically, the same thing happens if the basic value of a user- | |
129 defined property is a specifier, although this usage is rare.) | |
428 | 130 |
131 The return value will be a list of instantiators (e.g. strings | |
132 specifying a font or color name), or a list of specifications, each | |
133 of which is a cons of a locale and a list of instantiators. | |
134 Specifically, if LOCALE is a particular locale (a buffer, window, | |
3027 | 135 frame, device, or `global'), a list of instantiators for that locale |
428 | 136 will be returned. Otherwise, if LOCALE is a locale type (one of |
3027 | 137 the symbols `buffer', `window', `frame', or `device'), the specifications |
428 | 138 for all locales of that type will be returned. Finally, if LOCALE is |
3027 | 139 `all', the specifications for all locales of all types will be returned. |
428 | 140 |
141 The specifications in a specifier determine what the value of | |
142 PROPERTY will be in a particular \"domain\" or set of circumstances, | |
3027 | 143 which is typically a particular Emacs window -- which in turn defines |
144 a buffer (the buffer in the window), a frame (the frame that the window | |
145 is in), and a device (the device that the frame is in). The value is | |
442 | 146 derived from the instantiator associated with the most specific |
3027 | 147 locale (in the order buffer, window, frame, device, and `global') |
428 | 148 that matches the domain in question. In other words, given a domain |
442 | 149 (i.e. an Emacs window, usually), the specifier for PROPERTY will |
150 first be searched for a specification whose locale is the buffer | |
151 contained within that window; then for a specification whose locale | |
152 is the window itself; then for a specification whose locale is the | |
153 frame that the window is contained within; etc. The first | |
154 instantiator that is valid for the domain (usually this means that | |
155 the instantiator is recognized by the device [i.e. MS Windows, the X | |
3027 | 156 server or TTY device]) will be \"instantiated\", which generates |
157 a Lisp object encapsulating the original instantiator and the underlying | |
158 window-system object describing the property. The function | |
159 `face-property-instance' actually does all this." | |
428 | 160 |
161 (setq face (get-face face)) | |
162 (let ((value (get face property))) | |
163 (if (and locale | |
164 (or (memq property built-in-face-specifiers) | |
165 (specifierp value))) | |
166 (setq value (specifier-specs value locale tag-set exact-p))) | |
167 value)) | |
168 | |
169 (defun convert-face-property-into-specifier (face property) | |
170 "Convert PROPERTY on FACE into a specifier, if it's not already." | |
171 (setq face (get-face face)) | |
172 (let ((specifier (get face property))) | |
173 ;; if a user-property does not have a specifier but a | |
174 ;; locale was specified, put a specifier there. | |
175 ;; If there was already a value there, convert it to a | |
3027 | 176 ;; specifier with the value as its `global' instantiator. |
428 | 177 (unless (specifierp specifier) |
178 (let ((new-specifier (make-specifier 'generic))) | |
179 (if (or (not (null specifier)) | |
180 ;; make sure the nil returned from `get' wasn't | |
181 ;; actually the value of the property | |
182 (null (get face property t))) | |
183 (add-spec-to-specifier new-specifier specifier)) | |
184 (setq specifier new-specifier) | |
185 (put face property specifier))))) | |
186 | |
187 (defun face-property-instance (face property | |
872 | 188 &optional domain default no-fallback) |
428 | 189 "Return the instance of FACE's PROPERTY in the specified DOMAIN. |
190 | |
191 Under most circumstances, DOMAIN will be a particular window, | |
192 and the returned instance describes how the specified property | |
193 actually is displayed for that window and the particular buffer | |
194 in it. Note that this may not be the same as how the property | |
195 appears when the buffer is displayed in a different window or | |
196 frame, or how the property appears in the same window if you | |
197 switch to another buffer in that window; and in those cases, | |
198 the returned instance would be different. | |
199 | |
200 The returned instance will typically be a color-instance, | |
3027 | 201 font-instance, or image-instance object, and you can query |
428 | 202 it using the appropriate object-specific functions. For example, |
203 you could use `color-instance-rgb-components' to find out the | |
3027 | 204 RGB (red, green, and blue) components of how the `background' |
205 property of the `highlight' face is displayed in a particular | |
428 | 206 window. The results might be different from the results |
207 you would get for another window (perhaps the user | |
208 specified a different color for the frame that window is on; | |
209 or perhaps the same color was specified but the window is | |
210 on a different X server, and that X server has different RGB | |
211 values for the color from this one). | |
212 | |
213 DOMAIN defaults to the selected window if omitted. | |
214 | |
215 DOMAIN can be a frame or device, instead of a window. The value | |
216 returned for a such a domain is used in special circumstances | |
217 when a more specific domain does not apply; for example, a frame | |
218 value might be used for coloring a toolbar, which is conceptually | |
219 attached to a frame rather than a particular window. The value | |
220 is also useful in determining what the value would be for a | |
221 particular window within the frame or device, if it is not | |
222 overridden by a more specific specification. | |
223 | |
224 If PROPERTY does not name a built-in property, its value will | |
225 simply be returned unless it is a specifier object, in which case | |
226 it will be instanced using `specifier-instance'. | |
227 | |
228 Optional arguments DEFAULT and NO-FALLBACK are the same as in | |
229 `specifier-instance'." | |
230 | |
231 (setq face (get-face face)) | |
232 (let ((value (get face property))) | |
233 (if (specifierp value) | |
234 (setq value (specifier-instance value domain default no-fallback))) | |
235 value)) | |
236 | |
237 (defun face-property-matching-instance (face property matchspec | |
872 | 238 &optional domain default |
239 no-fallback) | |
428 | 240 "Return the instance of FACE's PROPERTY matching MATCHSPEC in DOMAIN. |
241 Currently the only useful value for MATCHSPEC is a charset, when used | |
242 in conjunction with the face's font; this allows you to retrieve a | |
243 font that can be used to display a particular charset, rather than just | |
244 any font. | |
245 | |
246 Other than MATCHSPEC, this function is identical to `face-property-instance'. | |
247 See also `specifier-matching-instance' for a fuller description of the | |
248 matching process." | |
249 | |
250 (setq face (get-face face)) | |
251 (let ((value (get face property))) | |
3659 | 252 (when (specifierp value) |
253 (setq value (specifier-matching-instance value matchspec domain | |
254 default no-fallback))) | |
428 | 255 value)) |
256 | |
257 (defun set-face-property (face property value &optional locale tag-set | |
872 | 258 how-to-add) |
428 | 259 "Change a property of FACE. |
260 | |
261 NOTE: If you want to remove a property from a face, use `remove-face-property' | |
262 rather than attempting to set a value of nil for the property. | |
263 | |
264 For built-in properties, the actual value of the property is a | |
265 specifier and you cannot change this; but you can change the | |
266 specifications within the specifier, and that is what this function | |
267 will do. For user-defined properties, you can use this function | |
268 to either change the actual value of the property or, if this value | |
269 is a specifier, change the specifications within it. | |
270 | |
271 If PROPERTY is a built-in property, the specifications to be added to | |
272 this property can be supplied in many different ways: | |
273 | |
274 -- If VALUE is a simple instantiator (e.g. a string naming a font or | |
275 color) or a list of instantiators, then the instantiator(s) will | |
276 be added as a specification of the property for the given LOCALE | |
3027 | 277 (which defaults to `global' if omitted). |
428 | 278 -- If VALUE is a list of specifications (each of which is a cons of |
279 a locale and a list of instantiators), then LOCALE must be nil | |
280 (it does not make sense to explicitly specify a locale in this | |
281 case), and specifications will be added as given. | |
282 -- If VALUE is a specifier (as would be returned by `face-property' | |
283 if no LOCALE argument is given), then some or all of the | |
284 specifications in the specifier will be added to the property. | |
285 In this case, the function is really equivalent to | |
286 `copy-specifier' and LOCALE has the same semantics (if it is | |
287 a particular locale, the specification for the locale will be | |
288 copied; if a locale type, specifications for all locales of | |
3027 | 289 that type will be copied; if nil or `all', then all |
428 | 290 specifications will be copied). |
291 | |
3027 | 292 HOW-TO-ADD should be either nil or one of the symbols `prepend', |
293 `append', `remove-tag-set-prepend', `remove-tag-set-append', `remove-locale', | |
294 `remove-locale-type', or `remove-all'. See `copy-specifier' and | |
428 | 295 `add-spec-to-specifier' for a description of what each of |
296 these means. Most of the time, you do not need to worry about | |
297 this argument; the default behavior usually is fine. | |
298 | |
299 In general, it is OK to pass an instance object (e.g. as returned | |
300 by `face-property-instance') as an instantiator in place of | |
301 an actual instantiator. In such a case, the instantiator used | |
302 to create that instance object will be used (for example, if | |
3027 | 303 you set a font-instance object as the value of the `font' |
428 | 304 property, then the font name used to create that object will |
305 be used instead). If some cases, however, doing this | |
306 conversion does not make sense, and this will be noted in | |
307 the documentation for particular types of instance objects. | |
308 | |
309 If PROPERTY is not a built-in property, then this function will | |
310 simply set its value if LOCALE is nil. However, if LOCALE is | |
311 given, then this function will attempt to add VALUE as the | |
312 instantiator for the given LOCALE, using `add-spec-to-specifier'. | |
313 If the value of the property is not a specifier, it will | |
3027 | 314 automatically be converted into a `generic' specifier. |
428 | 315 |
316 | |
317 The following symbols have predefined meanings: | |
318 | |
319 foreground The foreground color of the face. | |
442 | 320 For valid instantiators, see `make-color-specifier'. |
428 | 321 |
322 background The background color of the face. | |
442 | 323 For valid instantiators, see `make-color-specifier'. |
428 | 324 |
325 font The font used to display text covered by this face. | |
442 | 326 For valid instantiators, see `make-font-specifier'. |
428 | 327 |
328 display-table The display table of the face. | |
329 This should be a vector of 256 elements. | |
330 | |
331 background-pixmap The pixmap displayed in the background of the face. | |
442 | 332 Only used by faces on X and MS Windows devices. |
333 For valid instantiators, see `make-image-specifier'. | |
428 | 334 |
5080
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
335 background-placement The placement of the face's background pixmap. |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
336 Only used by faces on X devices. |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
337 For valid instantiators, |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
338 see `make-face-background-placement-specifier'. |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
339 |
428 | 340 underline Underline all text covered by this face. |
442 | 341 For valid instantiators, see `make-face-boolean-specifier'. |
428 | 342 |
343 strikethru Draw a line through all text covered by this face. | |
442 | 344 For valid instantiators, see `make-face-boolean-specifier'. |
428 | 345 |
346 highlight Highlight all text covered by this face. | |
347 Only used by faces on TTY devices. | |
442 | 348 For valid instantiators, see `make-face-boolean-specifier'. |
428 | 349 |
350 dim Dim all text covered by this face. | |
442 | 351 For valid instantiators, see `make-face-boolean-specifier'. |
428 | 352 |
353 blinking Blink all text covered by this face. | |
354 Only used by faces on TTY devices. | |
442 | 355 For valid instantiators, see `make-face-boolean-specifier'. |
428 | 356 |
357 reverse Reverse the foreground and background colors. | |
358 Only used by faces on TTY devices. | |
442 | 359 For valid instantiators, see `make-face-boolean-specifier'. |
428 | 360 |
3027 | 361 inherit Face name or face object from which to inherit attributes, |
362 or a list of such elements. Attributes from inherited | |
363 faces are merged into the face like an underlying face | |
364 would be, with higher priority than underlying faces. | |
365 | |
428 | 366 doc-string Description of what the face's normal use is. |
367 NOTE: This is not a specifier, unlike all | |
368 the other built-in properties, and cannot | |
369 contain locale-specific values." | |
370 | |
371 (setq face (get-face face)) | |
372 (if (memq property built-in-face-specifiers) | |
373 (set-specifier (get face property) value locale tag-set how-to-add) | |
374 | |
375 ;; This section adds user defined properties. | |
376 (if (not locale) | |
377 (put face property value) | |
378 (convert-face-property-into-specifier face property) | |
379 (add-spec-to-specifier (get face property) value locale tag-set | |
380 how-to-add))) | |
381 value) | |
382 | |
383 (defun remove-face-property (face property &optional locale tag-set exact-p) | |
384 "Remove a property from FACE. | |
385 For built-in properties, this is analogous to `remove-specifier'. | |
386 See `remove-specifier' for the meaning of the LOCALE, TAG-SET, and EXACT-P | |
387 arguments." | |
388 (or locale (setq locale 'all)) | |
389 (if (memq property built-in-face-specifiers) | |
390 (remove-specifier (face-property face property) locale tag-set exact-p) | |
391 (if (eq locale 'all) | |
392 (remprop (get-face face) property) | |
393 (convert-face-property-into-specifier face property) | |
394 (remove-specifier (face-property face property) locale tag-set | |
395 exact-p)))) | |
396 | |
397 (defun reset-face (face &optional locale tag-set exact-p) | |
398 "Clear all existing built-in specifications from FACE. | |
3027 | 399 This makes FACE inherit all its display properties from `default'. |
428 | 400 WARNING: Be absolutely sure you want to do this!!! It is a dangerous |
401 operation and is not undoable. | |
402 | |
403 The arguments LOCALE, TAG-SET and EXACT-P are the same as for | |
404 `remove-specifier'." | |
3918 | 405 ;; Don't reset the default face. |
406 (unless (eq 'default face) | |
407 (dolist (x built-in-face-specifiers nil) | |
408 (remove-specifier (face-property face x) locale tag-set exact-p)))) | |
428 | 409 |
410 (defun set-face-parent (face parent &optional locale tag-set how-to-add) | |
411 "Set the parent of FACE to PARENT, for all properties. | |
412 This makes all properties of FACE inherit from PARENT." | |
413 (setq parent (get-face parent)) | |
4783
e29fcfd8df5f
Eliminate most core code byte-compile warnings.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4764
diff
changeset
|
414 (mapc (lambda (x) |
e29fcfd8df5f
Eliminate most core code byte-compile warnings.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4764
diff
changeset
|
415 (set-face-property face x (vector parent) locale tag-set |
e29fcfd8df5f
Eliminate most core code byte-compile warnings.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4764
diff
changeset
|
416 how-to-add)) |
e29fcfd8df5f
Eliminate most core code byte-compile warnings.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4764
diff
changeset
|
417 (set-difference built-in-face-specifiers |
e29fcfd8df5f
Eliminate most core code byte-compile warnings.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4764
diff
changeset
|
418 '(display-table background-pixmap inherit))) |
428 | 419 (set-face-background-pixmap face (vector 'inherit ':face parent) |
420 locale tag-set how-to-add) | |
421 nil) | |
422 | |
423 (defun face-doc-string (face) | |
424 "Return the documentation string for FACE." | |
425 (face-property face 'doc-string)) | |
426 | |
427 (defun set-face-doc-string (face doc-string) | |
428 "Change the documentation string of FACE to DOC-STRING." | |
429 (interactive (face-interactive "doc-string")) | |
430 (set-face-property face 'doc-string doc-string)) | |
431 | |
432 (defun face-font-name (face &optional domain charset) | |
433 "Return the font name of FACE in DOMAIN, or nil if it is unspecified. | |
3027 | 434 DOMAIN is as in `face-font-instance'. |
435 | |
436 Font names are strings, as described in `make-font-specifier'." | |
428 | 437 (let ((f (face-font-instance face domain charset))) |
438 (and f (font-instance-name f)))) | |
439 | |
440 (defun face-font (face &optional locale tag-set exact-p) | |
3027 | 441 "Return the font spec of FACE in LOCALE, or nil if it is unspecified. |
442 | |
443 NOTE: This returns a locale-specific specification, not any sort of value | |
444 corresponding to the actual font being used. If you want to know the | |
445 actual font used in a particular domain, use `face-font-instance', or | |
446 `face-font-name' for its name (i.e. the instantiator used to create it). | |
428 | 447 |
448 FACE may be either a face object or a symbol representing a face. | |
449 | |
450 LOCALE may be a locale (the instantiators for that particular locale | |
451 will be returned), a locale type (the specifications for all locales | |
3027 | 452 of that type will be returned), `all' (all specifications will be |
428 | 453 returned), or nil (the actual specifier object will be returned). |
454 | |
455 See `face-property' for more information." | |
456 (face-property face 'font locale tag-set exact-p)) | |
457 | |
458 (defun face-font-instance (face &optional domain charset) | |
459 "Return the instance of FACE's font in DOMAIN. | |
460 | |
3027 | 461 Return value will be a font instance object; query its properties using |
462 `font-instance-name', `font-instance-height', `font-instance-width', etc. | |
463 | |
428 | 464 FACE may be either a face object or a symbol representing a face. |
465 | |
466 Normally DOMAIN will be a window or nil (meaning the selected window), | |
467 and an instance object describing how the font appears in that | |
468 particular window and buffer will be returned. | |
469 | |
3659 | 470 CHARSET is a Mule charset (meaning return the font used for that charset) or |
471 nil (meaning return the font used for ASCII.) | |
472 | |
428 | 473 See `face-property-instance' for more information." |
3659 | 474 (if (null charset) |
475 (face-property-instance face 'font domain) | |
476 (let (matchspec) | |
477 ;; get-charset signals an error if its argument doesn't have an | |
478 ;; associated charset. | |
4222 | 479 (setq charset (if-fboundp #'get-charset |
480 (get-charset charset) | |
481 (error 'unimplemented "Charset support not available")) | |
3659 | 482 matchspec (cons charset nil)) |
483 (or (null (setcdr matchspec 'initial)) | |
484 (face-property-matching-instance | |
485 face 'font matchspec domain) | |
486 (null (setcdr matchspec 'final)) | |
487 (face-property-matching-instance | |
488 face 'font matchspec domain))))) | |
428 | 489 |
490 (defun set-face-font (face font &optional locale tag-set how-to-add) | |
491 "Change the font of FACE to FONT in LOCALE. | |
492 | |
493 FACE may be either a face object or a symbol representing a face. | |
494 | |
3659 | 495 FONT should be an instantiator (see `make-font-specifier'; a common |
496 instantiator is a platform-dependent string naming the font), a list | |
497 of instantiators, an alist of specifications (each mapping a locale | |
498 to an instantiator list), or a font specifier object. | |
428 | 499 |
3659 | 500 If FONT is an alist, LOCALE must be omitted. If FONT is a specifier |
501 object, LOCALE can be a locale, a locale type, `all', or nil; see | |
502 `copy-specifier' for its semantics. Common LOCALEs are buffer | |
503 objects, window objects, device objects and `global'. Otherwise | |
504 LOCALE specifies the locale under which the specified | |
505 instantiator(s) will be added, and defaults to `global'. | |
428 | 506 |
507 See `set-face-property' for more information." | |
508 (interactive (face-interactive "font")) | |
509 (set-face-property face 'font font locale tag-set how-to-add)) | |
510 | |
511 (defun face-foreground (face &optional locale tag-set exact-p) | |
3027 | 512 "Return the foreground spec of FACE in LOCALE, or nil if it is unspecified. |
513 | |
514 NOTE: This returns a locale-specific specification, not any sort of value | |
515 corresponding to the actual foreground being used. If you want to know the | |
516 actual foreground color used in a particular domain, use | |
517 `face-foreground-instance', or `face-foreground-name' for its name | |
518 \(i.e. the instantiator used to create it). | |
428 | 519 |
520 FACE may be either a face object or a symbol representing a face. | |
521 | |
522 LOCALE may be a locale (the instantiators for that particular locale | |
523 will be returned), a locale type (the specifications for all locales | |
3027 | 524 of that type will be returned), `all' (all specifications will be |
428 | 525 returned), or nil (the actual specifier object will be returned). |
526 | |
527 See `face-property' for more information." | |
528 (face-property face 'foreground locale tag-set exact-p)) | |
529 | |
530 (defun face-foreground-instance (face &optional domain default no-fallback) | |
531 "Return the instance of FACE's foreground in DOMAIN. | |
532 | |
3027 | 533 Return value will be a color instance object; query its properties using |
534 `color-instance-name' or `color-instance-rgb-properties'. | |
535 | |
428 | 536 FACE may be either a face object or a symbol representing a face. |
537 | |
538 Normally DOMAIN will be a window or nil (meaning the selected window), | |
539 and an instance object describing how the foreground appears in that | |
540 particular window and buffer will be returned. | |
541 | |
542 See `face-property-instance' for more information." | |
543 (face-property-instance face 'foreground domain default no-fallback)) | |
544 | |
545 (defun face-foreground-name (face &optional domain default no-fallback) | |
546 "Return the name of FACE's foreground color in DOMAIN. | |
547 | |
548 FACE may be either a face object or a symbol representing a face. | |
549 | |
550 Normally DOMAIN will be a window or nil (meaning the selected window), | |
551 and an instance object describing how the background appears in that | |
552 particular window and buffer will be returned. | |
553 | |
554 See `face-property-instance' for more information." | |
555 (color-instance-name (face-foreground-instance | |
556 face domain default no-fallback))) | |
557 | |
558 (defun set-face-foreground (face color &optional locale tag-set how-to-add) | |
559 "Change the foreground color of FACE to COLOR in LOCALE. | |
560 | |
561 FACE may be either a face object or a symbol representing a face. | |
562 | |
442 | 563 COLOR should be an instantiator (see `make-color-specifier'), a list of |
428 | 564 instantiators, an alist of specifications (each mapping a locale to |
565 an instantiator list), or a color specifier object. | |
566 | |
567 If COLOR is an alist, LOCALE must be omitted. If COLOR is a | |
3027 | 568 specifier object, LOCALE can be a locale, a locale type, `all', |
428 | 569 or nil; see `copy-specifier' for its semantics. Otherwise LOCALE |
570 specifies the locale under which the specified instantiator(s) | |
3027 | 571 will be added, and defaults to `global'. |
428 | 572 |
573 See `set-face-property' for more information." | |
574 (interactive (face-interactive "foreground")) | |
575 (set-face-property face 'foreground color locale tag-set how-to-add)) | |
576 | |
577 (defun face-background (face &optional locale tag-set exact-p) | |
578 "Return the background color of FACE in LOCALE, or nil if it is unspecified. | |
579 | |
3027 | 580 NOTE: This returns a locale-specific specification, not any sort of value |
581 corresponding to the actual background being used. If you want to know the | |
582 actual background color used in a particular domain, use | |
583 `face-background-instance', or `face-background-name' for its name | |
584 \(i.e. the instantiator used to create it). | |
585 | |
428 | 586 FACE may be either a face object or a symbol representing a face. |
587 | |
588 LOCALE may be a locale (the instantiators for that particular locale | |
589 will be returned), a locale type (the specifications for all locales | |
3027 | 590 of that type will be returned), `all' (all specifications will be |
428 | 591 returned), or nil (the actual specifier object will be returned). |
592 | |
593 See `face-property' for more information." | |
594 (face-property face 'background locale tag-set exact-p)) | |
595 | |
596 (defun face-background-instance (face &optional domain default no-fallback) | |
597 "Return the instance of FACE's background in DOMAIN. | |
598 | |
3027 | 599 Return value will be a color instance object; query its properties using |
600 `color-instance-name' or `color-instance-rgb-properties'. | |
601 | |
428 | 602 FACE may be either a face object or a symbol representing a face. |
603 | |
604 Normally DOMAIN will be a window or nil (meaning the selected window), | |
605 and an instance object describing how the background appears in that | |
606 particular window and buffer will be returned. | |
607 | |
608 See `face-property-instance' for more information." | |
609 (face-property-instance face 'background domain default no-fallback)) | |
610 | |
611 (defun face-background-name (face &optional domain default no-fallback) | |
612 "Return the name of FACE's background color in DOMAIN. | |
613 | |
614 FACE may be either a face object or a symbol representing a face. | |
615 | |
616 Normally DOMAIN will be a window or nil (meaning the selected window), | |
617 and an instance object describing how the background appears in that | |
618 particular window and buffer will be returned. | |
619 | |
620 See `face-property-instance' for more information." | |
621 (color-instance-name (face-background-instance | |
622 face domain default no-fallback))) | |
623 | |
624 (defun set-face-background (face color &optional locale tag-set how-to-add) | |
625 "Change the background color of FACE to COLOR in LOCALE. | |
626 | |
627 FACE may be either a face object or a symbol representing a face. | |
628 | |
442 | 629 COLOR should be an instantiator (see `make-color-specifier'), a list of |
428 | 630 instantiators, an alist of specifications (each mapping a locale to |
631 an instantiator list), or a color specifier object. | |
632 | |
633 If COLOR is an alist, LOCALE must be omitted. If COLOR is a | |
3027 | 634 specifier object, LOCALE can be a locale, a locale type, `all', |
428 | 635 or nil; see `copy-specifier' for its semantics. Otherwise LOCALE |
636 specifies the locale under which the specified instantiator(s) | |
3027 | 637 will be added, and defaults to `global'. |
428 | 638 |
639 See `set-face-property' for more information." | |
640 (interactive (face-interactive "background")) | |
641 (set-face-property face 'background color locale tag-set how-to-add)) | |
642 | |
643 (defun face-background-pixmap (face &optional locale tag-set exact-p) | |
3027 | 644 "Return the background pixmap spec of FACE in LOCALE, or nil if unspecified. |
428 | 645 This property is only used on window system devices. |
646 | |
3027 | 647 NOTE: This returns a locale-specific specification, not any sort of value |
648 corresponding to the actual background pixmap being used. If you want to | |
649 know the actual background pixmap used in a particular domain, use | |
650 `face-background-pixmap-instance'. | |
651 | |
428 | 652 FACE may be either a face object or a symbol representing a face. |
653 | |
654 LOCALE may be a locale (the instantiators for that particular locale | |
655 will be returned), a locale type (the specifications for all locales | |
3027 | 656 of that type will be returned), `all' (all specifications will be |
428 | 657 returned), or nil (the actual specifier object will be returned). |
658 | |
659 See `face-property' for more information." | |
660 (face-property face 'background-pixmap locale tag-set exact-p)) | |
661 | |
662 (defun face-background-pixmap-instance (face &optional domain default | |
663 no-fallback) | |
664 "Return the instance of FACE's background pixmap in DOMAIN. | |
665 | |
3027 | 666 Return value will be an image instance object; query its properties using |
667 `image-instance-instantiator' (the original instantiator used to create | |
668 the image, which may be a complex beast -- see `make-image-specifier'), | |
669 `image-instance-file-name' (the file, if any, from which the image was | |
670 created), `image-instance-height', etc. | |
671 | |
428 | 672 FACE may be either a face object or a symbol representing a face. |
673 | |
674 Normally DOMAIN will be a window or nil (meaning the selected window), | |
675 and an instance object describing how the background appears in that | |
676 particular window and buffer will be returned. | |
677 | |
678 See `face-property-instance' for more information." | |
679 (face-property-instance face 'background-pixmap domain default no-fallback)) | |
680 | |
681 (defun set-face-background-pixmap (face pixmap &optional locale tag-set | |
682 how-to-add) | |
683 "Change the background pixmap of FACE to PIXMAP in LOCALE. | |
684 This property is only used on window system devices. | |
685 | |
686 FACE may be either a face object or a symbol representing a face. | |
687 | |
442 | 688 PIXMAP should be an instantiator (see `make-image-specifier'), a list |
428 | 689 of instantiators, an alist of specifications (each mapping a locale |
690 to an instantiator list), or an image specifier object. | |
691 | |
692 If PIXMAP is an alist, LOCALE must be omitted. If PIXMAP is a | |
3027 | 693 specifier object, LOCALE can be a locale, a locale type, `all', |
428 | 694 or nil; see `copy-specifier' for its semantics. Otherwise LOCALE |
695 specifies the locale under which the specified instantiator(s) | |
3027 | 696 will be added, and defaults to `global'. |
428 | 697 |
698 See `set-face-property' for more information." | |
699 (interactive (face-interactive "background-pixmap")) | |
700 (set-face-property face 'background-pixmap pixmap locale tag-set how-to-add)) | |
701 | |
1137 | 702 (defvar background-pixmap-file-history nil |
703 ;; History for `set-face-background-pixmap-file' | |
704 ) | |
705 | |
706 (defun set-face-background-pixmap-file (face file) | |
707 "Read (and set) the background pixmap of FACE from FILE. | |
708 This function is a simplified version of `set-face-background-pixmap', | |
709 designed for interactive use." | |
710 (interactive | |
711 (let* ((face (read-face-name "Set background pixmap of face: ")) | |
1139 | 712 (default (and (face-background-pixmap-instance face) |
4670
5a54ce6dc945
Remove some extra parentheses, #'set-face-background-pixmap-file.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4222
diff
changeset
|
713 (image-instance-file-name |
5a54ce6dc945
Remove some extra parentheses, #'set-face-background-pixmap-file.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4222
diff
changeset
|
714 (face-background-pixmap-instance face)))) |
1137 | 715 (file (read-file-name |
716 (format "Set background pixmap of face %s to: " | |
717 (symbol-name face)) | |
1139 | 718 nil default t nil |
1137 | 719 'background-pixmap-file-history))) |
720 (list face (if (equal file "") nil file)))) | |
721 (set-face-property face 'background-pixmap file)) | |
722 | |
5080
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
723 (defun face-background-placement (face &optional domain default no-fallback) |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
724 "Return FACE's background placement in DOMAIN. |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
725 See `face-property-instance' for the semantics of the DOMAIN argument." |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
726 (face-property face 'background-placement domain default no-fallback)) |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
727 |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
728 (defun set-face-background-placement (face placement &optional locale tag-set |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
729 how-to-add) |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
730 "Change the background-placement property of FACE to PLACEMENT. |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
731 PLACEMENT is normally a background-placement instantiator; see |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
732 `make-face-background-placement-specifier'. |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
733 See `set-face-property' for the semantics of the LOCALE, TAG-SET, and |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
734 HOW-TO-ADD arguments." |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
735 (interactive (face-interactive "background placement")) |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
736 ;; When called non-interactively (for example via custom), PLACEMENT is |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
737 ;; expected to be a symbol. -- dvl |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
738 (unless (symbolp placement) |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
739 (setq placement (intern placement))) |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
740 (set-face-property face 'background-placement placement locale tag-set |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
741 how-to-add)) |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
742 |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
743 (defun face-background-placement-instance (face &optional domain default |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
744 no-fallback) |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
745 "Return FACE's background-placement instance in DOMAIN. |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
746 Return value will be a background-placement instance object. |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
747 |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
748 FACE may be either a face object or a symbol representing a face. |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
749 |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
750 Normally DOMAIN will be a window or nil (meaning the selected window), |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
751 and an instance object describing the background placement in that particular |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
752 window and buffer will be returned. |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
753 |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
754 See `face-property-instance' for more information." |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
755 (face-property-instance face 'background-placement domain default |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
756 no-fallback)) |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
757 |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
758 (defun face-background-placement-instance-p (object) |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
759 "Return t if OBJECT is a face-background-placement instance." |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
760 (or (eq object 'absolute) (eq object 'relative))) |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
761 |
428 | 762 (defun face-display-table (face &optional locale tag-set exact-p) |
3027 | 763 "Return the display table spec of FACE in LOCALE, or nil if unspecified.. |
428 | 764 |
3027 | 765 NOTE: This returns a locale-specific specification, not any sort of value |
766 corresponding to the actual display table being used. If you want to | |
767 know the actual display table used in a particular domain, use | |
768 `face-display-table-instance'. | |
769 | |
770 FACE may be either a face object or a symbol representing a face. | |
428 | 771 |
772 LOCALE may be a locale (the instantiators for that particular locale | |
773 will be returned), a locale type (the specifications for all locales | |
3027 | 774 of that type will be returned), `all' (all specifications will be |
428 | 775 returned), or nil (the actual specifier object will be returned). |
776 | |
777 See `face-property' for more information." | |
778 (face-property face 'display-table locale tag-set exact-p)) | |
779 | |
780 (defun face-display-table-instance (face &optional domain default no-fallback) | |
781 "Return the instance of FACE's display table in DOMAIN. | |
3027 | 782 |
783 Return value will be a vector, char table or range table; see | |
784 `current-display-table'. | |
785 | |
786 FACE may be either a face object or a symbol representing a face. | |
428 | 787 |
3027 | 788 Normally DOMAIN will be a window or nil (meaning the selected window), |
789 and the actual display table used in that particular window and buffer | |
790 will be returned. | |
791 | |
792 See `face-property-instance' for more information." | |
428 | 793 (face-property-instance face 'display-table domain default no-fallback)) |
794 | |
795 (defun set-face-display-table (face display-table &optional locale tag-set | |
872 | 796 how-to-add) |
428 | 797 "Change the display table of FACE to DISPLAY-TABLE in LOCALE. |
798 DISPLAY-TABLE should be a vector as returned by `make-display-table'. | |
799 | |
800 See `set-face-property' for the semantics of the LOCALE, TAG-SET, and | |
801 HOW-TO-ADD arguments." | |
802 (interactive (face-interactive "display-table")) | |
803 (set-face-property face 'display-table display-table locale tag-set | |
804 how-to-add)) | |
805 | |
806 ;; The following accessors and mutators are, IMHO, good | |
807 ;; implementation. Cf. with `make-face-bold'. | |
808 | |
809 (defun face-underline-p (face &optional domain default no-fallback) | |
810 "Return t if FACE is underlined in DOMAIN. | |
811 See `face-property-instance' for the semantics of the DOMAIN argument." | |
812 (face-property-instance face 'underline domain default no-fallback)) | |
813 | |
814 (defun set-face-underline-p (face underline-p &optional locale tag-set | |
872 | 815 how-to-add) |
428 | 816 "Change the underline property of FACE to UNDERLINE-P. |
817 UNDERLINE-P is normally a face-boolean instantiator; see | |
442 | 818 `make-face-boolean-specifier'. |
428 | 819 See `set-face-property' for the semantics of the LOCALE, TAG-SET, and |
820 HOW-TO-ADD arguments." | |
821 (interactive (face-interactive "underline-p" "underlined")) | |
822 (set-face-property face 'underline underline-p locale tag-set how-to-add)) | |
823 | |
824 (defun face-strikethru-p (face &optional domain default no-fallback) | |
825 "Return t if FACE is strikethru-d (i.e. struck through) in DOMAIN. | |
826 See `face-property-instance' for the semantics of the DOMAIN argument." | |
827 (face-property-instance face 'strikethru domain default no-fallback)) | |
828 | |
829 (defun set-face-strikethru-p (face strikethru-p &optional locale tag-set | |
872 | 830 how-to-add) |
428 | 831 "Change whether FACE is strikethru-d (i.e. struck through) in LOCALE. |
832 STRIKETHRU-P is normally a face-boolean instantiator; see | |
442 | 833 `make-face-boolean-specifier'. |
428 | 834 See `set-face-property' for the semantics of the LOCALE, TAG-SET, and |
835 HOW-TO-ADD arguments." | |
836 (interactive (face-interactive "strikethru-p" "strikethru-d")) | |
837 (set-face-property face 'strikethru strikethru-p locale tag-set how-to-add)) | |
838 | |
839 (defun face-highlight-p (face &optional domain default no-fallback) | |
840 "Return t if FACE is highlighted in DOMAIN (TTY domains only). | |
841 See `face-property-instance' for the semantics of the DOMAIN argument." | |
842 (face-property-instance face 'highlight domain default no-fallback)) | |
843 | |
844 (defun set-face-highlight-p (face highlight-p &optional locale tag-set | |
872 | 845 how-to-add) |
428 | 846 "Change whether FACE is highlighted in LOCALE (TTY locales only). |
847 HIGHLIGHT-P is normally a face-boolean instantiator; see | |
442 | 848 `make-face-boolean-specifier'. |
428 | 849 See `set-face-property' for the semantics of the LOCALE, TAG-SET, and |
850 HOW-TO-ADD arguments." | |
851 (interactive (face-interactive "highlight-p" "highlighted")) | |
852 (set-face-property face 'highlight highlight-p locale tag-set how-to-add)) | |
853 | |
854 (defun face-dim-p (face &optional domain default no-fallback) | |
855 "Return t if FACE is dimmed in DOMAIN. | |
856 See `face-property-instance' for the semantics of the DOMAIN argument." | |
857 (face-property-instance face 'dim domain default no-fallback)) | |
858 | |
859 (defun set-face-dim-p (face dim-p &optional locale tag-set how-to-add) | |
860 "Change whether FACE is dimmed in LOCALE. | |
861 DIM-P is normally a face-boolean instantiator; see | |
442 | 862 `make-face-boolean-specifier'. |
428 | 863 See `set-face-property' for the semantics of the LOCALE, TAG-SET, and |
864 HOW-TO-ADD arguments." | |
865 (interactive (face-interactive "dim-p" "dimmed")) | |
866 (set-face-property face 'dim dim-p locale tag-set how-to-add)) | |
867 | |
868 (defun face-blinking-p (face &optional domain default no-fallback) | |
869 "Return t if FACE is blinking in DOMAIN (TTY domains only). | |
870 See `face-property-instance' for the semantics of the DOMAIN argument." | |
871 (face-property-instance face 'blinking domain default no-fallback)) | |
872 | |
873 (defun set-face-blinking-p (face blinking-p &optional locale tag-set | |
872 | 874 how-to-add) |
428 | 875 "Change whether FACE is blinking in LOCALE (TTY locales only). |
876 BLINKING-P is normally a face-boolean instantiator; see | |
442 | 877 `make-face-boolean-specifier'. |
428 | 878 See `set-face-property' for the semantics of the LOCALE, TAG-SET, and |
879 HOW-TO-ADD arguments." | |
880 (interactive (face-interactive "blinking-p" "blinking")) | |
881 (set-face-property face 'blinking blinking-p locale tag-set how-to-add)) | |
882 | |
883 (defun face-reverse-p (face &optional domain default no-fallback) | |
884 "Return t if FACE is reversed in DOMAIN (TTY domains only). | |
885 See `face-property-instance' for the semantics of the DOMAIN argument." | |
886 (face-property-instance face 'reverse domain default no-fallback)) | |
887 | |
888 (defun set-face-reverse-p (face reverse-p &optional locale tag-set how-to-add) | |
889 "Change whether FACE is reversed in LOCALE (TTY locales only). | |
890 REVERSE-P is normally a face-boolean instantiator; see | |
442 | 891 `make-face-boolean-specifier'. |
428 | 892 See `set-face-property' for the semantics of the LOCALE, TAG-SET, and |
893 HOW-TO-ADD arguments." | |
894 (interactive (face-interactive "reverse-p" "reversed")) | |
895 (set-face-property face 'reverse reverse-p locale tag-set how-to-add)) | |
896 | |
897 | |
898 (defun face-property-equal (face1 face2 prop domain) | |
899 (equal (face-property-instance face1 prop domain) | |
900 (face-property-instance face2 prop domain))) | |
901 | |
902 (defun face-equal-loop (props face1 face2 domain) | |
903 (while (and props | |
904 (face-property-equal face1 face2 (car props) domain)) | |
905 (setq props (cdr props))) | |
906 (null props)) | |
907 | |
908 (defun face-equal (face1 face2 &optional domain) | |
909 "Return t if FACE1 and FACE2 will display in the same way in DOMAIN. | |
910 See `face-property-instance' for the semantics of the DOMAIN argument." | |
911 (if (null domain) (setq domain (selected-window))) | |
912 (if (not (valid-specifier-domain-p domain)) | |
913 (error "Invalid specifier domain")) | |
914 (let ((device (dfw-device domain)) | |
915 (common-props '(foreground background font display-table underline | |
3027 | 916 dim inherit)) |
5080
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
917 (win-props '(background-pixmap background-placement strikethru)) |
428 | 918 (tty-props '(highlight blinking reverse))) |
919 | |
920 ;; First check the properties which are used in common between the | |
921 ;; x and tty devices. Then, check those properties specific to | |
922 ;; the particular device type. | |
923 (and (face-equal-loop common-props face1 face2 domain) | |
924 (cond ((eq 'tty (device-type device)) | |
925 (face-equal-loop tty-props face1 face2 domain)) | |
872 | 926 ((console-on-window-system-p (device-console device)) |
428 | 927 (face-equal-loop win-props face1 face2 domain)) |
928 (t t))))) | |
929 | |
930 (defun face-differs-from-default-p (face &optional domain) | |
931 "Return t if FACE will display differently from the default face in DOMAIN. | |
932 See `face-property-instance' for the semantics of the DOMAIN argument." | |
933 (not (face-equal face 'default domain))) | |
934 | |
935 (defun try-font-name (name &optional device) | |
872 | 936 "Return NAME if it's a valid font name on DEVICE, else nil." |
428 | 937 ;; yes, name really should be here twice. |
938 (and name (make-font-instance name device t) name)) | |
939 | |
940 | |
872 | 941 |
942 (defcustom face-frob-from-locale-first nil | |
943 "*If non nil, use kludgy way of frobbing fonts suitable for non-mule | |
944 multi-charset environments." | |
945 :group 'faces | |
946 :type 'boolean) | |
947 | |
428 | 948 ;; This function is a terrible, disgusting hack!!!! Need to |
949 ;; separate out the font elements as separate face properties! | |
950 | |
951 ;; WE DEMAND LEXICAL SCOPING!!! | |
952 ;; WE DEMAND LEXICAL SCOPING!!! | |
953 ;; WE DEMAND LEXICAL SCOPING!!! | |
954 ;; WE DEMAND LEXICAL SCOPING!!! | |
955 ;; WE DEMAND LEXICAL SCOPING!!! | |
956 ;; WE DEMAND LEXICAL SCOPING!!! | |
957 ;; WE DEMAND LEXICAL SCOPING!!! | |
958 ;; WE DEMAND LEXICAL SCOPING!!! | |
959 ;; WE DEMAND LEXICAL SCOPING!!! | |
960 ;; WE DEMAND LEXICAL SCOPING!!! | |
961 ;; WE DEMAND LEXICAL SCOPING!!! | |
962 ;; WE DEMAND LEXICAL SCOPING!!! | |
963 ;; WE DEMAND LEXICAL SCOPING!!! | |
964 ;; WE DEMAND LEXICAL SCOPING!!! | |
965 ;; WE DEMAND LEXICAL SCOPING!!! | |
872 | 966 |
967 ;; When we are initializing a device, it won't be selected; we communicate | |
968 ;; the device to consider as selected using this variable. | |
969 (defvar Face-frob-property-device-considered-current nil) | |
428 | 970 |
872 | 971 (defun Face-frob-property (face locale tag-set exact-p |
972 unfrobbed-face frobbed-face | |
973 win-prop tty-props | |
974 frob-mapping standard-face-mapping) | |
975 ;; implement the semantics of `make-face-bold' et al. FACE, LOCALE, TAG-SET | |
976 ;; and EXACT-P are as in that call. UNFROBBED-FACE and FROBBED-FACE are | |
977 ;; what we expect the original face and the result to look like, | |
978 ;; respectively. TTY-PROPS is a list of face properties to frob in place | |
4764
dec62ca5a899
Prevent font frobbers from operating on TTY specs.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4741
diff
changeset
|
979 ;; of `font' for TTYs. FROB-MAPPING is either a plist mapping device |
872 | 980 ;; types to functions of two args (NAME DEVICE) that will frob the |
4764
dec62ca5a899
Prevent font frobbers from operating on TTY specs.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4741
diff
changeset
|
981 ;; instantiator to NAME as appropriate for DEVICE's type (this includes |
dec62ca5a899
Prevent font frobbers from operating on TTY specs.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4741
diff
changeset
|
982 ;; TTYs #### TTYs are not passed the device, just the symbol 'tty), or a |
dec62ca5a899
Prevent font frobbers from operating on TTY specs.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4741
diff
changeset
|
983 ;; function to handle the mapping for all device types. |
872 | 984 ;; STANDARD-FACE-MAPPING is an alist of mappings of inheritance |
985 ;; instantiators to be replaced with other inheritance instantiators, meant | |
986 ;; for e.g. converting [bold] into [bold-italic]. | |
987 | |
988 ;; #### it would be nice if this function could be generalized to be | |
989 ;; a general specifier frobber. but so much of what it does is specific | |
990 ;; to faces -- e.g. handling of inheritance, standard faces, | |
991 ;; special-casing in various ways for tty's, etc. i've already extracted | |
992 ;; as much of the functionality as i can into subfunctions in the | |
993 ;; heuristic section of specifier.el. | |
442 | 994 |
872 | 995 ;; #### Note: The old code was totally different (and there was much less |
996 ;; of it). It didn't bother with trying to frob all the instantiators, | |
997 ;; or handle inheritance vectors as instantiators, or do something | |
998 ;; sensible with buffer locales, or many other things. (It always, or | |
999 ;; usually, did a specifier-instance and frobbed the result.) But it did | |
1000 ;; do three things we don't: | |
1001 ;; | |
1002 ;; (1) Map over all devices when processing global or buffer locales. | |
1003 ;; Should we be doing this in stages 2 and/or 3? The fact that we | |
1004 ;; now process all fallback instantiators seems to make this less | |
1005 ;; necessary, at least for global locales. | |
1006 ;; | |
1007 ;; (2) Remove all instantiators tagged with `default' when putting the | |
1008 ;; instantiators back. I don't see why this is necessary, but maybe | |
1009 ;; it is. | |
1010 ;; | |
1011 ;; (3) Pay attention to the face-frob-from-locale-first variable. #### | |
1012 ;; I don't understand its purpose. Undocumented hacks like this, | |
1013 ;; clearly added after-the-fact, don't deserve to live. DOCUMENT | |
1014 ;; THIS SHIT! | |
428 | 1015 |
872 | 1016 (flet |
1017 ( | |
1018 | |
1019 ;; non-nil if either instantiator non-nil, or nil instantiators allowed. | |
1020 (nil-instantiator-ok (inst devtype-spec) | |
1021 (or inst (eq devtype-spec 'tty))) | |
1022 | |
1023 ;; if LOCALE is a global locale (all, nil, global), return 'global, | |
1024 ;; else nil. | |
1025 (global-locale (locale) | |
1026 (and (memq locale '(all nil global)) 'global)) | |
444 | 1027 |
872 | 1028 ;; Given a locale and the inst-list from that locale, frob the |
1029 ;; instantiators according to FROB-MAPPING, a plist mapping device | |
1030 ;; types to functions that frob instantiators of that device type. | |
1031 ;; NOTE: TAG-SET and FROB-MAPPING from environment. | |
1032 (frob-face-inst-list (locale inst-list prop devtype-spec) | |
1033 (let* ((ffpdev Face-frob-property-device-considered-current) | |
1034 (results | |
1035 ;; for each inst-pair, frob it (the result will be 0 or | |
1036 ;; more inst-pairs; we may get more than one if, e.g. the | |
1037 ;; instantiator specifies inheritance and we expand the | |
1038 ;; inheritance); then nconc the results together | |
1039 (loop for (tag-set . x) in inst-list | |
1040 for devtype = (derive-device-type-from-locale-and-tag-set | |
1041 locale tag-set devtype-spec ffpdev) | |
1042 ;; devtype may be nil if it fails to match DEVTYPE-SPEC | |
1043 if devtype | |
3360 | 1044 if (let* ((mapper |
1045 (cond ((functionp frob-mapping) frob-mapping) | |
1046 ((plist-get frob-mapping devtype)) | |
1047 (t (error 'unimplemented "mapper" devtype)))) | |
872 | 1048 (result |
1049 (cond | |
1050 ;; if a vector ... | |
1051 ((vectorp x) | |
1052 (let ((change-to | |
1053 (cdr (assoc x standard-face-mapping)))) | |
1054 (cond | |
1055 ;; (1) handle standard mappings/null vectors | |
1056 ((or change-to (null (length x))) | |
1057 (list (cons tag-set | |
1058 (cond ((eq change-to t) x) | |
1059 (change-to) | |
1060 (t x))))) | |
1061 ;; (2) inheritance vectors. retrieve the | |
1062 ;; inherited value and recursively frob. | |
1063 ;; stick the tag-set into the result. | |
1064 (t (let* | |
1065 ((subprop | |
1066 (if (> (length x) 1) (elt x 1) | |
1067 prop)) | |
1068 (subinsts | |
1069 (frob-face-inst-list | |
1070 locale | |
1071 (cdar | |
1072 (specifier-spec-list | |
1073 (face-property (elt x 0) | |
1074 subprop))) | |
1075 subprop devtype-spec))) | |
1076 ;; #### we don't currently handle | |
1077 ;; the "reverse the sense" flag on | |
1078 ;; tty inheritance vectors. | |
1079 (add-tag-to-inst-list subinsts | |
1080 tag-set)))))) | |
1081 ;; (3) not a vector. just process it. | |
1082 (t | |
1083 (let ((value | |
1084 (if (eq devtype-spec 'tty) | |
4764
dec62ca5a899
Prevent font frobbers from operating on TTY specs.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4741
diff
changeset
|
1085 ;; #### not quite right but need |
dec62ca5a899
Prevent font frobbers from operating on TTY specs.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4741
diff
changeset
|
1086 ;; two args to match documentation |
dec62ca5a899
Prevent font frobbers from operating on TTY specs.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4741
diff
changeset
|
1087 ;; mostly we just ignore TTYs so |
dec62ca5a899
Prevent font frobbers from operating on TTY specs.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4741
diff
changeset
|
1088 ;; for now just pass the devtype |
dec62ca5a899
Prevent font frobbers from operating on TTY specs.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4741
diff
changeset
|
1089 (funcall mapper x 'tty) |
872 | 1090 (funcall mapper x |
1091 (derive-domain-from-locale | |
1092 locale devtype-spec | |
1093 ffpdev))))) | |
1094 (and (nil-instantiator-ok value devtype-spec) | |
1095 (list (cons tag-set value)))))))) | |
1096 ;; if we're adding to a tty, we need to tag our | |
1097 ;; additions with `tty'; see [note 1] below. we leave | |
1098 ;; the old spec in place, however -- if e.g. we're | |
1099 ;; italicizing a font that was always set to be | |
1100 ;; underlined, even on window systems, then we still | |
1101 ;; want the underline there. unless we put the old | |
1102 ;; spec back, the underline will disappear, since | |
1103 ;; the new specs are all tagged with `tty'. this | |
1104 ;; doesn't apply to the [note 1] situations below | |
1105 ;; because there we're just adding, not substituting. | |
1106 (if (and (eq 'tty devtype-spec) | |
1107 (not (or (eq 'tty tag-set) | |
1108 (memq 'tty tag-set)))) | |
1109 (nconc (add-tag-to-inst-list result 'tty) | |
1110 (list (cons tag-set x))) | |
1111 result)) | |
1112 nconc it))) | |
1113 (delete-duplicates results :test #'equal))) | |
428 | 1114 |
872 | 1115 ;; Frob INST-LIST, which came from LOCALE, and put the new value back |
1116 ;; into SP at LOCALE. THUNK is a cons of (PROP . DEVTYPE-SPEC), the | |
1117 ;; property being processed and whether this is a TTY property or a | |
1118 ;; win property. | |
1119 (frob-locale (sp locale inst-list thunk) | |
1120 (let ((newinst (frob-face-inst-list locale inst-list | |
1121 (car thunk) (cdr thunk)))) | |
1122 (remove-specifier sp locale tag-set exact-p) | |
1123 (add-spec-list-to-specifier sp (list (cons locale newinst)))) | |
1124 ;; map-specifier should keep going | |
1125 nil) | |
428 | 1126 |
872 | 1127 ;; map over all specified locales in LOCALE; for each locale, |
1128 ;; frob the instantiators in that locale in the specifier in both | |
1129 ;; WIN-PROP and TTY-PROPS in FACE. Takes values from environment. | |
1130 (map-over-locales (locale) | |
1131 (map-specifier (get face win-prop) #'frob-locale locale | |
1132 (cons win-prop 'window-system) | |
1133 tag-set exact-p) | |
1134 (loop for prop in tty-props do | |
1135 (map-specifier (get face prop) #'frob-locale locale | |
1136 (cons prop 'tty) | |
1137 tag-set exact-p))) | |
1138 | |
1139 ;; end of flets | |
1140 ) | |
1141 | |
1142 ;; the function itself | |
452 | 1143 |
872 | 1144 (let* ((ffpdev Face-frob-property-device-considered-current) |
1145 (do-later-stages | |
1146 (or (global-locale locale) | |
1147 (valid-specifier-domain-p locale) | |
1148 (bufferp locale))) | |
1149 (domain (and do-later-stages | |
1150 (derive-domain-from-locale locale 'window-system | |
1151 ffpdev))) | |
1152 (check-differences | |
1153 (and unfrobbed-face frobbed-face domain | |
1154 (not (memq (face-name face) | |
1155 '(default bold italic bold-italic))))) | |
1156 (orig-instance | |
1157 (and check-differences | |
1158 (face-property-instance face win-prop domain)))) | |
1159 | |
1160 ;; first do the frobbing | |
1161 (setq face (get-face face)) | |
1162 (map-over-locales locale) | |
1163 | |
1164 (when do-later-stages | |
1165 | |
1166 (if (global-locale locale) (setq locale 'global)) | |
428 | 1167 |
872 | 1168 ;; now do the second stage -- if there's nothing there, try |
1169 ;; harder to find an instantiator, and frob it. | |
1170 (let (do-something) | |
1171 (loop for prop in (cons win-prop tty-props) | |
1172 for propspec = (get face prop) | |
1173 for devtype-spec = (if (eq prop win-prop) 'window-system 'tty) | |
1174 if propspec | |
1175 do | |
1176 (or (specifier-spec-list propspec locale) | |
1177 (let ((doit (derive-specifier-specs-from-locale | |
1178 propspec locale devtype-spec ffpdev | |
1179 ;; #### does this make sense? When no tags | |
1180 ;; given, frob the whole list of fallbacks when | |
1181 ;; global, else just retrieve a current-device | |
1182 ;; value. this tries to mirror normal practices, | |
1183 ;; where with no tags you want everything frobbed, | |
1184 ;; but with a tag you want only the tag frobbed | |
1185 ;; and hence you probably don't want lots and lots | |
1186 ;; of items there. (#### Perhaps the best way -- | |
1187 ;; or at least a way with some theoretical | |
1188 ;; justifiability -- is to fetch the fallbacks | |
1189 ;; that match the TAG-SET/EXACT-P, and if none, | |
1190 ;; fall back onto doing the selected-device | |
1191 ;; trick.) | |
1192 (and (not tag-set) (not exact-p))))) | |
1193 (if (and (not doit) (eq locale 'global)) | |
1194 (error | |
1195 "No fallback for specifier property %s in face %s???" | |
1196 prop face)) | |
1197 ;; [note 1] whenever we add to a tty property, | |
1198 ;; make sure we tag our additions with `tty' to | |
1199 ;; avoid accidentally messing things up on window | |
1200 ;; systems (e.g. when making things italic we | |
1201 ;; don't want to set the underline property on | |
1202 ;; window systems) | |
1203 (when doit | |
1204 (add-spec-list-to-specifier | |
1205 propspec | |
1206 (list (cons locale | |
1207 (add-tag-to-inst-list | |
1208 doit | |
1209 (append (if (listp tag-set) tag-set | |
1210 (list tag-set)) | |
1211 (if (eq devtype-spec 'tty) '(tty))) | |
1212 )))) | |
1213 (setq do-something t))))) | |
1214 (when do-something | |
1215 (map-over-locales (or (global-locale locale) locale)))) | |
1216 | |
1217 ;; then do the third stage -- check for whether we have to do | |
1218 ;; the inheritance trick. | |
1219 | |
1220 (when (and check-differences | |
1221 (let ((new-instance | |
1222 (face-property-instance face win-prop domain))) | |
1223 (and | |
1224 (equal orig-instance new-instance) | |
1225 (equal orig-instance | |
1226 (face-property-instance unfrobbed-face win-prop | |
1227 domain))))) | |
1228 (set-face-property face win-prop (vector frobbed-face) | |
1229 (or (global-locale locale) locale) tag-set)))))) | |
428 | 1230 |
707 | 1231 ;; WE DEMAND FOUNDRY FROBBING! |
1232 | |
1233 ;; Family frobbing | |
1234 ;; Thx Jan Vroonhof, Ref xemacs-beta <87oflypbum.fsf@petteflet.ntlworld.com> | |
1235 ;; Brainlessly derived from make-face-size by Stephen; don't blame Jan. | |
1236 ;; I'm long since flown to Rio, it does you little good to blame me, either. | |
872 | 1237 (defun make-face-family (face family &optional locale tags exact-p) |
1238 "Set FACE's family to FAMILY in LOCALE, if possible." | |
1239 (interactive (list (read-face-name "Set family of which face: ") | |
1240 (read-string "Family to set: "))) | |
707 | 1241 |
872 | 1242 (Face-frob-property face locale tags exact-p |
1243 nil nil 'font nil | |
4764
dec62ca5a899
Prevent font frobbers from operating on TTY specs.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4741
diff
changeset
|
1244 ;; #### this code is duplicated in make-face-size |
872 | 1245 `(lambda (f d) |
4764
dec62ca5a899
Prevent font frobbers from operating on TTY specs.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4741
diff
changeset
|
1246 ;; keep the dependency on font.el for now |
dec62ca5a899
Prevent font frobbers from operating on TTY specs.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4741
diff
changeset
|
1247 ;; #### The filter on null d is a band-aid. |
dec62ca5a899
Prevent font frobbers from operating on TTY specs.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4741
diff
changeset
|
1248 ;; Frob-face-property should not be passing in |
dec62ca5a899
Prevent font frobbers from operating on TTY specs.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4741
diff
changeset
|
1249 ;; null devices. |
dec62ca5a899
Prevent font frobbers from operating on TTY specs.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4741
diff
changeset
|
1250 (unless (or (null d) (eq d 'tty)) |
dec62ca5a899
Prevent font frobbers from operating on TTY specs.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4741
diff
changeset
|
1251 (let ((fo (font-create-object f d))) |
dec62ca5a899
Prevent font frobbers from operating on TTY specs.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4741
diff
changeset
|
1252 (set-font-family fo ,family) |
dec62ca5a899
Prevent font frobbers from operating on TTY specs.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4741
diff
changeset
|
1253 (font-create-name fo d)))) |
872 | 1254 nil)) |
707 | 1255 |
1256 ;; Style (ie, typographical face) frobbing | |
872 | 1257 (defun make-face-bold (face &optional locale tags exact-p) |
428 | 1258 "Make FACE bold in LOCALE, if possible. |
872 | 1259 This will attempt to make the font bold for window-system locales and will |
1260 set the highlight flag for TTY locales. | |
1261 | |
1262 The actual behavior of this function is somewhat messy, in an attempt to | |
1263 get more intuitive behavior in quite a lot of different circumstances. (You | |
1264 might view this as indicative of design failures with specifiers, but in | |
1265 fact almost all code that attempts to interface to humans and produce | |
1266 \"intuitive\" results gets messy, particularly with a system as complicated | |
1267 as specifiers, whose complexity results from an attempt to work well in | |
1268 many different circumstances.) | |
1269 | |
1270 The meaning of LOCALE is the same as for `specifier-spec-list', i.e.: | |
1271 | |
1272 -- If LOCALE is nil, omitted, or `all', this will attempt to \"frob\" all | |
1273 font specifications for FACE to make them appear bold (i.e. the | |
1274 specifications are replaced with equivalent specifications, where the | |
1275 font names have been changed to the closest bold font). | |
1276 | |
1277 -- If LOCALE is a locale type \(`buffer', `window', etc.), this frobs all | |
1278 font specifications for locales of that type. | |
1279 | |
1280 -- If LOCALE is a particular locale, this frobs all font specifications for | |
1281 that locale. | |
428 | 1282 |
872 | 1283 If TAGS is given, this only processes instantiators whose tag set includes |
1284 all tags mentioned in TAGS. In addition, if EXACT-P is non-nil, only | |
1285 instantiators whose tag set exactly matches TAGS are processed; otherwise, | |
1286 additional tags may be present in the instantiator's tag set. | |
1287 | |
1288 This function proceeeds in three stages. | |
1289 | |
1290 STAGE 1: Frob the settings that are already present. | |
1291 STAGE 2: (if called for) Ensure that *some* setting exists in the locale | |
1292 that was given, finding it in various ways and frobbing it as in | |
1293 stage 1. This ensures that there is an actual setting for | |
1294 the locale, so you will get the expected buffer-local/frame-local | |
1295 behavior -- changes to the global value, to other locales, won't | |
1296 affect this locale, (b) the face will actually look bold in | |
1297 the locale. | |
1137 | 1298 STAGE 3: (if called for) |
872 | 1299 |
1300 The way the frobbing works depends on the device type -- first on whether | |
1301 or not it's TTY, and second, if it's a window-system device type, on which | |
1302 particular window-system device type. For locales with a specific device | |
1303 type, we do the frobbing in the context of that device type -- this means | |
1304 that for TTY device types we set the highlight flag, and for window-system | |
1305 device types we modify the font spec according to the rules for font specs | |
1306 of that device type. For global locales, we may process both the highlight | |
1307 flag and the font specs (depending on the device types compiled into this | |
1308 XEmacs). When processing font specs, we check the tag set associated with | |
1309 each font spec to see if it's specific to a particular device type; if so, | |
1310 we frob it in the context of that type, else we use the type of the current | |
1311 device. (A hack, but works well in practice -- and if a new device is | |
1312 created, we will automatically frob all the standard fonts to make sure | |
1313 they display OK on that device.) | |
1314 | |
1315 If LOCALE is not a locale type, and both TAGS and EXACT-P are omitted, we | |
1316 do further frobbing in an attempt to give more intuitive behavior. | |
428 | 1317 |
872 | 1318 First, if there are no specifications in LOCALE (if LOCALE is `all', we act |
1319 as if it were `global' for this step), we do our utmost to put a | |
1320 specification there; otherwise, this function will have no effect. For | |
1321 device, frame, or window locales, the face's font is instantiated using the | |
1322 locale as a domain, and the resulting font is frobbed and added back as a | |
1323 specification for this locale. If LOCALE is `global', we retrieve the | |
1324 fallback specs and frob them. If LOCALE is a buffer, things get tricky | |
1325 since you can't instantiate a specifier in a buffer domain \(the buffer can | |
1326 appear in multiple places, or in different places over time, so this | |
1327 operation is not well-defined). We used to signal an error in this case, | |
1328 but now we instead try to do something logical so that we work somewhat | |
1329 similarly to buffer-local variables. Specifically, we use | |
1330 `get-buffer-window' to find a window viewing the buffer, and if there is | |
1331 one, use this as a domain to instantiate the font, and frob the resulting | |
1332 value. Otherwise, we use the selected window for the same purpose. | |
1333 | |
1334 Finally, if the frobbing didn't actually make the font look any different | |
1335 in whatever domain we instantiated the font in (this happens, for example, | |
1336 if your font specification is already bold or has no bold equivalent; note | |
1337 that in this step, we use the selected device in place of `global' or `all' | |
1338 -- another hack, but works well in practice since there's usually only one | |
1339 device), and the font currently looks like the font of the `default' face, | |
1340 it is set to inherit from the `bold' face. | |
1341 | |
1342 NOTE: For the other functions defined below, the identity of these two | |
1343 standard faces mentioned in the previous paragraph, and the TTY properties | |
1344 that are modified, may be different, and whether the TTY property or | |
1345 properties are set or unset may be different. For example, for | |
1346 `make-face-unitalic', the last sentence in the previous paragraph would | |
1347 read \"... and the font currently looks like the font of the `italic' face, | |
1348 it is set to inherit from the `default' face.\", and the second sentence in | |
1349 the first paragraph would read \"This will attempt to make the font | |
1350 non-italic for window-system locales and will unset the underline flag for | |
1351 TTY locales.\" | |
1352 | |
1353 Here's a table indicating the behavior differences with the different | |
1354 functions: | |
1355 | |
1356 function face1 face2 tty-props tty-val | |
1357 ---------------------------------------------------------------------------- | |
1358 make-face-bold default bold highlight t | |
1359 make-face-italic default italic underline t | |
1360 make-face-bold-italic default bold-italic highlight,underline t | |
1361 make-face-unbold bold default highlight nil | |
1362 make-face-unitalic italic default underline nil | |
1363 " | |
428 | 1364 (interactive (list (read-face-name "Make which face bold: "))) |
872 | 1365 (Face-frob-property face locale tags exact-p |
1366 'default 'bold 'font '(highlight) | |
4764
dec62ca5a899
Prevent font frobbers from operating on TTY specs.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4741
diff
changeset
|
1367 '(tty (lambda (f d) t) |
872 | 1368 x x-make-font-bold |
1369 gtk gtk-make-font-bold | |
1370 mswindows mswindows-make-font-bold | |
1371 msprinter mswindows-make-font-bold) | |
1372 '(([default] . [bold]) | |
1373 ([bold] . t) | |
1374 ([italic] . [bold-italic]) | |
1375 ([bold-italic] . t)))) | |
428 | 1376 |
872 | 1377 (defun make-face-italic (face &optional locale tags exact-p) |
428 | 1378 "Make FACE italic in LOCALE, if possible. |
442 | 1379 This will attempt to make the font italic for X/MS Windows locales and |
1380 will set the underline flag for TTY locales. See `make-face-bold' for | |
1381 the semantics of the LOCALE argument and for more specifics on exactly | |
1382 how this function works." | |
428 | 1383 (interactive (list (read-face-name "Make which face italic: "))) |
872 | 1384 (Face-frob-property face locale tags exact-p |
1385 'default 'italic 'font '(underline) | |
4764
dec62ca5a899
Prevent font frobbers from operating on TTY specs.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4741
diff
changeset
|
1386 '(tty (lambda (f d) t) |
872 | 1387 x x-make-font-italic |
1388 gtk gtk-make-font-italic | |
1389 mswindows mswindows-make-font-italic | |
1390 msprinter mswindows-make-font-italic) | |
1391 '(([default] . [italic]) | |
1392 ([bold] . [bold-italic]) | |
1393 ([italic] . t) | |
1394 ([bold-italic] . t)))) | |
428 | 1395 |
872 | 1396 (defun make-face-bold-italic (face &optional locale tags exact-p) |
428 | 1397 "Make FACE bold and italic in LOCALE, if possible. |
442 | 1398 This will attempt to make the font bold-italic for X/MS Windows |
1399 locales and will set the highlight and underline flags for TTY | |
1400 locales. See `make-face-bold' for the semantics of the LOCALE | |
1401 argument and for more specifics on exactly how this function works." | |
428 | 1402 (interactive (list (read-face-name "Make which face bold-italic: "))) |
872 | 1403 (Face-frob-property face locale tags exact-p |
1404 'default 'bold-italic 'font '(underline highlight) | |
4764
dec62ca5a899
Prevent font frobbers from operating on TTY specs.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4741
diff
changeset
|
1405 '(tty (lambda (f d) t) |
872 | 1406 x x-make-font-bold-italic |
1407 gtk gtk-make-font-bold-italic | |
1408 mswindows mswindows-make-font-bold-italic | |
1409 msprinter mswindows-make-font-bold-italic) | |
1410 '(([default] . [italic]) | |
1411 ([bold] . [bold-italic]) | |
1412 ([italic] . [bold-italic]) | |
1413 ([bold-italic] . t)))) | |
428 | 1414 |
872 | 1415 |
1416 (defun make-face-unbold (face &optional locale tags exact-p) | |
428 | 1417 "Make FACE non-bold in LOCALE, if possible. |
442 | 1418 This will attempt to make the font non-bold for X/MS Windows locales |
1419 and will unset the highlight flag for TTY locales. See | |
1420 `make-face-bold' for the semantics of the LOCALE argument and for more | |
1421 specifics on exactly how this function works." | |
428 | 1422 (interactive (list (read-face-name "Make which face non-bold: "))) |
872 | 1423 (Face-frob-property face locale tags exact-p |
1424 'bold 'default 'font '(highlight) | |
4764
dec62ca5a899
Prevent font frobbers from operating on TTY specs.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4741
diff
changeset
|
1425 '(tty (lambda (f d) nil) |
872 | 1426 x x-make-font-unbold |
1427 gtk gtk-make-font-unbold | |
1428 mswindows mswindows-make-font-unbold | |
1429 msprinter mswindows-make-font-unbold) | |
1430 '(([default] . t) | |
1431 ([bold] . [default]) | |
1432 ([italic] . t) | |
1433 ([bold-italic] . [italic])))) | |
428 | 1434 |
872 | 1435 (defun make-face-unitalic (face &optional locale tags exact-p) |
428 | 1436 "Make FACE non-italic in LOCALE, if possible. |
442 | 1437 This will attempt to make the font non-italic for X/MS Windows locales |
1438 and will unset the underline flag for TTY locales. See | |
1439 `make-face-bold' for the semantics of the LOCALE argument and for more | |
1440 specifics on exactly how this function works." | |
428 | 1441 (interactive (list (read-face-name "Make which face non-italic: "))) |
872 | 1442 (Face-frob-property face locale tags exact-p |
1443 'italic 'default 'font '(underline) | |
4764
dec62ca5a899
Prevent font frobbers from operating on TTY specs.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4741
diff
changeset
|
1444 '(tty (lambda (f d) nil) |
872 | 1445 x x-make-font-unitalic |
1446 gtk gtk-make-font-unitalic | |
1447 mswindows mswindows-make-font-unitalic | |
1448 msprinter mswindows-make-font-unitalic) | |
1449 '(([default] . t) | |
1450 ([bold] . t) | |
1451 ([italic] . [default]) | |
1452 ([bold-italic] . [bold])))) | |
428 | 1453 |
1454 | |
707 | 1455 ;; Size frobbing |
1456 ;; Thx Jan Vroonhof, Ref xemacs-beta <87oflypbum.fsf@petteflet.ntlworld.com> | |
1137 | 1457 ;; Jan had a separate helper function |
872 | 1458 (defun make-face-size (face size &optional locale tags exact-p) |
1459 "Adjust FACE to SIZE in LOCALE, if possible." | |
1460 (interactive (list (read-face-name "Set size of which face: ") | |
1461 (read-number "Size to set: " t 10))) | |
1462 (Face-frob-property face locale tags exact-p | |
1463 nil nil 'font nil | |
4764
dec62ca5a899
Prevent font frobbers from operating on TTY specs.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4741
diff
changeset
|
1464 ;; #### this code is duplicated in make-face-family |
872 | 1465 `(lambda (f d) |
1466 ;; keep the dependency on font.el for now | |
4764
dec62ca5a899
Prevent font frobbers from operating on TTY specs.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4741
diff
changeset
|
1467 ;; #### The filter on null d is a band-aid. |
dec62ca5a899
Prevent font frobbers from operating on TTY specs.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4741
diff
changeset
|
1468 ;; Frob-face-property should not be passing in |
dec62ca5a899
Prevent font frobbers from operating on TTY specs.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4741
diff
changeset
|
1469 ;; null devices. |
dec62ca5a899
Prevent font frobbers from operating on TTY specs.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4741
diff
changeset
|
1470 (unless (or (null d) (eq d 'tty)) |
dec62ca5a899
Prevent font frobbers from operating on TTY specs.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4741
diff
changeset
|
1471 (let ((fo (font-create-object f d))) |
dec62ca5a899
Prevent font frobbers from operating on TTY specs.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4741
diff
changeset
|
1472 (set-font-size fo ,size) |
dec62ca5a899
Prevent font frobbers from operating on TTY specs.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4741
diff
changeset
|
1473 (font-create-name fo d)))) |
872 | 1474 nil)) |
707 | 1475 |
428 | 1476 ;; Why do the following two functions lose so badly in so many |
1477 ;; circumstances? | |
1478 | |
872 | 1479 (defun make-face-smaller (face &optional locale tags exact-p) |
428 | 1480 "Make the font of FACE be smaller, if possible. |
1481 LOCALE works as in `make-face-bold' et al., but the ``inheriting- | |
1482 from-the-bold-face'' operations described there are not done | |
1483 because they don't make sense in this context." | |
1484 (interactive (list (read-face-name "Shrink which face: "))) | |
872 | 1485 (Face-frob-property face locale tags exact-p |
1486 nil nil 'font nil | |
1487 '(x x-find-smaller-font | |
1488 gtk gtk-find-smaller-font | |
1489 mswindows mswindows-find-smaller-font | |
1490 msprinter mswindows-find-smaller-font) | |
1491 nil)) | |
428 | 1492 |
872 | 1493 (defun make-face-larger (face &optional locale tags exact-p) |
428 | 1494 "Make the font of FACE be larger, if possible. |
1495 See `make-face-smaller' for the semantics of the LOCALE argument." | |
1496 (interactive (list (read-face-name "Enlarge which face: "))) | |
872 | 1497 (Face-frob-property face locale tags exact-p |
1498 nil nil 'font nil | |
1499 '(x x-find-larger-font | |
1500 gtk gtk-find-larger-font | |
1501 mswindows mswindows-find-larger-font | |
1502 msprinter mswindows-find-larger-font) | |
1503 nil)) | |
428 | 1504 |
1505 (defun invert-face (face &optional locale) | |
1506 "Swap the foreground and background colors of the face." | |
1507 (interactive (list (read-face-name "Invert face: "))) | |
1508 (if (valid-specifier-domain-p locale) | |
1509 (let ((foreface (face-foreground-instance face locale))) | |
1510 (set-face-foreground face (face-background-instance face locale) | |
1511 locale) | |
1512 (set-face-background face foreface locale)) | |
1513 (let ((forespec (copy-specifier (face-foreground face) nil locale))) | |
1514 (copy-specifier (face-background face) (face-foreground face) locale) | |
1515 (copy-specifier forespec (face-background face) locale)))) | |
1516 | |
1517 | |
1518 ;;; Convenience functions | |
1519 | |
1520 (defun face-ascent (face &optional domain charset) | |
1521 "Return the ascent of FACE in DOMAIN. | |
1522 See `face-property-instance' for the semantics of the DOMAIN argument." | |
1523 (font-ascent (face-font face) domain charset)) | |
1524 | |
1525 (defun face-descent (face &optional domain charset) | |
1526 "Return the descent of FACE in DOMAIN. | |
1527 See `face-property-instance' for the semantics of the DOMAIN argument." | |
1528 (font-descent (face-font face) domain charset)) | |
1529 | |
1530 (defun face-width (face &optional domain charset) | |
1531 "Return the width of FACE in DOMAIN. | |
1532 See `face-property-instance' for the semantics of the DOMAIN argument." | |
1533 (font-width (face-font face) domain charset)) | |
1534 | |
1535 (defun face-height (face &optional domain charset) | |
1536 "Return the height of FACE in DOMAIN. | |
1537 See `face-property-instance' for the semantics of the DOMAIN argument." | |
1538 (+ (face-ascent face domain charset) (face-descent face domain charset))) | |
1539 | |
1540 (defun face-proportional-p (face &optional domain charset) | |
1541 "Return t if FACE is proportional in DOMAIN. | |
1542 See `face-property-instance' for the semantics of the DOMAIN argument." | |
1543 (font-proportional-p (face-font face) domain charset)) | |
1544 | |
1545 | |
1546 ;; Functions that used to be in cus-face.el, but logically go here. | |
1547 | |
1548 (defcustom frame-background-mode nil | |
1549 "*The brightness of the background. | |
1550 Set this to the symbol dark if your background color is dark, light if | |
1551 your background is light, or nil (default) if you want Emacs to | |
1552 examine the brightness for you." | |
1553 :group 'faces | |
1554 :type '(choice (choice-item dark) | |
1555 (choice-item light) | |
1556 (choice-item :tag "Auto" nil))) | |
1557 | |
1558 ;; The old variable that many people still have in .emacs files. | |
1559 (define-obsolete-variable-alias 'custom-background-mode | |
1560 'frame-background-mode) | |
1561 | |
1562 (defun get-frame-background-mode (frame) | |
1563 "Detect background mode for FRAME." | |
1564 (let* ((color-instance (face-background-instance 'default frame)) | |
1565 (mode (condition-case nil | |
1566 (if (< (apply '+ (color-instance-rgb-components | |
1567 color-instance)) 65536) | |
1568 'dark 'light) | |
872 | 1569 ;; Here, we get an error on a TTY (Return value from |
1570 ;; color-instance-rgb-components is nil), and on the | |
1571 ;; initial stream device (Return value from | |
1572 ;; face-background-instance is nil). As we don't have a | |
1573 ;; good way of detecting whether a TTY is light or dark, | |
1574 ;; we'll guess it's dark. | |
428 | 1575 (error 'dark)))) |
1576 (set-frame-property frame 'background-mode mode) | |
1577 mode)) | |
1578 | |
1579 (defun extract-custom-frame-properties (frame) | |
1580 "Return a plist with the frame properties of FRAME used by custom." | |
1581 (list 'type (or (frame-property frame 'display-type) | |
1582 (device-type (frame-device frame))) | |
1583 'class (device-class (frame-device frame)) | |
1584 'background (or frame-background-mode | |
1585 (frame-property frame 'background-mode) | |
1586 (get-frame-background-mode frame)))) | |
1587 | |
1588 (defcustom init-face-from-resources t | |
1589 "If non nil, attempt to initialize faces from the resource database." | |
1590 :group 'faces | |
1591 :type 'boolean) | |
1592 | |
1593 ;; Old name, used by custom. Also, FSFmacs name. | |
1594 (defvaralias 'initialize-face-resources 'init-face-from-resources) | |
1595 | |
1596 ;; Make sure all custom setting are added with this tag so we can | |
1597 ;; identify-them | |
1598 (define-specifier-tag 'custom) | |
1599 | |
1600 (defun face-spec-set (face spec &optional frame tags) | |
1601 "Set FACE's face attributes according to the first matching entry in SPEC. | |
1602 If optional FRAME is non-nil, set it for that frame only. | |
1603 If it is nil, then apply SPEC to each frame individually. | |
1604 See `defface' for information about SPEC." | |
1605 (if frame | |
1606 (progn | |
1607 (reset-face face frame tags) | |
1608 (face-display-set face spec frame tags) | |
1609 (init-face-from-resources face frame)) | |
1610 (let ((frames (relevant-custom-frames))) | |
1611 (reset-face face nil tags) | |
1612 ;; This should not be needed. We only remove our own specifiers | |
1613 ;; (if (and (eq 'default face) (featurep 'x)) | |
1614 ;; (x-init-global-faces)) | |
1615 (face-display-set face spec nil tags) | |
1616 (while frames | |
1617 (face-display-set face spec (car frames) tags) | |
1618 (pop frames)) | |
1619 (init-face-from-resources face)))) | |
1620 | |
1621 (defun face-display-set (face spec &optional frame tags) | |
1622 "Set FACE to the attributes to the first matching entry in SPEC. | |
1623 Iff optional FRAME is non-nil, set it for that frame only. | |
1624 See `defface' for information about SPEC." | |
1625 (while spec | |
1626 (let ((display (caar spec)) | |
1627 (atts (cadar spec))) | |
1628 (pop spec) | |
1629 (when (face-spec-set-match-display display frame) | |
1630 ;; Avoid creating frame local duplicates of the global face. | |
1631 (unless (and frame (eq display (get face 'custom-face-display))) | |
1632 (apply 'face-custom-attributes-set face frame tags atts)) | |
1633 (unless frame | |
1634 (put face 'custom-face-display display)) | |
1635 (setq spec nil))))) | |
1636 | |
1637 (defvar default-custom-frame-properties nil | |
1638 "The frame properties used for the global faces. | |
442 | 1639 Frames not matching these properties should have frame local faces. |
428 | 1640 The value should be nil, if uninitialized, or a plist otherwise. |
1641 See `defface' for a list of valid keys and values for the plist.") | |
1642 | |
1643 (defun get-custom-frame-properties (&optional frame) | |
1644 "Return a plist with the frame properties of FRAME used by custom. | |
1645 If FRAME is nil, return the default frame properties." | |
1646 (cond (frame | |
1647 ;; Try to get from cache. | |
1648 (let ((cache (frame-property frame 'custom-properties))) | |
1649 (unless cache | |
1650 ;; Oh well, get it then. | |
1651 (setq cache (extract-custom-frame-properties frame)) | |
1652 ;; and cache it... | |
1653 (set-frame-property frame 'custom-properties cache)) | |
1654 cache)) | |
1655 (default-custom-frame-properties) | |
1656 (t | |
1657 (setq default-custom-frame-properties | |
1658 (extract-custom-frame-properties (selected-frame)))))) | |
1659 | |
1660 (defun face-spec-update-all-matching (spec display plist) | |
1661 "Update all entries in the face spec that could match display to | |
444 | 1662 have the entries from the new plist and return the new spec." |
428 | 1663 (mapcar |
1664 (lambda (e) | |
1665 (let ((entries (car e)) | |
1666 (options (cadr e)) | |
1667 (match t) | |
1668 dplist | |
1669 (new-options plist) | |
1670 ) | |
1671 (unless (eq display t) | |
1672 (mapc (lambda (arg) | |
1673 (setq dplist (plist-put dplist (car arg) (cadr arg)))) | |
1674 display)) | |
1675 (unless (eq entries t) | |
1676 (mapc (lambda (arg) | |
1677 (setq match (and match (eq (cadr arg) | |
1678 (plist-get | |
1679 dplist (car arg) | |
1680 (cadr arg)))))) | |
1681 entries)) | |
1682 (if (not match) | |
1683 e | |
1684 (while new-options | |
1685 (setq options | |
1686 (plist-put options (car new-options) (cadr new-options))) | |
1687 (setq new-options (cddr new-options))) | |
1688 (list entries options)))) | |
1689 (copy-sequence spec))) | |
444 | 1690 |
1691 | |
428 | 1692 |
1693 (defun face-spec-set-match-display (display &optional frame) | |
1694 "Return non-nil if DISPLAY matches FRAME. | |
1695 DISPLAY is part of a spec such as can be used in `defface'. | |
1696 If FRAME is nil or omitted, the selected frame is used." | |
1697 (if (eq display t) | |
1698 t | |
1699 (let* ((props (get-custom-frame-properties frame)) | |
1700 (type (plist-get props 'type)) | |
1701 (class (plist-get props 'class)) | |
1702 (background (plist-get props 'background)) | |
1703 (match t) | |
1704 (entries display) | |
1705 entry req options) | |
1706 (while (and entries match) | |
1707 (setq entry (car entries) | |
1708 entries (cdr entries) | |
1709 req (car entry) | |
1710 options (cdr entry) | |
1711 match (case req | |
1712 (type (memq type options)) | |
1713 (class (memq class options)) | |
1714 (background (memq background options)) | |
1715 (t (warn "Unknown req `%S' with options `%S'" | |
1716 req options) | |
1717 nil)))) | |
1718 match))) | |
1719 | |
1720 (defun relevant-custom-frames () | |
1721 "List of frames whose custom properties differ from the default." | |
1722 (let ((relevant nil) | |
1723 (default (get-custom-frame-properties)) | |
1724 (frames (frame-list)) | |
1725 frame) | |
1726 (while frames | |
1727 (setq frame (car frames) | |
1728 frames (cdr frames)) | |
1729 (unless (equal default (get-custom-frame-properties frame)) | |
1730 (push frame relevant))) | |
1731 relevant)) | |
1732 | |
1733 (defun initialize-custom-faces (&optional frame) | |
1734 "Initialize all custom faces for FRAME. | |
1735 If FRAME is nil or omitted, initialize them for all frames." | |
1736 (mapc (lambda (symbol) | |
1737 (let ((spec (or (get symbol 'saved-face) | |
1738 (get symbol 'face-defface-spec)))) | |
1739 (when spec | |
1740 ;; No need to init-face-from-resources -- code in | |
1741 ;; `init-frame-faces' does it already. | |
1742 (face-display-set symbol spec frame)))) | |
1743 (face-list))) | |
1744 | |
1745 (defun custom-initialize-frame (frame) | |
1746 "Initialize frame-local custom faces for FRAME if necessary." | |
1747 (unless (equal (get-custom-frame-properties) | |
1748 (get-custom-frame-properties frame)) | |
1749 (initialize-custom-faces frame))) | |
1750 | |
440 | 1751 (defun startup-initialize-custom-faces () |
1752 "Reset faces created by defface. Only called at startup. | |
1753 Don't use this function in your program." | |
1754 (when default-custom-frame-properties | |
1755 ;; Reset default value to the actual frame, not stream. | |
1756 (setq default-custom-frame-properties | |
1757 (extract-custom-frame-properties (selected-frame))) | |
1758 ;; like initialize-custom-faces but removes property first. | |
1759 (mapc (lambda (symbol) | |
1760 (let ((spec (or (get symbol 'saved-face) | |
1761 (get symbol 'face-defface-spec)))) | |
1762 (when spec | |
1763 ;; Reset faces created during auto-autoloads loading. | |
1764 (reset-face symbol) | |
1765 ;; And set it according to the spec. | |
1766 (face-display-set symbol spec nil)))) | |
1767 (face-list)))) | |
1768 | |
428 | 1769 |
1770 (defun make-empty-face (name &optional doc-string temporary) | |
1771 "Like `make-face', but doesn't query the resource database." | |
1772 (let ((init-face-from-resources nil)) | |
1773 (make-face name doc-string temporary))) | |
1774 | |
1775 (defun init-face-from-resources (face &optional locale) | |
1776 "Initialize FACE from the resource database. | |
3027 | 1777 If LOCALE is specified, it should be a frame, device, or `global', and |
428 | 1778 the face will be resourced over that locale. Otherwise, the face will |
1779 be resourced over all possible locales (i.e. all frames, all devices, | |
3027 | 1780 and `global')." |
428 | 1781 (cond ((null init-face-from-resources) |
1782 ;; Do nothing. | |
1783 ) | |
1784 ((not locale) | |
1785 ;; Global, set for all frames. | |
1786 (progn | |
1787 (init-face-from-resources face 'global) | |
1788 (let ((devices (device-list))) | |
1789 (while devices | |
1790 (init-face-from-resources face (car devices)) | |
1791 (setq devices (cdr devices)))) | |
1792 (let ((frames (frame-list))) | |
1793 (while frames | |
1794 (init-face-from-resources face (car frames)) | |
1795 (setq frames (cdr frames)))))) | |
1796 (t | |
1797 ;; Specific. | |
1798 (let ((devtype (cond ((devicep locale) (device-type locale)) | |
1799 ((framep locale) (frame-type locale)) | |
1800 (t nil)))) | |
1801 (cond ((or (and (not devtype) (featurep 'x)) (eq 'x devtype)) | |
502 | 1802 (declare-fboundp (x-init-face-from-resources face locale))) |
428 | 1803 ((or (not devtype) (eq 'tty devtype)) |
1804 ;; Nothing to do for TTYs? | |
1805 )))))) | |
1806 | |
1807 (defun init-device-faces (device) | |
1808 ;; First, add any device-local face resources. | |
1809 (when init-face-from-resources | |
1810 (loop for face in (face-list) do | |
1811 (init-face-from-resources face device)) | |
1812 ;; Then do any device-specific initialization. | |
1813 (cond ((eq 'x (device-type device)) | |
502 | 1814 (declare-fboundp (x-init-device-faces device))) |
462 | 1815 ((eq 'gtk (device-type device)) |
502 | 1816 (declare-fboundp (gtk-init-device-faces device))) |
428 | 1817 ((eq 'mswindows (device-type device)) |
502 | 1818 (declare-fboundp (mswindows-init-device-faces device))) |
428 | 1819 ;; Nothing to do for TTYs? |
1820 ) | |
1821 (or (eq 'stream (device-type device)) | |
1822 (init-other-random-faces device)))) | |
1823 | |
1824 (defun init-frame-faces (frame) | |
1825 (when init-face-from-resources | |
1826 ;; First, add any frame-local face resources. | |
1827 (loop for face in (face-list) do | |
1828 (init-face-from-resources face frame)) | |
1829 ;; Then do any frame-specific initialization. | |
1830 (cond ((eq 'x (frame-type frame)) | |
502 | 1831 (declare-fboundp (x-init-frame-faces frame))) |
462 | 1832 ((eq 'gtk (frame-type frame)) |
502 | 1833 (declare-fboundp (gtk-init-frame-faces frame))) |
428 | 1834 ((eq 'mswindows (frame-type frame)) |
502 | 1835 (declare-fboundp (mswindows-init-frame-faces frame))) |
428 | 1836 ;; Is there anything which should be done for TTY's? |
1837 ))) | |
1838 | |
872 | 1839 ;; Called when the first device created. |
428 | 1840 |
872 | 1841 (defun init-global-faces (device) |
1842 (let ((Face-frob-property-device-considered-current device)) | |
1843 ;; Look for global face resources. | |
1844 (loop for face in (face-list) do | |
1845 (init-face-from-resources face 'global)) | |
1846 ;; Further frobbing. | |
1847 (and (featurep 'x) (declare-fboundp (x-init-global-faces))) | |
1848 (and (featurep 'gtk) (declare-fboundp (gtk-init-global-faces))) | |
1849 (and (featurep 'mswindows) (declare-fboundp (mswindows-init-global-faces))) | |
462 | 1850 |
872 | 1851 ;; for bold and the like, make the global specification be bold etc. |
1852 ;; if the user didn't already specify a value. These will also be | |
1853 ;; frobbed further in init-other-random-faces. | |
1854 (unless (face-font 'bold 'global) | |
1855 (make-face-bold 'bold 'global)) | |
1856 ;; | |
1857 (unless (face-font 'italic 'global) | |
1858 (make-face-italic 'italic 'global)) | |
1859 ;; | |
428 | 1860 (unless (face-font 'bold-italic 'global) |
872 | 1861 (make-face-bold-italic 'bold-italic 'global) |
1862 (unless (face-font 'bold-italic 'global) | |
1863 (copy-face 'bold 'bold-italic) | |
1864 (make-face-italic 'bold-italic))) | |
428 | 1865 |
872 | 1866 (when (face-equal 'bold 'bold-italic device) |
1867 (copy-face 'italic 'bold-italic) | |
1868 (make-face-bold 'bold-italic)))) | |
428 | 1869 |
1870 | |
1871 ;; These warnings are there for a reason. Just specify your fonts | |
1872 ;; correctly. Deal with it. Additionally, one can use | |
1873 ;; `log-warning-minimum-level' instead of this. | |
1874 ;(defvar inhibit-font-complaints nil | |
1875 ; "Whether to suppress complaints about incomplete sets of fonts.") | |
1876 | |
1877 (defun face-complain-about-font (face device) | |
1878 (if (symbolp face) (setq face (symbol-name face))) | |
1879 ;; (if (not inhibit-font-complaints) | |
707 | 1880 ;; complaining for printers is generally annoying. |
1881 (unless (device-printer-p device) | |
1882 (display-warning | |
1883 'font | |
1884 (let ((default-name (face-font-name 'default device))) | |
1885 (format "%s: couldn't deduce %s %s version of the font | |
428 | 1886 %S. |
1887 | |
1888 Please specify X resources to make the %s face | |
1889 visually distinguishable from the default face. | |
1890 For example, you could add one of the following to $HOME/Emacs: | |
1891 | |
2703 | 1892 XEmacs.%s.attributeFont: -dt-*-medium-i-* |
428 | 1893 or |
2703 | 1894 XEmacs.%s.attributeForeground: hotpink\n" |
707 | 1895 invocation-name |
1896 (if (string-match "\\`[aeiouAEIOU]" face) "an" "a") | |
1897 face | |
1898 default-name | |
1899 face | |
1900 face | |
1901 face | |
1902 ))))) | |
428 | 1903 |
1904 | |
1905 ;; #### This is quite a mess. We should use the custom mechanism for | |
1906 ;; most of this stuff. Currently we don't do it, because Custom | |
1907 ;; doesn't use specifiers (yet.) FSF does it the Right Way. | |
1908 | |
1909 ;; For instance, the definition of `bold' should be something like | |
1910 ;; (defface bold ((t (:bold t))) "Bold text.") -- and `:bold t' should | |
1911 ;; make sure that everything works properly. | |
1912 | |
1913 (defun init-other-random-faces (device) | |
1914 "Initialize the colors and fonts of the bold, italic, bold-italic, | |
1915 zmacs-region, list-mode-item-selected, highlight, primary-selection, | |
1916 secondary-selection, and isearch faces when each device is created. If | |
1917 you want to add code to do stuff like this, use the create-device-hook." | |
1918 | |
1919 ;; try to make 'bold look different from the default on this device. | |
1920 ;; If that doesn't work at all, then issue a warning. | |
1921 (unless (face-differs-from-default-p 'bold device) | |
1922 (make-face-bold 'bold device) | |
1923 (unless (face-differs-from-default-p 'bold device) | |
1924 (make-face-unbold 'bold device) | |
1925 (unless (face-differs-from-default-p 'bold device) | |
1926 ;; the luser specified one of the bogus font names | |
1927 (face-complain-about-font 'bold device)))) | |
1928 | |
1929 ;; Similar for italic. | |
1930 ;; It's unreasonable to expect to be able to make a font italic all | |
1931 ;; the time. For many languages, italic is an alien concept. | |
1932 ;; Basically, because italic is not a globally meaningful concept, | |
440 | 1933 ;; the use of the italic face should really be obsoleted. |
428 | 1934 |
1935 ;; I disagree with above. In many languages, the concept of capital | |
1936 ;; letters is just as alien, and yet we use them. Italic is here to | |
1937 ;; stay. -hniksic | |
1938 | |
1939 ;; In a Solaris Japanese environment, there just aren't any italic | |
1940 ;; fonts - period. CDE recognizes this reality, and fonts | |
1941 ;; -dt-interface user-medium-r-normal-*-*-*-*-*-*-*-*-* don't come | |
1942 ;; in italic versions. So we first try to make the font bold before | |
1943 ;; complaining. | |
1944 (unless (face-differs-from-default-p 'italic device) | |
1945 (make-face-italic 'italic device) | |
1946 (unless (face-differs-from-default-p 'italic device) | |
1947 (make-face-bold 'italic device) | |
1948 (unless (face-differs-from-default-p 'italic device) | |
1949 (face-complain-about-font 'italic device)))) | |
1950 | |
1951 ;; similar for bold-italic. | |
1952 (unless (face-differs-from-default-p 'bold-italic device) | |
1953 (make-face-bold-italic 'bold-italic device) | |
1954 ;; if we couldn't get a bold-italic version, try just bold. | |
1955 (unless (face-differs-from-default-p 'bold-italic device) | |
1956 (make-face-bold 'bold-italic device) | |
1957 ;; if we couldn't get bold or bold-italic, then that's probably because | |
1958 ;; the default font is bold, so make the `bold-italic' face be unbold. | |
1959 (unless (face-differs-from-default-p 'bold-italic device) | |
1960 (make-face-unbold 'bold-italic device) | |
1961 (make-face-italic 'bold-italic device) | |
1962 (unless (face-differs-from-default-p 'bold-italic device) | |
1963 ;; if that didn't work, try plain italic | |
1964 ;; (can this ever happen? what the hell.) | |
1965 (make-face-italic 'bold-italic device) | |
1966 (unless (face-differs-from-default-p 'bold-italic device) | |
1967 ;; then bitch and moan. | |
1968 (face-complain-about-font 'bold-italic device)))))) | |
1969 | |
1970 ;; Set the text-cursor colors unless already specified. | |
1971 (when (and (not (eq 'tty (device-type device))) | |
1972 (not (face-background 'text-cursor 'global)) | |
1973 (face-property-equal 'text-cursor 'default 'background device)) | |
1974 (set-face-background 'text-cursor [default foreground] 'global | |
1975 nil 'append)) | |
1976 (when (and (not (eq 'tty (device-type device))) | |
1977 (not (face-foreground 'text-cursor 'global)) | |
1978 (face-property-equal 'text-cursor 'default 'foreground device)) | |
1979 (set-face-foreground 'text-cursor [default background] 'global | |
1980 nil 'append)) | |
4741
e14f9fdd5096
Fix modeline-mousable, other faces that inherit from modeline, on startup.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4676
diff
changeset
|
1981 |
e14f9fdd5096
Fix modeline-mousable, other faces that inherit from modeline, on startup.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4676
diff
changeset
|
1982 ;; The faces buffers-tab, modeline-mousable and modeline-buffer-id all |
e14f9fdd5096
Fix modeline-mousable, other faces that inherit from modeline, on startup.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4676
diff
changeset
|
1983 ;; inherit directly from modeline; they require that modeline's details be |
e14f9fdd5096
Fix modeline-mousable, other faces that inherit from modeline, on startup.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4676
diff
changeset
|
1984 ;; specified, that it not use fallbacks, otherwise *they* use the general |
e14f9fdd5096
Fix modeline-mousable, other faces that inherit from modeline, on startup.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4676
diff
changeset
|
1985 ;; fallback of the default face instead, which clashes with the gui |
e14f9fdd5096
Fix modeline-mousable, other faces that inherit from modeline, on startup.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4676
diff
changeset
|
1986 ;; element faces. So take the modeline face information from its |
e14f9fdd5096
Fix modeline-mousable, other faces that inherit from modeline, on startup.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4676
diff
changeset
|
1987 ;; fallbacks, themselves ultimately set up in faces.c: |
e14f9fdd5096
Fix modeline-mousable, other faces that inherit from modeline, on startup.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4676
diff
changeset
|
1988 (loop |
5080
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
1989 for face-property in '(foreground background |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
1990 background-pixmap background-placement) |
4741
e14f9fdd5096
Fix modeline-mousable, other faces that inherit from modeline, on startup.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4676
diff
changeset
|
1991 do (when (and (setq face-property (face-property 'modeline face-property)) |
e14f9fdd5096
Fix modeline-mousable, other faces that inherit from modeline, on startup.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4676
diff
changeset
|
1992 (null (specifier-instance face-property device nil t)) |
e14f9fdd5096
Fix modeline-mousable, other faces that inherit from modeline, on startup.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4676
diff
changeset
|
1993 (specifier-instance face-property device)) |
e14f9fdd5096
Fix modeline-mousable, other faces that inherit from modeline, on startup.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4676
diff
changeset
|
1994 (set-specifier face-property |
e14f9fdd5096
Fix modeline-mousable, other faces that inherit from modeline, on startup.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4676
diff
changeset
|
1995 (or (specifier-specs (specifier-fallback |
e14f9fdd5096
Fix modeline-mousable, other faces that inherit from modeline, on startup.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4676
diff
changeset
|
1996 face-property)) |
e14f9fdd5096
Fix modeline-mousable, other faces that inherit from modeline, on startup.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4676
diff
changeset
|
1997 ;; This will error at startup if the |
e14f9fdd5096
Fix modeline-mousable, other faces that inherit from modeline, on startup.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4676
diff
changeset
|
1998 ;; corresponding C fallback doesn't exist, |
e14f9fdd5096
Fix modeline-mousable, other faces that inherit from modeline, on startup.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4676
diff
changeset
|
1999 ;; which is well and good. |
e14f9fdd5096
Fix modeline-mousable, other faces that inherit from modeline, on startup.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4676
diff
changeset
|
2000 (specifier-fallback (specifier-fallback |
e14f9fdd5096
Fix modeline-mousable, other faces that inherit from modeline, on startup.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4676
diff
changeset
|
2001 face-property)))))) |
e14f9fdd5096
Fix modeline-mousable, other faces that inherit from modeline, on startup.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4676
diff
changeset
|
2002 nil) |
428 | 2003 |
442 | 2004 ;; New function with 20.1, suggested by Per Abrahamsen, coded by Kyle |
2005 ;; Jones and Hrvoje Niksic. | |
428 | 2006 (defun set-face-stipple (face pixmap &optional frame) |
2007 "Change the stipple pixmap of FACE to PIXMAP. | |
2008 This is an Emacs compatibility function; consider using | |
2009 set-face-background-pixmap instead. | |
2010 | |
2011 PIXMAP should be a string, the name of a file of pixmap data. | |
442 | 2012 The directories listed in the variables `x-bitmap-file-path' and |
2013 `mswindows-bitmap-file-path' under X and MS Windows respectively | |
2014 are searched. | |
428 | 2015 |
2016 Alternatively, PIXMAP may be a list of the form (WIDTH HEIGHT | |
2017 DATA) where WIDTH and HEIGHT are the size in pixels, and DATA is | |
2018 a string, containing the raw bits of the bitmap. XBM data is | |
2019 expected in this case, other types of image data will not work. | |
2020 | |
2021 If the optional FRAME argument is provided, change only | |
2022 in that frame; otherwise change each frame." | |
2023 (while (not (find-face face)) | |
446 | 2024 (setq face (wrong-type-argument 'facep face))) |
502 | 2025 (let ((bitmap-path |
2026 (ecase (console-type) | |
2027 (x (declare-boundp x-bitmap-file-path)) | |
2028 (mswindows (declare-boundp mswindows-bitmap-file-path)))) | |
442 | 2029 instantiator) |
2030 (while | |
2031 (null | |
2032 (setq instantiator | |
2033 (cond ((stringp pixmap) | |
2034 (let ((file (if (file-name-absolute-p pixmap) | |
2035 pixmap | |
2036 (locate-file pixmap bitmap-path | |
2037 '(".xbm" ""))))) | |
2038 (and file | |
2039 `[xbm :file ,file]))) | |
2040 ((and (listp pixmap) (= (length pixmap) 3)) | |
2041 `[xbm :data ,pixmap]) | |
2042 (t nil)))) | |
2043 ;; We're signaling a continuable error; let's make sure the | |
2044 ;; function `stipple-pixmap-p' at least exists. | |
2045 (flet ((stipple-pixmap-p (pixmap) | |
2046 (or (stringp pixmap) | |
2047 (and (listp pixmap) (= (length pixmap) 3))))) | |
2048 (setq pixmap (signal 'wrong-type-argument | |
2049 (list 'stipple-pixmap-p pixmap))))) | |
446 | 2050 (check-type frame (or null frame)) |
442 | 2051 (set-face-background-pixmap face instantiator frame))) |
428 | 2052 |
2053 | |
2054 ;; Create the remaining standard faces now. This way, packages that we dump | |
2055 ;; can reference these faces as parents. | |
2056 ;; | |
2057 ;; The default, modeline, left-margin, right-margin, text-cursor, | |
2058 ;; and pointer faces are created in C. | |
2059 | |
2060 (make-face 'bold "Bold text.") | |
2061 (make-face 'italic "Italic text.") | |
2062 (make-face 'bold-italic "Bold-italic text.") | |
2063 (make-face 'underline "Underlined text.") | |
2064 (or (face-differs-from-default-p 'underline) | |
2065 (set-face-underline-p 'underline t 'global '(default))) | |
735 | 2066 (make-face 'zmacs-region "Used on highlighted region between point and mark.") |
428 | 2067 (make-face 'isearch "Used on region matched by isearch.") |
2068 (make-face 'isearch-secondary "Face to use for highlighting all matches.") | |
2069 (make-face 'list-mode-item-selected | |
2070 "Face for the selected list item in list-mode.") | |
2071 (make-face 'highlight "Highlight face.") | |
2072 (make-face 'primary-selection "Primary selection face.") | |
2073 (make-face 'secondary-selection "Secondary selection face.") | |
2074 | |
2075 ;; Several useful color faces. | |
2076 (dolist (color '(red green blue yellow)) | |
2077 (make-face color (concat (symbol-name color) " text.")) | |
2078 (set-face-foreground color (symbol-name color) nil 'color)) | |
2079 | |
2080 ;; Make some useful faces. This happens very early, before creating | |
2081 ;; the first non-stream device. | |
2082 | |
2083 (set-face-background 'text-cursor | |
711 | 2084 '(((win default) . "Red3")) |
428 | 2085 'global) |
2086 | |
2087 ;; some older X servers don't recognize "darkseagreen2" | |
2088 (set-face-background 'highlight | |
711 | 2089 '(((win default color) . "darkseagreen2") |
2090 ((win default color) . "green") | |
2091 ((win default grayscale) . "gray53")) | |
428 | 2092 'global) |
2093 (set-face-background-pixmap 'highlight | |
711 | 2094 '(((win default mono) . "gray1")) |
428 | 2095 'global) |
2096 | |
2097 (set-face-background 'zmacs-region | |
711 | 2098 '(((win default color) . "gray65") |
2099 ((win default grayscale) . "gray65")) | |
428 | 2100 'global) |
2101 (set-face-background-pixmap 'zmacs-region | |
711 | 2102 '(((win default mono) . "gray3")) |
428 | 2103 'global) |
2104 | |
2105 (set-face-background 'list-mode-item-selected | |
711 | 2106 '(((win default color) . "gray68") |
2107 ((win default grayscale) . "gray68") | |
2108 ((win default mono) . [default foreground])) | |
428 | 2109 'global) |
2110 (set-face-foreground 'list-mode-item-selected | |
711 | 2111 '(((win default mono) . [default background])) |
428 | 2112 'global) |
2113 | |
2114 (set-face-background 'primary-selection | |
711 | 2115 '(((win default color) . "gray65") |
2116 ((win default grayscale) . "gray65")) | |
428 | 2117 'global) |
2118 (set-face-background-pixmap 'primary-selection | |
711 | 2119 '(((win default mono) . "gray3")) |
428 | 2120 'global) |
2121 | |
2122 (set-face-background 'secondary-selection | |
711 | 2123 '(((win default color) . "paleturquoise") |
2124 ((win default color) . "green") | |
2125 ((win default grayscale) . "gray53")) | |
428 | 2126 'global) |
2127 (set-face-background-pixmap 'secondary-selection | |
711 | 2128 '(((win default mono) . "gray1")) |
428 | 2129 'global) |
2130 | |
2131 (set-face-background 'isearch | |
711 | 2132 '(((win default color) . "paleturquoise") |
2133 ((win default color) . "green")) | |
428 | 2134 'global) |
2135 | |
2136 ;; #### This should really, I mean *really*, be converted to some form | |
2137 ;; of `defface' one day. | |
2138 (set-face-foreground 'isearch-secondary | |
711 | 2139 '(((win default color) . "red3")) |
428 | 2140 'global) |
2141 | |
2142 ;; Define some logical color names to be used when reading the pixmap files. | |
4222 | 2143 (and-boundp |
2144 'xpm-color-symbols | |
2145 (featurep 'xpm) | |
2146 (setq xpm-color-symbols | |
2147 (list | |
2148 '("foreground" (face-foreground 'default)) | |
2149 '("background" (face-background 'default)) | |
4676
e3feb329bda9
Make the initialisation of xpm-color-symbols a bit more reasonable.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4670
diff
changeset
|
2150 `("backgroundToolBarColor" |
e3feb329bda9
Make the initialisation of xpm-color-symbols a bit more reasonable.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4670
diff
changeset
|
2151 ,(if (featurep 'x) |
e3feb329bda9
Make the initialisation of xpm-color-symbols a bit more reasonable.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4670
diff
changeset
|
2152 '(or (x-get-resource "backgroundToolBarColor" |
e3feb329bda9
Make the initialisation of xpm-color-symbols a bit more reasonable.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4670
diff
changeset
|
2153 "BackgroundToolBarColor" 'string |
e3feb329bda9
Make the initialisation of xpm-color-symbols a bit more reasonable.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4670
diff
changeset
|
2154 nil nil 'warn) |
e3feb329bda9
Make the initialisation of xpm-color-symbols a bit more reasonable.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4670
diff
changeset
|
2155 (face-background 'toolbar)) |
e3feb329bda9
Make the initialisation of xpm-color-symbols a bit more reasonable.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4670
diff
changeset
|
2156 '(face-background 'toolbar))) |
e3feb329bda9
Make the initialisation of xpm-color-symbols a bit more reasonable.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4670
diff
changeset
|
2157 `("foregroundToolBarColor" |
e3feb329bda9
Make the initialisation of xpm-color-symbols a bit more reasonable.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4670
diff
changeset
|
2158 ,(if (featurep 'x) |
e3feb329bda9
Make the initialisation of xpm-color-symbols a bit more reasonable.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4670
diff
changeset
|
2159 '(or (x-get-resource "foregroundToolBarColor" |
e3feb329bda9
Make the initialisation of xpm-color-symbols a bit more reasonable.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4670
diff
changeset
|
2160 "ForegroundToolBarColor" 'string |
e3feb329bda9
Make the initialisation of xpm-color-symbols a bit more reasonable.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4670
diff
changeset
|
2161 nil nil 'warn) |
e3feb329bda9
Make the initialisation of xpm-color-symbols a bit more reasonable.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4670
diff
changeset
|
2162 (face-foreground 'toolbar)) |
e3feb329bda9
Make the initialisation of xpm-color-symbols a bit more reasonable.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4670
diff
changeset
|
2163 '(face-foreground 'toolbar)))))) |
428 | 2164 |
2165 (when (featurep 'tty) | |
2166 (set-face-highlight-p 'bold t 'global '(default tty)) | |
2167 (set-face-underline-p 'italic t 'global '(default tty)) | |
2168 (set-face-highlight-p 'bold-italic t 'global '(default tty)) | |
2169 (set-face-underline-p 'bold-italic t 'global '(default tty)) | |
2170 (set-face-highlight-p 'highlight t 'global '(default tty)) | |
2171 (set-face-reverse-p 'text-cursor t 'global '(default tty)) | |
2172 (set-face-reverse-p 'modeline t 'global '(default tty)) | |
2173 (set-face-reverse-p 'zmacs-region t 'global '(default tty)) | |
2174 (set-face-reverse-p 'primary-selection t 'global '(default tty)) | |
2175 (set-face-underline-p 'secondary-selection t 'global '(default tty)) | |
2176 (set-face-reverse-p 'list-mode-item-selected t 'global '(default tty)) | |
2177 (set-face-reverse-p 'isearch t 'global '(default tty)) | |
2178 ) | |
2179 | |
2180 ;;; faces.el ends here |