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