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