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