0
|
1 ;;; faces.el --- Lisp interface to the C "face" structure
|
|
2
|
|
3 ;; Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc.
|
|
4 ;; Copyright (C) 1995 Board of Trustees, University of Illinois
|
|
5 ;; Copyright (C) 1995, 1996 Ben Wing
|
|
6
|
|
7 ;; Author: Ben Wing <wing@666.com>
|
|
8 ;; Keywords: faces internal
|
|
9 ;;
|
|
10 ;; face implementation #1 (used Lisp vectors and parallel C vectors;
|
|
11 ;; FSFmacs still uses this) authored by Jamie Zawinski <jwz@netscape.com>
|
|
12 ;; pre Lucid-Emacs 19.0.
|
|
13 ;;
|
|
14 ;; face implementation #2 (used one face object per frame per face)
|
|
15 ;; authored by Jamie Zawinkski for 19.9.
|
|
16 ;;
|
|
17 ;; face implementation #3 (use one face object per face) originally
|
|
18 ;; authored for 19.12 by Chuck Thompson <cthomp@cs.uiuc.edu>,
|
|
19 ;; rewritten by Ben Wing with the advent of specifiers.
|
|
20
|
|
21 ;; This file is part of XEmacs.
|
|
22
|
|
23 ;; XEmacs is free software; you can redistribute it and/or modify it
|
|
24 ;; under the terms of the GNU General Public License as published by
|
|
25 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
26 ;; any later version.
|
|
27
|
|
28 ;; XEmacs is distributed in the hope that it will be useful, but
|
|
29 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
30 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
31 ;; General Public License for more details.
|
|
32
|
|
33 ;; You should have received a copy of the GNU General Public License
|
16
|
34 ;; along with XEmacs; see the file COPYING. If not, write to the
|
|
35 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
36 ;; Boston, MA 02111-1307, USA.
|
0
|
37
|
|
38 ;;; Synched up with: Not synched with FSF. Almost completely divergent.
|
|
39 ;;; Some stuff in FSF's faces.el is in our x-faces.el.
|
|
40
|
|
41 (defun read-face-name (prompt)
|
|
42 (let (face)
|
|
43 (while (= (length face) 0) ; nil or ""
|
|
44 (setq face (completing-read prompt
|
2
|
45 (mapcar (lambda (x) (list (symbol-name x)))
|
0
|
46 (face-list))
|
|
47 nil t)))
|
|
48 (intern face)))
|
|
49
|
|
50 (defun face-interactive (what &optional bool)
|
|
51 (let* ((fn (intern (concat "face-" what "-instance")))
|
|
52 (face (read-face-name (format "Set %s of face: " what)))
|
|
53 (default (if (fboundp fn)
|
|
54 ;; #### we should distinguish here between
|
|
55 ;; explicitly setting the value to be the
|
|
56 ;; same as the default face's value, and
|
|
57 ;; not setting a value at all.
|
|
58 (funcall fn face)))
|
|
59 (value (if bool
|
|
60 (y-or-n-p (format "Should face %s be %s? "
|
|
61 (symbol-name face) bool))
|
|
62 (read-string (format "Set %s of face %s to: "
|
|
63 what (symbol-name face))
|
|
64 (cond ((font-instance-p default)
|
|
65 (font-instance-name default))
|
|
66 ((color-instance-p default)
|
|
67 (color-instance-name default))
|
|
68 ((image-instance-p default)
|
|
69 (image-instance-file-name default))
|
|
70 (t default))))))
|
|
71 (list face (if (equal value "") nil value))))
|
|
72
|
|
73 (defconst built-in-face-specifiers
|
|
74 (built-in-face-specifiers)
|
|
75 "A list of the built-in face properties that are specifiers.")
|
|
76
|
|
77 (defun face-property (face property &optional locale tag-set exact-p)
|
|
78 "Return FACE's value of the given PROPERTY.
|
|
79
|
|
80 If LOCALE is omitted, the FACE's actual value for PROPERTY will be
|
|
81 returned. For built-in properties, this will be a specifier object
|
|
82 of a type appropriate to the property (e.g. a font or color
|
|
83 specifier). For other properties, this could be anything.
|
|
84
|
|
85 If LOCALE is supplied, then instead of returning the actual value,
|
|
86 the specification(s) for the given locale or locale type will
|
|
87 be returned. This will only work if the actual value of
|
|
88 PROPERTY is a specifier (this will always be the case for built-in
|
|
89 properties, but not or not may apply to user-defined properties).
|
|
90 If the actual value of PROPERTY is not a specifier, this value
|
|
91 will simply be returned regardless of LOCALE.
|
|
92
|
|
93 The return value will be a list of instantiators (e.g. strings
|
|
94 specifying a font or color name), or a list of specifications, each
|
|
95 of which is a cons of a locale and a list of instantiators.
|
|
96 Specifically, if LOCALE is a particular locale (a buffer, window,
|
|
97 frame, device, or 'global), a list of instantiators for that locale
|
|
98 will be returned. Otherwise, if LOCALE is a locale type (one of
|
|
99 the symbols 'buffer, 'window, 'frame, or 'device), the specifications
|
|
100 for all locales of that type will be returned. Finally, if LOCALE is
|
|
101 'all, the specifications for all locales of all types will be returned.
|
|
102
|
|
103 The specifications in a specifier determine what the value of
|
|
104 PROPERTY will be in a particular \"domain\" or set of circumstances,
|
|
105 which is typically a particular Emacs window along with the buffer
|
|
106 it contains and the frame and device it lies within. The value
|
|
107 is derived from the instantiator associated with the most specific
|
|
108 locale (in the order buffer, window, frame, device, and 'global)
|
|
109 that matches the domain in question. In other words, given a domain
|
|
110 (i.e. an Emacs window, usually), the specifier for PROPERTY will first
|
|
111 be searched for a specification whose locale is the buffer contained
|
|
112 within that window; then for a specification whose locale is the window
|
|
113 itself; then for a specification whose locale is the frame that the
|
|
114 window is contained within; etc. The first instantiator that is
|
|
115 valid for the domain (usually this means that the instantiator is
|
|
116 recognized by the device [i.e. the X server or TTY device] that the
|
|
117 domain is on. The function `face-property-instance' actually does
|
|
118 all this, and is used to determine how to display the face.
|
|
119
|
|
120 See `set-face-property' for the built-in property-names."
|
|
121
|
|
122 (or (facep face) (setq face (get-face face)))
|
|
123 (let ((value (get face property)))
|
|
124 (if (and locale
|
|
125 (or (memq property built-in-face-specifiers)
|
|
126 (specifierp value)))
|
|
127 (setq value (specifier-specs value locale tag-set exact-p)))
|
|
128 value))
|
|
129
|
|
130 (defun convert-face-property-into-specifier (face property)
|
|
131 "Convert PROPERTY on FACE into a specifier, if it's not already."
|
|
132 (setq face (get-face face))
|
|
133 (let ((specifier (get face property)))
|
|
134 ;; if a user-property does not have a specifier but a
|
|
135 ;; locale was specified, put a specifier there.
|
|
136 ;; If there was already a value there, convert it to a
|
|
137 ;; specifier with the value as its 'global instantiator.
|
|
138 (if (not (specifierp specifier))
|
|
139 (let ((new-specifier (make-specifier 'generic)))
|
|
140 (if (or (not (null specifier))
|
|
141 ;; make sure the nil returned from `get' wasn't
|
|
142 ;; actually the value of the property
|
|
143 (null (get face property t)))
|
|
144 (add-spec-to-specifier new-specifier specifier))
|
|
145 (setq specifier new-specifier)
|
|
146 (put face property specifier)))))
|
|
147
|
|
148 (defun face-property-instance (face property
|
|
149 &optional domain default no-fallback)
|
|
150 "Return the instance of FACE's PROPERTY in the specified DOMAIN.
|
|
151
|
|
152 Under most circumstances, DOMAIN will be a particular window,
|
|
153 and the returned instance describes how the specified property
|
|
154 actually is displayed for that window and the particular buffer
|
|
155 in it. Note that this may not be the same as how the property
|
|
156 appears when the buffer is displayed in a different window or
|
|
157 frame, or how the property appears in the same window if you
|
|
158 switch to another buffer in that window; and in those cases,
|
|
159 the returned instance would be different.
|
|
160
|
|
161 The returned instance will typically be a color-instance,
|
|
162 font-instance, or pixmap-instance object, and you can query
|
|
163 it using the appropriate object-specific functions. For example,
|
|
164 you could use `color-instance-rgb-components' to find out the
|
|
165 RGB (red, green, and blue) components of how the 'background
|
|
166 property of the 'highlight face is displayed in a particular
|
|
167 window. The results might be different from the results
|
|
168 you would get for another window (perhaps the user
|
|
169 specified a different color for the frame that window is on;
|
|
170 or perhaps the same color was specified but the window is
|
|
171 on a different X server, and that X server has different RGB
|
|
172 values for the color from this one).
|
|
173
|
|
174 DOMAIN defaults to the selected window if omitted.
|
|
175
|
|
176 DOMAIN can be a frame or device, instead of a window. The value
|
|
177 returned for a such a domain is used in special circumstances
|
|
178 when a more specific domain does not apply; for example, a frame
|
|
179 value might be used for coloring a toolbar, which is conceptually
|
|
180 attached to a frame rather than a particular window. The value
|
|
181 is also useful in determining what the value would be for a
|
|
182 particular window within the frame or device, if it is not
|
|
183 overridden by a more specific specification.
|
|
184
|
|
185 If PROPERTY does not name a built-in property, its value will
|
|
186 simply be returned unless it is a specifier object, in which case
|
|
187 it will be instanced using `specifier-instance'.
|
|
188
|
|
189 Optional arguments DEFAULT and NO-FALLBACK are the same as in
|
|
190 `specifier-instance'."
|
|
191
|
|
192 (or (facep face) (setq face (get-face face)))
|
|
193 (let ((value (get face property)))
|
|
194 (if (specifierp value)
|
|
195 (setq value (specifier-instance value domain default no-fallback)))
|
|
196 value))
|
|
197
|
|
198 (defun face-property-matching-instance (face property matchspec
|
|
199 &optional domain default
|
|
200 no-fallback)
|
|
201 "Return the instance of FACE's PROPERTY matching MATCHSPEC in DOMAIN.
|
|
202 Currently the only useful value for MATCHSPEC is a charset, when used
|
|
203 in conjunction with the face's font; this allows you to retrieve a
|
|
204 font that can be used to display a particular charset, rather than just
|
|
205 any font.
|
|
206
|
|
207 Other than MATCHSPEC, this function is identical to `face-property-instance'.
|
|
208 See also `specifier-matching-instance' for a fuller description of the
|
|
209 matching process."
|
|
210
|
|
211 (or (facep face) (setq face (get-face face)))
|
|
212 (let ((value (get face property)))
|
|
213 (if (specifierp value)
|
|
214 (setq value (specifier-matching-instance value matchspec domain
|
|
215 default no-fallback)))
|
|
216 value))
|
|
217
|
|
218 (defun set-face-property (face property value &optional locale tag-set
|
|
219 how-to-add)
|
|
220 "Change a property of a FACE.
|
|
221
|
|
222 NOTE: If you want to remove a property from a face, use `remove-face-property'
|
|
223 rather than attempting to set a value of nil for the property.
|
|
224
|
|
225 For built-in properties, the actual value of the property is a
|
|
226 specifier and you cannot change this; but you can change the
|
|
227 specifications within the specifier, and that is what this function
|
|
228 will do. For user-defined properties, you can use this function
|
|
229 to either change the actual value of the property or, if this value
|
|
230 is a specifier, change the specifications within it.
|
|
231
|
|
232 If PROPERTY is a built-in property, the specifications to be added to
|
|
233 this property can be supplied in many different ways:
|
|
234
|
|
235 -- If VALUE is a simple instantiator (e.g. a string naming a font or
|
|
236 color) or a list of instantiators, then the instantiator(s) will
|
|
237 be added as a specification of the property for the given LOCALE
|
|
238 (which defaults to 'global if omitted).
|
|
239 -- If VALUE is a list of specifications (each of which is a cons of
|
|
240 a locale and a list of instantiators), then LOCALE must be nil
|
|
241 (it does not make sense to explicitly specify a locale in this
|
|
242 case), and specifications will be added as given.
|
|
243 -- If VALUE is a specifier (as would be returned by `face-property'
|
|
244 if no LOCALE argument is given), then some or all of the
|
|
245 specifications in the specifier will be added to the property.
|
|
246 In this case, the function is really equivalent to
|
|
247 `copy-specifier' and LOCALE has the same semantics (if it is
|
|
248 a particular locale, the specification for the locale will be
|
|
249 copied; if a locale type, specifications for all locales of
|
|
250 that type will be copied; if nil or 'all, then all
|
|
251 specifications will be copied).
|
|
252
|
|
253 HOW-TO-ADD should be either nil or one of the symbols 'prepend,
|
|
254 'append, 'remove-tag-set-prepend, 'remove-tag-set-append, 'remove-locale,
|
|
255 'remove-locale-type, or 'remove-all. See `copy-specifier' and
|
|
256 `add-spec-to-specifier' for a description of what each of
|
|
257 these means. Most of the time, you do not need to worry about
|
|
258 this argument; the default behavior usually is fine.
|
|
259
|
|
260 In general, it is OK to pass an instance object (e.g. as returned
|
|
261 by `face-property-instance') as an instantiator in place of
|
|
262 an actual instantiator. In such a case, the instantiator used
|
|
263 to create that instance object will be used (for example, if
|
|
264 you set a font-instance object as the value of the 'font
|
|
265 property, then the font name used to create that object will
|
|
266 be used instead). If some cases, however, doing this
|
|
267 conversion does not make sense, and this will be noted in
|
|
268 the documentation for particular types of instance objects.
|
|
269
|
|
270 If PROPERTY is not a built-in property, then this function will
|
|
271 simply set its value if LOCALE is nil. However, if LOCALE is
|
|
272 given, then this function will attempt to add VALUE as the
|
|
273 instantiator for the given LOCALE, using `add-spec-to-specifier'.
|
|
274 If the value of the property is not a specifier, it will
|
|
275 automatically be converted into a 'generic specifier.
|
|
276
|
|
277
|
|
278 The following symbols have predefined meanings:
|
|
279
|
|
280 foreground The foreground color of the face.
|
|
281 For valid instantiators, see `color-specifier-p'.
|
|
282
|
|
283 background The background color of the face.
|
|
284 For valid instantiators, see `color-specifier-p'.
|
|
285
|
|
286 font The font used to display text covered by this face.
|
|
287 For valid instantiators, see `font-specifier-p'.
|
|
288
|
|
289 display-table The display table of the face.
|
|
290 This should be a vector of 256 elements.
|
|
291
|
|
292 background-pixmap The pixmap displayed in the background of the face.
|
|
293 Only used by faces on X devices.
|
|
294 For valid instantiators, see `image-specifier-p'.
|
|
295
|
|
296 underline Underline all text covered by this face.
|
|
297 For valid instantiators, see `face-boolean-specifier-p'.
|
|
298
|
|
299 strikethru Draw a line through all text covered by this face.
|
|
300 For valid instantiators, see `face-boolean-specifier-p'.
|
|
301
|
|
302 highlight Highlight all text covered by this face.
|
|
303 Only used by faces on TTY devices.
|
|
304 For valid instantiators, see `face-boolean-specifier-p'.
|
|
305
|
|
306 dim Dim all text covered by this face.
|
|
307 Only used by faces on TTY devices.
|
|
308 For valid instantiators, see `face-boolean-specifier-p'.
|
|
309
|
|
310 blinking Blink all text covered by this face.
|
|
311 Only used by faces on TTY devices.
|
|
312 For valid instantiators, see `face-boolean-specifier-p'.
|
|
313
|
|
314 reverse Reverse the foreground and background colors.
|
|
315 Only used by faces on TTY devices.
|
|
316 For valid instantiators, see `face-boolean-specifier-p'.
|
|
317
|
|
318 doc-string Description of what the face's normal use is.
|
|
319 NOTE: This is not a specifier, unlike all
|
|
320 the other built-in properties, and cannot
|
|
321 contain locale-specific values."
|
|
322
|
|
323 (or (facep face) (setq face (get-face face)))
|
|
324 (if (memq property built-in-face-specifiers)
|
|
325 (set-specifier (get face property) value locale tag-set how-to-add)
|
|
326
|
|
327 ;; This section adds user defined properties.
|
|
328 (if (not locale)
|
|
329 (put face property value)
|
|
330 (convert-face-property-into-specifier face property)
|
|
331 (add-spec-to-specifier (get face property) value locale tag-set
|
|
332 how-to-add)))
|
|
333 value)
|
|
334
|
|
335 (defun remove-face-property (face property &optional locale tag-set exact-p)
|
|
336 "Remove a property from a face.
|
|
337 For built-in properties, this is analogous to `remove-specifier'.
|
|
338 See `remove-specifier' for the meaning of the LOCALE, TAG-SET, and EXACT-P
|
|
339 arguments."
|
|
340 (or locale (setq locale 'all))
|
|
341 (if (memq property built-in-face-specifiers)
|
|
342 (remove-specifier (face-property face property) locale tag-set exact-p)
|
|
343 (if (eq locale 'all)
|
|
344 (remprop (get-face face) property)
|
|
345 (convert-face-property-into-specifier face property)
|
|
346 (remove-specifier (face-property face property) locale tag-set
|
|
347 exact-p))))
|
|
348
|
|
349 (defun reset-face (face)
|
|
350 "Clear all existing built-in specifications from FACE.
|
|
351 This makes FACE inherit all its display properties from 'default.
|
|
352 WARNING: Be absolutely sure you want to do this!!! It is a dangerous
|
|
353 operation and is not undoable."
|
|
354 (mapcar #'(lambda (x)
|
|
355 (remove-specifier (face-property face x)))
|
|
356 built-in-face-specifiers)
|
|
357 nil)
|
|
358
|
|
359 (defun set-face-parent (face parent &optional locale tag-set how-to-add)
|
|
360 "Set the parent of FACE to PARENT, for all properties.
|
|
361 This makes all properties of FACE inherit from PARENT."
|
|
362 (setq parent (get-face parent))
|
|
363 (mapcar #'(lambda (x)
|
|
364 (set-face-property face x (vector parent) locale tag-set
|
|
365 how-to-add))
|
|
366 (delq 'display-table
|
|
367 (delq 'background-pixmap
|
|
368 (copy-sequence built-in-face-specifiers))))
|
|
369 (set-face-background-pixmap face (vector 'inherit ':face parent)
|
|
370 locale tag-set how-to-add)
|
|
371 nil)
|
|
372
|
|
373 (defun face-doc-string (face)
|
|
374 "Return the documentation string for FACE."
|
|
375 (face-property face 'doc-string))
|
|
376
|
|
377 (defun set-face-doc-string (face doc-string)
|
|
378 "Change the documentation string of FACE to DOC-STRING."
|
|
379 (interactive (face-interactive "doc-string"))
|
|
380 (set-face-property face 'doc-string doc-string))
|
|
381
|
|
382 (defun face-font-name (face &optional domain charset)
|
|
383 "Return the font name of the given face, or nil if it is unspecified.
|
|
384 DOMAIN is as in `face-font-instance'."
|
|
385 (let ((f (face-font-instance face domain charset)))
|
|
386 (and f (font-instance-name f))))
|
|
387
|
|
388 (defun face-font (face &optional locale tag-set exact-p)
|
|
389 "Return the font of the given face, or nil if it is unspecified.
|
|
390
|
|
391 FACE may be either a face object or a symbol representing a face.
|
|
392
|
|
393 LOCALE may be a locale (the instantiators for that particular locale
|
|
394 will be returned), a locale type (the specifications for all locales
|
|
395 of that type will be returned), 'all (all specifications will be
|
|
396 returned), or nil (the actual specifier object will be returned).
|
|
397
|
|
398 See `face-property' for more information."
|
|
399 (face-property face 'font locale tag-set exact-p))
|
|
400
|
|
401 (defun face-font-instance (face &optional domain charset)
|
|
402 "Return the instance of the given face's font in the given domain.
|
|
403
|
|
404 FACE may be either a face object or a symbol representing a face.
|
|
405
|
|
406 Normally DOMAIN will be a window or nil (meaning the selected window),
|
|
407 and an instance object describing how the font appears in that
|
|
408 particular window and buffer will be returned.
|
|
409
|
|
410 See `face-property-instance' for more information."
|
|
411 (if charset
|
|
412 (face-property-matching-instance face 'font charset domain)
|
|
413 (face-property-instance face 'font domain)))
|
|
414
|
|
415 (defun set-face-font (face font &optional locale tag-set how-to-add)
|
|
416 "Change the font of the given face.
|
|
417
|
|
418 FACE may be either a face object or a symbol representing a face.
|
|
419
|
|
420 FONT should be an instantiator (see `font-specifier-p'), a list of
|
|
421 instantiators, an alist of specifications (each mapping a
|
|
422 locale to an instantiator list), or a font specifier object.
|
|
423
|
|
424 If FONT is an alist, LOCALE must be omitted. If FONT is a
|
|
425 specifier object, LOCALE can be a locale, a locale type, 'all,
|
|
426 or nil; see `copy-specifier' for its semantics. Otherwise LOCALE
|
|
427 specifies the locale under which the specified instantiator(s)
|
|
428 will be added, and defaults to 'global.
|
|
429
|
|
430 See `set-face-property' for more information."
|
|
431 (interactive (face-interactive "font"))
|
|
432 (set-face-property face 'font font locale tag-set how-to-add))
|
|
433
|
|
434 (defun face-foreground (face &optional locale tag-set exact-p)
|
|
435 "Return the foreground of the given face, or nil if it is unspecified.
|
|
436
|
|
437 FACE may be either a face object or a symbol representing a face.
|
|
438
|
|
439 LOCALE may be a locale (the instantiators for that particular locale
|
|
440 will be returned), a locale type (the specifications for all locales
|
|
441 of that type will be returned), 'all (all specifications will be
|
|
442 returned), or nil (the actual specifier object will be returned).
|
|
443
|
|
444 See `face-property' for more information."
|
|
445 (face-property face 'foreground locale tag-set exact-p))
|
|
446
|
|
447 (defun face-foreground-instance (face &optional domain default no-fallback)
|
|
448 "Return the instance of the given face's foreground in the given domain.
|
|
449
|
|
450 FACE may be either a face object or a symbol representing a face.
|
|
451
|
|
452 Normally DOMAIN will be a window or nil (meaning the selected window),
|
|
453 and an instance object describing how the foreground appears in that
|
|
454 particular window and buffer will be returned.
|
|
455
|
|
456 See `face-property-instance' for more information."
|
|
457 (face-property-instance face 'foreground domain default no-fallback))
|
|
458
|
|
459 (defun set-face-foreground (face color &optional locale tag-set how-to-add)
|
|
460 "Change the foreground of the given face.
|
|
461
|
|
462 FACE may be either a face object or a symbol representing a face.
|
|
463
|
|
464 COLOR should be an instantiator (see `color-specifier-p'), a list of
|
|
465 instantiators, an alist of specifications (each mapping a locale to
|
|
466 an instantiator list), or a color specifier object.
|
|
467
|
|
468 If COLOR is an alist, LOCALE must be omitted. If COLOR is a
|
|
469 specifier object, LOCALE can be a locale, a locale type, 'all,
|
|
470 or nil; see `copy-specifier' for its semantics. Otherwise LOCALE
|
|
471 specifies the locale under which the specified instantiator(s)
|
|
472 will be added, and defaults to 'global.
|
|
473
|
|
474 See `set-face-property' for more information."
|
|
475 (interactive (face-interactive "foreground"))
|
|
476 (set-face-property face 'foreground color locale tag-set how-to-add))
|
|
477
|
|
478 (defun face-background (face &optional locale tag-set exact-p)
|
|
479 "Return the background of the given face, or nil if it is unspecified.
|
|
480
|
|
481 FACE may be either a face object or a symbol representing a face.
|
|
482
|
|
483 LOCALE may be a locale (the instantiators for that particular locale
|
|
484 will be returned), a locale type (the specifications for all locales
|
|
485 of that type will be returned), 'all (all specifications will be
|
|
486 returned), or nil (the actual specifier object will be returned).
|
|
487
|
|
488 See `face-property' for more information."
|
|
489 (face-property face 'background locale tag-set exact-p))
|
|
490
|
|
491 (defun face-background-instance (face &optional domain default no-fallback)
|
|
492 "Return the instance of the given face's background in the given 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 (face-property-instance face 'background domain default no-fallback))
|
|
502
|
|
503 (defun set-face-background (face color &optional locale tag-set how-to-add)
|
|
504 "Change the background of the given face.
|
|
505
|
|
506 FACE may be either a face object or a symbol representing a face.
|
|
507
|
|
508 COLOR should be an instantiator (see `color-specifier-p'), a list of
|
|
509 instantiators, an alist of specifications (each mapping a locale to
|
|
510 an instantiator list), or a color specifier object.
|
|
511
|
|
512 If COLOR is an alist, LOCALE must be omitted. If COLOR is a
|
|
513 specifier object, LOCALE can be a locale, a locale type, 'all,
|
|
514 or nil; see `copy-specifier' for its semantics. Otherwise LOCALE
|
|
515 specifies the locale under which the specified instantiator(s)
|
|
516 will be added, and defaults to 'global.
|
|
517
|
|
518 See `set-face-property' for more information."
|
|
519 (interactive (face-interactive "background"))
|
|
520 (set-face-property face 'background color locale tag-set how-to-add))
|
|
521
|
|
522 (defun face-background-pixmap (face &optional locale tag-set exact-p)
|
|
523 "Return the background pixmap of the given face, or nil if it is unspecified.
|
|
524 This property is only used on X devices.
|
|
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-pixmap locale tag-set exact-p))
|
|
535
|
|
536 (defun face-background-pixmap-instance (face &optional domain default
|
|
537 no-fallback)
|
|
538 "Return the instance of the given face's background pixmap in the given domain.
|
|
539
|
|
540 FACE may be either a face object or a symbol representing a face.
|
|
541
|
|
542 Normally DOMAIN will be a window or nil (meaning the selected window),
|
|
543 and an instance object describing how the background appears in that
|
|
544 particular window and buffer will be returned.
|
|
545
|
|
546 See `face-property-instance' for more information."
|
|
547 (face-property-instance face 'background-pixmap domain default no-fallback))
|
|
548
|
|
549 (defun set-face-background-pixmap (face pixmap &optional locale tag-set
|
|
550 how-to-add)
|
|
551 "Change the background pixmap of the given face.
|
|
552 This property is only used on X devices.
|
|
553
|
|
554 FACE may be either a face object or a symbol representing a face.
|
|
555
|
|
556 PIXMAP should be an instantiator (see `image-specifier-p'), a list
|
|
557 of instantiators, an alist of specifications (each mapping a locale
|
|
558 to an instantiator list), or an image specifier object.
|
|
559
|
|
560 If PIXMAP is an alist, LOCALE must be omitted. If PIXMAP is a
|
|
561 specifier object, LOCALE can be a locale, a locale type, 'all,
|
|
562 or nil; see `copy-specifier' for its semantics. Otherwise LOCALE
|
|
563 specifies the locale under which the specified instantiator(s)
|
|
564 will be added, and defaults to 'global.
|
|
565
|
|
566 See `set-face-property' for more information."
|
|
567 (interactive (face-interactive "background-pixmap"))
|
|
568 (set-face-property face 'background-pixmap pixmap locale tag-set how-to-add))
|
|
569
|
|
570 (defun face-display-table (face &optional locale tag-set exact-p)
|
|
571 "Return the display table of the given face.
|
|
572
|
|
573 A vector (as returned by `make-display-table') will be returned.
|
|
574
|
|
575 LOCALE may be a locale (the instantiators for that particular locale
|
|
576 will be returned), a locale type (the specifications for all locales
|
|
577 of that type will be returned), 'all (all specifications will be
|
|
578 returned), or nil (the actual specifier object will be returned).
|
|
579
|
|
580 See `face-property' for more information."
|
|
581 (face-property face 'display-table locale tag-set exact-p))
|
|
582
|
|
583 (defun face-display-table-instance (face &optional domain default no-fallback)
|
|
584 "Return the instance of FACE's display table in DOMAIN.
|
|
585 A vector (as returned by `make-display-table') will be returned.
|
|
586
|
|
587 See `face-property-instance' for the semantics of the DOMAIN argument."
|
|
588 (face-property-instance face 'display-table domain default no-fallback))
|
|
589
|
|
590 (defun set-face-display-table (face display-table &optional locale tag-set
|
|
591 how-to-add)
|
|
592 "Change the display table of the given face.
|
|
593 DISPLAY-TABLE should be a vector as returned by `make-display-table'.
|
|
594
|
|
595 See `set-face-property' for the semantics of the LOCALE, TAG-SET, and
|
|
596 HOW-TO-ADD arguments."
|
|
597 (interactive (face-interactive "display-table"))
|
|
598 (set-face-property face 'display-table display-table locale tag-set
|
|
599 how-to-add))
|
|
600
|
|
601 (defun face-underline-p (face &optional domain default no-fallback)
|
|
602 "Return whether the given face is underlined.
|
|
603 See `face-property-instance' for the semantics of the DOMAIN argument."
|
|
604 (face-property-instance face 'underline domain default no-fallback))
|
|
605
|
|
606 (defun set-face-underline-p (face underline-p &optional locale tag-set
|
|
607 how-to-add)
|
|
608 "Change whether the given face is underlined.
|
|
609 UNDERLINE-P is normally a face-boolean instantiator; see
|
|
610 `face-boolean-specifier-p'.
|
|
611 See `set-face-property' for the semantics of the LOCALE, TAG-SET, and
|
|
612 HOW-TO-ADD arguments."
|
|
613 (interactive (face-interactive "underline-p" "underlined"))
|
|
614 (set-face-property face 'underline underline-p locale tag-set how-to-add))
|
|
615
|
|
616 (defun face-strikethru-p (face &optional domain default no-fallback)
|
|
617 "Return whether the given face is strikethru-d (i.e. struck through).
|
|
618 See `face-property-instance' for the semantics of the DOMAIN argument."
|
|
619 (face-property-instance face 'strikethru domain default no-fallback))
|
|
620
|
|
621 (defun set-face-strikethru-p (face strikethru-p &optional locale tag-set
|
|
622 how-to-add)
|
|
623 "Change whether the given face is strikethru-d (i.e. struck through).
|
|
624 STRIKETHRU-P is normally a face-boolean instantiator; see
|
|
625 `face-boolean-specifier-p'.
|
|
626 See `set-face-property' for the semantics of the LOCALE, TAG-SET, and
|
|
627 HOW-TO-ADD arguments."
|
|
628 (interactive (face-interactive "strikethru-p" "strikethru-d"))
|
|
629 (set-face-property face 'strikethru strikethru-p locale tag-set how-to-add))
|
|
630
|
|
631 (defun face-highlight-p (face &optional domain default no-fallback)
|
|
632 "Return whether the given face is highlighted (TTY domains only).
|
|
633 See `face-property-instance' for the semantics of the DOMAIN argument."
|
|
634 (face-property-instance face 'highlight domain default no-fallback))
|
|
635
|
|
636 (defun set-face-highlight-p (face highlight-p &optional locale tag-set
|
|
637 how-to-add)
|
|
638 "Change whether the given face is highlighted (TTY locales only).
|
|
639 HIGHLIGHT-P is normally a face-boolean instantiator; see
|
|
640 `face-boolean-specifier-p'.
|
|
641 See `set-face-property' for the semantics of the LOCALE, TAG-SET, and
|
|
642 HOW-TO-ADD arguments."
|
|
643 (interactive (face-interactive "highlight-p" "highlighted"))
|
|
644 (set-face-property face 'highlight highlight-p locale tag-set how-to-add))
|
|
645
|
|
646 (defun face-dim-p (face &optional domain default no-fallback)
|
|
647 "Return whether the given face is dimmed (TTY domains only).
|
|
648 See `face-property-instance' for the semantics of the DOMAIN argument."
|
|
649 (face-property-instance face 'dim domain default no-fallback))
|
|
650
|
|
651 (defun set-face-dim-p (face dim-p &optional locale tag-set how-to-add)
|
|
652 "Change whether the given face is dimmed (TTY locales only).
|
|
653 DIM-P is normally a face-boolean instantiator; see
|
|
654 `face-boolean-specifier-p'.
|
|
655 See `set-face-property' for the semantics of the LOCALE, TAG-SET, and
|
|
656 HOW-TO-ADD arguments."
|
|
657 (interactive (face-interactive "dim-p" "dimmed"))
|
|
658 (set-face-property face 'dim dim-p locale tag-set how-to-add))
|
|
659
|
|
660 (defun face-blinking-p (face &optional domain default no-fallback)
|
|
661 "Return whether the given face is blinking (TTY domains only).
|
|
662 See `face-property-instance' for the semantics of the DOMAIN argument."
|
|
663 (face-property-instance face 'blinking domain default no-fallback))
|
|
664
|
|
665 (defun set-face-blinking-p (face blinking-p &optional locale tag-set
|
|
666 how-to-add)
|
|
667 "Change whether the given face is blinking (TTY locales only).
|
|
668 BLINKING-P is normally a face-boolean instantiator; see
|
|
669 `face-boolean-specifier-p'.
|
|
670 See `set-face-property' for the semantics of the LOCALE, TAG-SET, and
|
|
671 HOW-TO-ADD arguments."
|
|
672 (interactive (face-interactive "blinking-p" "blinking"))
|
|
673 (set-face-property face 'blinking blinking-p locale tag-set how-to-add))
|
|
674
|
|
675 (defun face-reverse-p (face &optional domain default no-fallback)
|
|
676 "Return whether the given face is reversed (TTY domains only).
|
|
677 See `face-property-instance' for the semantics of the DOMAIN argument."
|
|
678 (face-property-instance face 'reverse domain default no-fallback))
|
|
679
|
|
680 (defun set-face-reverse-p (face reverse-p &optional locale tag-set how-to-add)
|
|
681 "Change whether the given face is reversed (TTY locales only).
|
|
682 REVERSE-P is normally a face-boolean instantiator; see
|
|
683 `face-boolean-specifier-p'.
|
|
684 See `set-face-property' for the semantics of the LOCALE, TAG-SET, and
|
|
685 HOW-TO-ADD arguments."
|
|
686 (interactive (face-interactive "reverse-p" "reversed"))
|
|
687 (set-face-property face 'reverse reverse-p locale tag-set how-to-add))
|
|
688
|
|
689
|
|
690 (defun face-property-equal (face1 face2 prop domain)
|
|
691 (equal (face-property-instance face1 prop domain)
|
|
692 (face-property-instance face2 prop domain)))
|
|
693
|
|
694 (defun face-equal-loop (props face1 face2 domain)
|
|
695 (while (and props
|
|
696 (face-property-equal face1 face2 (car props) domain))
|
|
697 (setq props (cdr props)))
|
|
698 (null props))
|
|
699
|
|
700 (defun face-equal (face1 face2 &optional domain)
|
2
|
701 "True if the given faces will display in the same way.
|
0
|
702 See `face-property-instance' for the semantics of the DOMAIN argument."
|
|
703 (if (null domain) (setq domain (selected-window)))
|
|
704 (if (not (valid-specifier-domain-p domain))
|
|
705 (error "Invalid specifier domain"))
|
|
706 (let ((device (dfw-device domain))
|
|
707 (common-props '(foreground background font display-table underline))
|
|
708 (x-props '(background-pixmap strikethru))
|
|
709 (tty-props '(highlight dim blinking reverse)))
|
|
710
|
|
711 ;; First check the properties which are used in common between the
|
|
712 ;; x and tty devices. Then, check those properties specific to
|
|
713 ;; the particular device type.
|
|
714 (and (face-equal-loop common-props face1 face2 domain)
|
|
715 (cond ((eq 'tty (device-type device))
|
|
716 (face-equal-loop tty-props face1 face2 domain))
|
|
717 ((eq 'x (device-type device))
|
|
718 (face-equal-loop x-props face1 face2 domain))
|
|
719 (t t)))))
|
|
720
|
|
721 (defun face-differs-from-default-p (face &optional domain)
|
|
722 "True if the given face will display differently from the default face.
|
|
723 See `face-property-instance' for the semantics of the DOMAIN argument."
|
|
724 (not (face-equal face 'default domain)))
|
|
725
|
|
726
|
|
727 ;; This function is a terrible, disgusting hack!!!! Need to
|
|
728 ;; separate out the font elements as separate face properties!
|
|
729
|
|
730 ;; WE DEMAND LEXICAL SCOPING!!!
|
|
731 ;; WE DEMAND LEXICAL SCOPING!!!
|
|
732 ;; WE DEMAND LEXICAL SCOPING!!!
|
|
733 ;; WE DEMAND LEXICAL SCOPING!!!
|
|
734 ;; WE DEMAND LEXICAL SCOPING!!!
|
|
735 ;; WE DEMAND LEXICAL SCOPING!!!
|
|
736 ;; WE DEMAND LEXICAL SCOPING!!!
|
|
737 ;; WE DEMAND LEXICAL SCOPING!!!
|
|
738 ;; WE DEMAND LEXICAL SCOPING!!!
|
|
739 ;; WE DEMAND LEXICAL SCOPING!!!
|
|
740 ;; WE DEMAND LEXICAL SCOPING!!!
|
|
741 ;; WE DEMAND LEXICAL SCOPING!!!
|
|
742 ;; WE DEMAND LEXICAL SCOPING!!!
|
|
743 ;; WE DEMAND LEXICAL SCOPING!!!
|
|
744 ;; WE DEMAND LEXICAL SCOPING!!!
|
|
745 (defun frob-face-property (face property func &optional locale)
|
|
746 "Change the specifier for FACE's PROPERTY according to FUNC, in LOCALE.
|
|
747 This function is ugly and messy and is primarily used as an internal
|
|
748 helper function for `make-face-bold' et al., so you probably don't
|
|
749 want to use it or read the rest of the documentation. But if you do ...
|
|
750
|
|
751 FUNC should be a function of two arguments (an instance and a device)
|
|
752 that returns a modified name that is valid for the given device.
|
|
753 If LOCALE specifies a valid domain (i.e. a window, frame, or device),
|
|
754 this function instantiates the specifier over that domain, applies FUNC
|
|
755 to the resulting instance, and adds the result back as an instantiator
|
|
756 for that locale. Otherwise, LOCALE should be a locale, locale type, or
|
|
757 'all (defaults to 'all if omitted). For each specification thusly
|
|
758 included: if the locale given is a valid domain, FUNC will be
|
|
759 iterated over all valid instantiators for the device of the domain
|
|
760 until a non-nil result is found (if there is no such result, the
|
|
761 first valid instantiator is used), and that result substituted for
|
|
762 the specification; otherwise, the process just outlined is
|
|
763 iterated over each existing device and the concatenated results
|
|
764 substituted for the specification."
|
|
765 (let ((sp (face-property face property)))
|
|
766 (if (valid-specifier-domain-p locale)
|
|
767 ;; this is easy.
|
|
768 (let* ((inst (face-property-instance face property locale))
|
|
769 (name (and inst (funcall func inst (dfw-device locale)))))
|
|
770 (if name
|
|
771 (add-spec-to-specifier sp name locale)))
|
|
772 ;; otherwise, map over all specifications ...
|
|
773 ;; but first, some further kludging:
|
|
774 ;; (1) if we're frobbing the global property, make sure
|
|
775 ;; that something is there (copy from the default face,
|
|
776 ;; if necessary). Otherwise, something like
|
|
777 ;; (make-face-larger 'modeline)
|
|
778 ;; won't do anything at all if the modeline simply
|
|
779 ;; inherits its font from 'default.
|
|
780 ;; (2) if we're frobbing a particular locale, nothing would
|
|
781 ;; happen if that locale has no instantiators. So signal
|
|
782 ;; an error to indicate this.
|
|
783 (if (and (or (eq locale 'global) (eq locale 'all) (not locale))
|
|
784 (not (face-property face property 'global)))
|
|
785 (copy-specifier (face-property 'default property)
|
|
786 (face-property face property)
|
|
787 'global))
|
|
788 (if (and (valid-specifier-locale-p locale)
|
|
789 (not (face-property face property locale)))
|
|
790 (error "Property must have a specification in locale %S" locale))
|
|
791 (map-specifier
|
|
792 sp
|
|
793 #'(lambda (sp locale inst-list func)
|
|
794 (let* ((device (dfw-device locale))
|
|
795 ;; if a device can be derived from the locale,
|
|
796 ;; call frob-face-property-1 for that device.
|
|
797 ;; Otherwise map frob-face-property-1 over each device.
|
|
798 (result
|
|
799 (if device
|
|
800 (list (frob-face-property-1 sp device inst-list func))
|
|
801 (mapcar #'(lambda (device)
|
|
802 (frob-face-property-1 sp device
|
|
803 inst-list func))
|
|
804 (device-list))))
|
|
805 new-result)
|
|
806 ;; remove duplicates and nils from the obtained list of
|
|
807 ;; instantiators.
|
|
808 (mapcar #'(lambda (arg)
|
|
809 (if (and arg (not (member arg new-result)))
|
|
810 (setq new-result (cons arg new-result))))
|
|
811 result)
|
|
812 ;; add back in.
|
|
813 (add-spec-list-to-specifier sp
|
|
814 (list (cons locale new-result)))
|
|
815 ;; tell map-specifier to keep going.
|
|
816 nil))
|
|
817 locale
|
|
818 func))))
|
|
819
|
|
820 (defun frob-face-property-1 (sp device inst-list func)
|
|
821 (let
|
|
822 (first-valid result)
|
|
823 (while (and inst-list (not result))
|
|
824 (let* ((inst-pair (car inst-list))
|
|
825 (tag-set (car inst-pair))
|
|
826 (sp-inst (specifier-instance-from-inst-list
|
|
827 sp device (list inst-pair))))
|
|
828 (if sp-inst
|
|
829 (progn
|
|
830 (if (not first-valid)
|
|
831 (setq first-valid inst-pair))
|
|
832 (setq result (funcall func sp-inst device))
|
|
833 (if result
|
|
834 (setq result (cons tag-set result))))))
|
|
835 (setq inst-list (cdr inst-list)))
|
|
836 (or result first-valid)))
|
|
837
|
|
838 (defun frob-face-font-2 (face locale unfrobbed-face frobbed-face
|
|
839 tty-thunk x-thunk standard-face-mapping)
|
|
840 ;; another kludge to make things more intuitive. If we're
|
|
841 ;; inheriting from a standard face in this locale, frob the
|
|
842 ;; inheritance as appropriate. Else, if, after the first X frobbing
|
|
843 ;; pass, the face hasn't changed and still looks like the standard
|
|
844 ;; unfrobbed face (e.g. 'default), make it inherit from the standard
|
|
845 ;; frobbed face (e.g. 'bold). Regardless of things, do the TTY
|
|
846 ;; frobbing.
|
|
847
|
|
848 ;; yuck -- The LOCALE argument to make-face-bold is not actually a locale,
|
|
849 ;; but is a "locale, locale-type, or nil for all". So ... do our extra
|
|
850 ;; frobbing only if it's actually a locale; or for nil, do the frobbing
|
|
851 ;; on 'global. This specifier stuff needs some rethinking.
|
|
852 (let* ((the-locale (cond ((null locale) 'global)
|
|
853 ((valid-specifier-locale-p locale) locale)
|
|
854 (t nil)))
|
|
855 (specs (and the-locale (face-font face the-locale nil t)))
|
|
856 (change-it (and specs (cdr (assoc specs standard-face-mapping)))))
|
|
857 (if (and change-it
|
|
858 (not (memq (face-name (find-face face))
|
|
859 '(default bold italic bold-italic))))
|
|
860 (progn
|
|
861 (or (equal change-it t)
|
|
862 (set-face-property face 'font change-it the-locale))
|
|
863 (funcall tty-thunk))
|
|
864 (let* ((domain (cond ((null the-locale) nil)
|
|
865 ((valid-specifier-domain-p the-locale) the-locale)
|
|
866 ;; OK, this next one is truly a kludge, but
|
|
867 ;; it results in more intuitive behavior most
|
|
868 ;; of the time. (really!)
|
|
869 ((or (eq the-locale 'global) (eq the-locale 'all))
|
|
870 (selected-device))
|
|
871 (t nil)))
|
|
872 (inst (and domain (face-property-instance face 'font domain))))
|
|
873 (funcall tty-thunk)
|
|
874 (funcall x-thunk)
|
|
875 ;; If it's reasonable to do the inherit-from-standard-face trick,
|
|
876 ;; and it's called for, then do it now.
|
|
877 (or (null domain)
|
|
878 (not (equal inst (face-property-instance face 'font domain)))
|
|
879 ;; don't do it for standard faces, or you'll get inheritance loops.
|
|
880 ;; #### This makes XEmacs seg fault! fix this bug.
|
|
881 (memq (face-name (find-face face))
|
|
882 '(default bold italic bold-italic))
|
|
883 (not (equal (face-property-instance face 'font domain)
|
|
884 (face-property-instance unfrobbed-face 'font domain)))
|
|
885 (set-face-property face 'font (vector frobbed-face)
|
|
886 the-locale))))))
|
|
887
|
|
888 (defun make-face-bold (face &optional locale)
|
|
889 "Make the face bold, if possible.
|
|
890 This will attempt to make the font bold for X locales and will set the
|
|
891 highlight flag for TTY locales.
|
|
892
|
|
893 If LOCALE is nil, omitted, or `all', this will attempt to frob all
|
|
894 font specifications for FACE to make them appear bold. Similarly, if
|
|
895 LOCALE is a locale type, this frobs all font specifications for locales
|
|
896 of that type. If LOCALE is a particular locale, what happens depends on
|
|
897 what sort of locale is given. If you gave a device, frame, or window,
|
|
898 then it's always possible to determine what the font actually will be,
|
|
899 so this is determined and the resulting font is frobbed and added back as a
|
|
900 specification for this locale. If LOCALE is a buffer, however, you can't
|
|
901 determine what the font will actually be unless there's actually a
|
|
902 specification given for that particular buffer (otherwise, it depends
|
|
903 on what window and frame the buffer appears in, and might not even be
|
|
904 well-defined if the buffer appears multiple times in different places);
|
|
905 therefore you will get an error unless there's a specification for the
|
|
906 buffer.
|
|
907
|
|
908 Finally, in some cases (specifically, when LOCALE is not a locale type),
|
|
909 if the frobbing didn't actually make the font look any different
|
|
910 \(this happens, for example, if your font specification is already bold
|
|
911 or has no bold equivalent), and currently looks like the font of the
|
|
912 'default face, it is set to inherit from the 'bold face. This is kludgy
|
|
913 but it makes `make-face-bold' have more intuitive behavior in many
|
|
914 circumstances."
|
|
915 (interactive (list (read-face-name "Make which face bold: ")))
|
|
916 (frob-face-font-2
|
|
917 face locale 'default 'bold
|
|
918 #'(lambda ()
|
|
919 ;; handle TTY specific entries
|
|
920 (if (featurep 'tty)
|
|
921 (set-face-highlight-p face t locale 'tty)))
|
|
922 #'(lambda ()
|
|
923 ;; handle X specific entries
|
|
924 (frob-face-property face 'font 'x-make-font-bold locale))
|
|
925 '(([default] . [bold])
|
|
926 ([bold] . t)
|
|
927 ([italic] . [bold-italic])
|
|
928 ([bold-italic] . t))))
|
|
929
|
|
930 (defun make-face-italic (face &optional locale)
|
|
931 "Make the face italic, if possible.
|
|
932 This will attempt to make the font italic for X locales and will set
|
|
933 the underline flag for TTY locales.
|
|
934 See `make-face-bold' for the semantics of the LOCALE argument and
|
|
935 for more specifics on exactly how this function works."
|
|
936 (interactive (list (read-face-name "Make which face italic: ")))
|
|
937 (frob-face-font-2
|
|
938 face locale 'default 'italic
|
|
939 #'(lambda ()
|
|
940 ;; handle TTY specific entries
|
|
941 (if (featurep 'tty)
|
|
942 (set-face-underline-p face t locale 'tty)))
|
|
943 #'(lambda ()
|
|
944 ;; handle X specific entries
|
|
945 (frob-face-property face 'font 'x-make-font-italic locale))
|
|
946 '(([default] . [italic])
|
|
947 ([bold] . [bold-italic])
|
|
948 ([italic] . t)
|
|
949 ([bold-italic] . t))))
|
|
950
|
|
951 (defun make-face-bold-italic (face &optional locale)
|
|
952 "Make the face bold and italic, if possible.
|
|
953 This will attempt to make the font bold-italic for X locales and will
|
|
954 set the highlight and underline flags for TTY locales.
|
|
955 See `make-face-bold' for the semantics of the LOCALE argument and
|
|
956 for more specifics on exactly how this function works."
|
|
957 (interactive (list (read-face-name "Make which face bold-italic: ")))
|
|
958 (frob-face-font-2
|
|
959 face locale 'default 'bold-italic
|
|
960 #'(lambda ()
|
|
961 ;; handle TTY specific entries
|
|
962 (if (featurep 'tty)
|
|
963 (progn
|
|
964 (set-face-highlight-p face t locale 'tty)
|
|
965 (set-face-underline-p face t locale 'tty))))
|
|
966 #'(lambda ()
|
|
967 ;; handle X specific entries
|
|
968 (frob-face-property face 'font 'x-make-font-bold-italic locale))
|
|
969 '(([default] . [italic])
|
|
970 ([bold] . [bold-italic])
|
|
971 ([italic] . [bold-italic])
|
|
972 ([bold-italic] . t))))
|
|
973
|
|
974 (defun make-face-unbold (face &optional locale)
|
|
975 "Make the face non-bold, if possible.
|
|
976 This will attempt to make the font non-bold for X locales and will
|
|
977 unset the highlight flag for TTY locales.
|
|
978 See `make-face-bold' for the semantics of the LOCALE argument and
|
|
979 for more specifics on exactly how this function works."
|
|
980 (interactive (list (read-face-name "Make which face non-bold: ")))
|
|
981 (frob-face-font-2
|
|
982 face locale 'bold 'default
|
|
983 #'(lambda ()
|
|
984 ;; handle TTY specific entries
|
|
985 (if (featurep 'tty)
|
|
986 (set-face-highlight-p face nil locale 'tty)))
|
|
987 #'(lambda ()
|
|
988 ;; handle X specific entries
|
|
989 (frob-face-property face 'font 'x-make-font-unbold locale))
|
|
990 '(([default] . t)
|
|
991 ([bold] . [default])
|
|
992 ([italic] . t)
|
|
993 ([bold-italic] . [italic]))))
|
|
994
|
|
995 (defun make-face-unitalic (face &optional locale)
|
|
996 "Make the face non-italic, if possible.
|
|
997 This will attempt to make the font non-italic for X locales and will
|
|
998 unset the underline flag for TTY locales.
|
|
999 See `make-face-bold' for the semantics of the LOCALE argument and
|
|
1000 for more specifics on exactly how this function works."
|
|
1001 (interactive (list (read-face-name "Make which face non-italic: ")))
|
|
1002 (frob-face-font-2
|
|
1003 face locale 'italic 'default
|
|
1004 #'(lambda ()
|
|
1005 ;; handle TTY specific entries
|
|
1006 (if (featurep 'tty)
|
|
1007 (set-face-underline-p face nil locale 'tty)))
|
|
1008 #'(lambda ()
|
|
1009 ;; handle X specific entries
|
|
1010 (frob-face-property face 'font 'x-make-font-unitalic locale))
|
|
1011 '(([default] . t)
|
|
1012 ([bold] . t)
|
|
1013 ([italic] . [default])
|
|
1014 ([bold-italic] . [bold]))))
|
|
1015
|
|
1016 (defun make-face-smaller (face &optional locale)
|
|
1017 "Make the font of the given face be smaller, if possible.
|
|
1018 LOCALE works as in `make-face-bold' et al., but the ``inheriting-
|
|
1019 from-the-bold-face'' operations described there are not done
|
|
1020 because they don't make sense in this context."
|
|
1021 (interactive (list (read-face-name "Shrink which face: ")))
|
|
1022 ;; handle X specific entries
|
|
1023 (frob-face-property face 'font 'x-find-smaller-font locale))
|
|
1024
|
|
1025 (defun make-face-larger (face &optional locale)
|
|
1026 "Make the font of the given face be larger, if possible.
|
|
1027 See `make-face-smaller' for the semantics of the LOCALE argument."
|
|
1028 (interactive (list (read-face-name "Enlarge which face: ")))
|
|
1029 ;; handle X specific entries
|
|
1030 (frob-face-property face 'font 'x-find-larger-font locale))
|
|
1031
|
|
1032 (defun invert-face (face &optional locale)
|
|
1033 "Swap the foreground and background colors of the face."
|
|
1034 (if (valid-specifier-domain-p locale)
|
|
1035 (let ((foreface (face-foreground-instance face locale)))
|
|
1036 (set-face-foreground face (face-background-instance face locale)
|
|
1037 locale)
|
|
1038 (set-face-background face foreface locale))
|
|
1039 (let ((forespec (copy-specifier (face-foreground face) nil locale)))
|
|
1040 (copy-specifier (face-background face) (face-foreground face) locale)
|
|
1041 (copy-specifier forespec (face-background face) locale))))
|
|
1042
|
|
1043
|
|
1044 ;;; Convenience functions
|
|
1045
|
|
1046 (defun face-ascent (face &optional domain charset)
|
|
1047 "Return the ascent of a face.
|
|
1048 See `face-property-instance' for the semantics of the DOMAIN argument."
|
|
1049 (font-ascent (face-font face) domain charset))
|
|
1050
|
|
1051 (defun face-descent (face &optional domain charset)
|
|
1052 "Return the descent of a face.
|
|
1053 See `face-property-instance' for the semantics of the DOMAIN argument."
|
|
1054 (font-descent (face-font face) domain charset))
|
|
1055
|
|
1056 (defun face-width (face &optional domain charset)
|
|
1057 "Return the width of a face.
|
|
1058 See `face-property-instance' for the semantics of the DOMAIN argument."
|
|
1059 (font-width (face-font face) domain charset))
|
|
1060
|
|
1061 (defun face-height (face &optional domain charset)
|
|
1062 "Return the height of a face.
|
|
1063 See `face-property-instance' for the semantics of the DOMAIN argument."
|
|
1064 (+ (face-ascent face domain charset) (face-descent face domain charset)))
|
|
1065
|
|
1066 (defun face-proportional-p (face &optional domain charset)
|
|
1067 "Return whether FACE is proportional.
|
|
1068 See `face-property-instance' for the semantics of the DOMAIN argument."
|
|
1069 (font-proportional-p (face-font face) domain charset))
|
|
1070
|
|
1071
|
28
|
1072 (defvar init-face-from-resources t
|
30
|
1073 "If non-nil, attempt to initialize faces from the resource database.")
|
28
|
1074
|
|
1075 (defun make-empty-face (name &optional doc-string temporary)
|
30
|
1076 "Like `make-face', but doesn't query the resource database."
|
28
|
1077 (let ((init-face-from-resources nil))
|
|
1078 (make-face name doc-string temporary)))
|
|
1079
|
0
|
1080 (defun init-face-from-resources (face &optional locale)
|
|
1081 "Initialize FACE from the resource database.
|
|
1082 If LOCALE is specified, it should be a frame, device, or 'global, and
|
|
1083 the face will be resourced over that locale. Otherwise, the face will
|
|
1084 be resourced over all possible locales (i.e. all frames, all devices,
|
|
1085 and 'global)."
|
28
|
1086 (cond ((null init-face-from-resources)
|
|
1087 ;; Do nothing.
|
|
1088 )
|
|
1089 ((not locale)
|
|
1090 ;; Global, set for all frames.
|
|
1091 (progn
|
|
1092 (init-face-from-resources face 'global)
|
|
1093 (let ((devices (device-list)))
|
|
1094 (while devices
|
|
1095 (init-face-from-resources face (car devices))
|
|
1096 (setq devices (cdr devices))))
|
|
1097 (let ((frames (frame-list)))
|
|
1098 (while frames
|
|
1099 (init-face-from-resources face (car frames))
|
|
1100 (setq frames (cdr frames))))))
|
|
1101 (t
|
|
1102 ;; Specific.
|
|
1103 (let ((devtype (cond ((devicep locale) (device-type locale))
|
|
1104 ((framep locale) (frame-type locale))
|
|
1105 (t nil))))
|
|
1106 (cond ((or (and (not devtype) (featurep 'x)) (eq 'x devtype))
|
|
1107 (x-init-face-from-resources face locale))
|
|
1108 ((or (not devtype) (eq 'tty devtype))
|
|
1109 ;; Nothing to do for TTYs?
|
|
1110 ))))))
|
0
|
1111
|
|
1112 (defun init-device-faces (device)
|
|
1113 ;; First, add any device-local face resources.
|
28
|
1114 (when init-face-from-resources
|
|
1115 (loop for face in (face-list) do
|
|
1116 (init-face-from-resources face device))
|
|
1117 ;; Then do any device-specific initialization.
|
|
1118 (cond ((eq 'x (device-type device))
|
|
1119 (x-init-device-faces device))
|
|
1120 ;; Nothing to do for TTYs?
|
|
1121 )
|
|
1122 (init-other-random-faces device)))
|
0
|
1123
|
|
1124 (defun init-frame-faces (frame)
|
28
|
1125 (when init-face-from-resources
|
|
1126 ;; First, add any frame-local face resources.
|
|
1127 (loop for face in (face-list) do
|
|
1128 (init-face-from-resources face frame))
|
|
1129 ;; Then do any frame-specific initialization.
|
|
1130 (cond ((eq 'x (frame-type frame))
|
|
1131 (x-init-frame-faces frame))
|
|
1132 ;; Is there anything which should be done for TTY's?
|
|
1133 )))
|
0
|
1134
|
|
1135 ;; #### This is somewhat X-specific, and is called when the first
|
|
1136 ;; X device is created (even if there were TTY devices created
|
|
1137 ;; beforehand). The concept of resources has not been generalized
|
|
1138 ;; outside of X-specificness, so we have to live with this
|
|
1139 ;; breach of device-independence.
|
|
1140
|
|
1141 (defun init-global-faces ()
|
|
1142 ;; Look for global face resources.
|
|
1143 (let ((faces (face-list)))
|
|
1144 (while faces
|
|
1145 (init-face-from-resources (car faces) 'global)
|
|
1146 (setq faces (cdr faces))))
|
|
1147 ;; Further X frobbing.
|
|
1148 (x-init-global-faces)
|
|
1149 ;; for bold and the like, make the global specification be bold etc.
|
|
1150 ;; if the user didn't already specify a value. These will also be
|
|
1151 ;; frobbed further in init-other-random-faces.
|
|
1152 (or (face-font 'bold 'global)
|
|
1153 (make-face-bold 'bold 'global))
|
|
1154 ;;
|
|
1155 (or (face-font 'italic 'global)
|
|
1156 (make-face-italic 'italic 'global))
|
|
1157 ;;
|
|
1158 (or (face-font 'bold-italic 'global)
|
|
1159 (make-face-bold-italic 'bold-italic 'global))
|
|
1160
|
|
1161 (if (not (face-font 'bold-italic 'global))
|
|
1162 (progn
|
|
1163 (copy-face 'bold 'bold-italic)
|
|
1164 (make-face-italic 'bold-italic)))
|
|
1165
|
|
1166 (if (face-equal 'bold 'bold-italic)
|
|
1167 (progn
|
|
1168 (copy-face 'italic 'bold-italic)
|
|
1169 (make-face-bold 'bold-italic)))
|
|
1170 ;;
|
|
1171 ;; Nothing more to be done for X or TTY's?
|
|
1172 )
|
|
1173
|
|
1174
|
|
1175 ;; These warnings are there for a reason.
|
|
1176 ;; Just specify your fonts correctly. Deal with it.
|
|
1177 ;(defvar inhibit-font-complaints nil
|
|
1178 ; "Whether to suppress complaints about incomplete sets of fonts.")
|
|
1179
|
|
1180 (defun face-complain-about-font (face device)
|
|
1181 (if (symbolp face) (setq face (symbol-name face)))
|
|
1182 ;; (if (not inhibit-font-complaints)
|
2
|
1183 (display-warning
|
|
1184 'font
|
|
1185 (let ((default-name (face-font-name 'default device)))
|
|
1186 (format "%s: couldn't deduce %s %s version of the font
|
|
1187 %S.
|
|
1188
|
|
1189 Please specify X resources to make the %s face
|
|
1190 visually distinguishable from the default face.
|
|
1191 For example, you could add one of the following to $HOME/Emacs:
|
|
1192
|
|
1193 Emacs.%s.attributeFont: -dt-*-medium-i-*
|
|
1194 or
|
|
1195 Emacs.%s.attributeForeground: hotpink\n"
|
|
1196 invocation-name
|
|
1197 (if (string-match "\\`[aeiouAEIOU]" face) "an" "a")
|
|
1198 face
|
|
1199 default-name
|
|
1200 face
|
|
1201 face
|
|
1202 face
|
|
1203 ))))
|
0
|
1204
|
|
1205 (defun init-other-random-faces (device)
|
|
1206 "Initializes the colors and fonts of the bold, italic, bold-italic,
|
|
1207 zmacs-region, list-mode-item-selected, highlight, primary-selection,
|
|
1208 secondary-selection, and isearch faces when each device is created. If
|
|
1209 you want to add code to do stuff like this, use the create-device-hook."
|
|
1210
|
|
1211 ;; try to make 'bold look different from the default on this device.
|
|
1212 ;; If that doesn't work at all, then issue a warning.
|
|
1213 (or (face-differs-from-default-p 'bold device)
|
|
1214 (make-face-bold 'bold device))
|
|
1215 (or (face-differs-from-default-p 'bold device)
|
|
1216 (make-face-unbold 'bold device))
|
|
1217 (or (face-differs-from-default-p 'bold device)
|
|
1218 ;; otherwise the luser specified one of the bogus font names
|
|
1219 (face-complain-about-font 'bold device))
|
|
1220
|
|
1221 ;; similar for italic.
|
|
1222 (or (face-differs-from-default-p 'italic device)
|
|
1223 (make-face-italic 'italic device))
|
|
1224 (or (face-differs-from-default-p 'italic device)
|
|
1225 (progn
|
2
|
1226 (make-face-bold 'italic device) ; bold if possible, then complain
|
0
|
1227 (face-complain-about-font 'italic device)))
|
|
1228
|
|
1229 ;; similar for bold-italic.
|
|
1230 (or (face-differs-from-default-p 'bold-italic device)
|
30
|
1231 (make-face-bold 'bold-italic device))
|
0
|
1232 ;; if we couldn't get a bold-italic version, try just bold.
|
|
1233 (or (face-differs-from-default-p 'bold-italic device)
|
|
1234 (make-face-bold-italic 'bold-italic device))
|
|
1235 ;; if we couldn't get bold or bold-italic, then that's probably because
|
|
1236 ;; the default font is bold, so make the `bold-italic' face be unbold.
|
|
1237 (or (face-differs-from-default-p 'bold-italic device)
|
|
1238 (progn
|
|
1239 (make-face-unbold 'bold-italic device)
|
|
1240 (make-face-italic 'bold-italic device)))
|
|
1241 (or (face-differs-from-default-p 'bold-italic device)
|
|
1242 (progn
|
|
1243 ;; if that didn't work, try italic (can this ever happen? what the hell.)
|
|
1244 (make-face-italic 'bold-italic device)
|
|
1245 ;; then bitch and moan.
|
|
1246 (face-complain-about-font 'bold-italic device)))
|
|
1247
|
|
1248 ;; first time through, set the text-cursor colors if not already
|
|
1249 ;; specified.
|
|
1250 (if (and (not (face-background 'text-cursor 'global))
|
|
1251 (face-property-equal 'text-cursor 'default 'background device))
|
|
1252 (set-face-background 'text-cursor [default foreground] 'global
|
|
1253 nil 'append))
|
|
1254 (if (and (not (face-foreground 'text-cursor 'global))
|
|
1255 (face-property-equal 'text-cursor 'default 'foreground device))
|
|
1256 (set-face-foreground 'text-cursor [default background] 'global
|
|
1257 nil 'append))
|
|
1258
|
|
1259 ;; first time through, set the secondary-selection color if it's not already
|
|
1260 ;; specified.
|
|
1261 (if (and (not (face-differs-from-default-p 'highlight device))
|
|
1262 (not (face-background 'highlight 'global)))
|
|
1263 (progn
|
|
1264 ;; some older servers don't recognize "darkseagreen2"
|
|
1265 (set-face-background 'highlight
|
|
1266 '((color . "darkseagreen2")
|
|
1267 (color . "green"))
|
|
1268 'global nil 'append)
|
|
1269 (set-face-background 'highlight "gray53" 'global 'grayscale 'append)))
|
|
1270 (if (and (not (face-differs-from-default-p 'highlight device))
|
|
1271 (not (face-background-pixmap 'highlight 'global)))
|
|
1272 (progn
|
|
1273 (set-face-background-pixmap 'highlight [nothing] 'global 'color
|
|
1274 'append)
|
|
1275 (set-face-background-pixmap 'highlight [nothing] 'global 'grayscale
|
|
1276 'append)
|
|
1277 (set-face-background-pixmap 'highlight "gray1" 'global 'mono 'append)))
|
|
1278 ;; if the highlight face isn't distinguished on this device,
|
|
1279 ;; at least try inverting it.
|
|
1280 (or (face-differs-from-default-p 'highlight device)
|
|
1281 (invert-face 'highlight device))
|
|
1282
|
|
1283 ;; first time through, set the zmacs-region color if it's not already
|
|
1284 ;; specified.
|
26
|
1285 (unless (or (face-differs-from-default-p 'zmacs-region device)
|
|
1286 (face-background 'zmacs-region 'global))
|
|
1287 (set-face-background 'zmacs-region "gray65" 'global 'color)
|
|
1288 (set-face-background 'zmacs-region "gray65" 'global 'grayscale))
|
0
|
1289 (if (and (not (face-differs-from-default-p 'zmacs-region device))
|
|
1290 (not (face-background-pixmap 'zmacs-region 'global)))
|
|
1291 (progn
|
|
1292 (set-face-background-pixmap 'zmacs-region [nothing] 'global 'color)
|
|
1293 (set-face-background-pixmap 'zmacs-region [nothing] 'global 'grayscale)
|
|
1294 (set-face-background-pixmap 'zmacs-region "gray3" 'global 'mono)))
|
|
1295 ;; if the zmacs-region face isn't distinguished on this device,
|
|
1296 ;; at least try inverting it.
|
|
1297 (or (face-differs-from-default-p 'zmacs-region device)
|
|
1298 (invert-face 'zmacs-region device))
|
|
1299
|
|
1300 ;; first time through, set the list-mode-item-selected color if it's
|
|
1301 ;; not already specified.
|
|
1302 (if (and (not (face-differs-from-default-p 'list-mode-item-selected device))
|
|
1303 (not (face-background 'list-mode-item-selected 'global)))
|
|
1304 (progn
|
|
1305 (set-face-background 'list-mode-item-selected "gray68" 'global 'color)
|
|
1306 (set-face-background 'list-mode-item-selected "gray68" 'global
|
|
1307 'grayscale)
|
|
1308 (if (not (face-foreground 'list-mode-item-selected 'global))
|
|
1309 (progn
|
|
1310 (set-face-background 'list-mode-item-selected
|
|
1311 [default foreground] 'global '(mono x))
|
|
1312 (set-face-foreground 'list-mode-item-selected
|
|
1313 [default background] 'global '(mono x))))))
|
|
1314 ;; if the list-mode-item-selected face isn't distinguished on this device,
|
|
1315 ;; at least try inverting it.
|
|
1316 (or (face-differs-from-default-p 'list-mode-item-selected device)
|
|
1317 (invert-face 'list-mode-item-selected device))
|
|
1318
|
|
1319 ;; first time through, set the primary-selection color if it's not already
|
|
1320 ;; specified.
|
26
|
1321 (unless (or (face-differs-from-default-p 'primary-selection device)
|
|
1322 (face-background 'primary-selection 'global))
|
|
1323 (set-face-background 'primary-selection "gray65" 'global 'color)
|
|
1324 (set-face-background 'primary-selection "gray65" 'global 'grayscale))
|
0
|
1325 (if (and (not (face-differs-from-default-p 'secondary-selection device))
|
|
1326 (not (face-background-pixmap 'primary-selection 'global)))
|
|
1327 (set-face-background-pixmap 'primary-selection "gray3" 'global 'mono))
|
|
1328 ;; if the primary-selection face isn't distinguished on this device,
|
|
1329 ;; at least try inverting it.
|
|
1330 (or (face-differs-from-default-p 'primary-selection device)
|
|
1331 (invert-face 'primary-selection device))
|
|
1332
|
|
1333 ;; first time through, set the secondary-selection color if it's not already
|
|
1334 ;; specified.
|
|
1335 (if (and (not (face-differs-from-default-p 'secondary-selection device))
|
|
1336 (not (face-background 'secondary-selection 'global)))
|
|
1337 (progn
|
|
1338 (set-face-background 'secondary-selection
|
|
1339 '((color . "paleturquoise")
|
|
1340 (color . "green"))
|
|
1341 'global)
|
|
1342 (set-face-background 'secondary-selection "gray53" 'global
|
|
1343 'grayscale)))
|
|
1344 (if (and (not (face-differs-from-default-p 'secondary-selection device))
|
|
1345 (not (face-background-pixmap 'secondary-selection 'global)))
|
|
1346 (set-face-background-pixmap 'secondary-selection "gray1" 'global 'mono))
|
|
1347 ;; if the secondary-selection face isn't distinguished on this device,
|
|
1348 ;; at least try inverting it.
|
|
1349 (or (face-differs-from-default-p 'secondary-selection device)
|
|
1350 (invert-face 'secondary-selection device))
|
|
1351
|
|
1352 ;; set the isearch color if it's not already specified.
|
|
1353 (if (not (face-differs-from-default-p 'isearch device))
|
|
1354 (or (face-background 'isearch 'global)
|
|
1355 ;; TTY's and some older X servers don't recognize "paleturquoise"
|
|
1356 (set-face-background 'isearch
|
|
1357 '((color . "paleturquoise")
|
|
1358 (color . "green"))
|
|
1359 'global)))
|
|
1360 ;; if the isearch face isn't distinguished (e.g. we're not on a color
|
|
1361 ;; display), at least try making it bold.
|
|
1362 (or (face-differs-from-default-p 'isearch device)
|
|
1363 (set-face-font 'isearch [bold]))
|
|
1364
|
|
1365 ;; set the modeline face colors/fonts if not already specified.
|
|
1366
|
|
1367 ;; modeline-buffer-id:
|
|
1368 (if (not (face-differs-from-default-p 'modeline-buffer-id device))
|
|
1369 (let ((fg (face-foreground 'modeline-buffer-id 'global))
|
|
1370 (font (face-font 'modeline-buffer-id 'global)))
|
|
1371 (and (featurep 'x)
|
|
1372 (or fg
|
24
|
1373 (set-face-foreground 'modeline-buffer-id "blue4" 'global
|
0
|
1374 '(color x))))
|
|
1375 (if font
|
|
1376 nil
|
|
1377 (if (featurep 'x)
|
|
1378 (progn
|
|
1379 (set-face-font 'modeline-buffer-id [bold-italic] nil '(mono x))
|
|
1380 (set-face-font 'modeline-buffer-id [bold-italic] nil
|
|
1381 '(grayscale x))))
|
12
|
1382 (if (featurep 'tty)
|
|
1383 (set-face-font 'modeline-buffer-id [bold-italic] nil 'tty)))))
|
0
|
1384 (set-face-parent 'modeline-buffer-id 'modeline nil nil 'append)
|
|
1385
|
|
1386 ;; modeline-mousable:
|
|
1387 (if (not (face-differs-from-default-p 'modeline-mousable device))
|
|
1388 (let ((fg (face-foreground 'modeline-mousable 'global))
|
|
1389 (font (face-font 'modeline-mousable 'global)))
|
|
1390 (and (featurep 'x)
|
|
1391 (or fg
|
24
|
1392 (set-face-foreground 'modeline-mousable "firebrick" 'global
|
0
|
1393 '(color x))))
|
|
1394 (if font
|
|
1395 nil
|
|
1396 (if (featurep 'x)
|
|
1397 (progn
|
|
1398 (set-face-font 'modeline-mousable [bold] nil '(mono x))
|
|
1399 (set-face-font 'modeline-mousable [bold] nil
|
|
1400 '(grayscale x)))))))
|
|
1401 (set-face-parent 'modeline-mousable 'modeline nil nil 'append)
|
|
1402
|
|
1403 ;; modeline-mousable-minor-mode:
|
|
1404 (if (not (face-differs-from-default-p 'modeline-mousable-minor-mode device))
|
|
1405 (let ((fg (face-foreground 'modeline-mousable-minor-mode 'global)))
|
|
1406 (and (featurep 'x)
|
|
1407 (or fg
|
|
1408 (set-face-foreground 'modeline-mousable-minor-mode
|
|
1409 '(((color x) . "green4")
|
24
|
1410 ((color x) . "forestgreen"))
|
|
1411 'global)))))
|
0
|
1412 (set-face-parent 'modeline-mousable-minor-mode 'modeline-mousable
|
|
1413 nil nil 'append)
|
|
1414 )
|
|
1415
|
|
1416
|
|
1417 ;; Create the remaining standard faces now. This way, packages that we dump
|
|
1418 ;; can reference these faces as parents.
|
|
1419 ;;
|
|
1420 ;; The default, modeline, left-margin, right-margin, text-cursor,
|
|
1421 ;; and pointer faces are created in C.
|
|
1422
|
|
1423 (make-face 'bold "bold text")
|
|
1424 (make-face 'italic "italic text")
|
|
1425 (make-face 'bold-italic "bold-italic text")
|
|
1426 (make-face 'underline "underlined text")
|
|
1427 (or (face-differs-from-default-p 'underline)
|
|
1428 (set-face-underline-p 'underline t 'global))
|
|
1429 (make-face 'zmacs-region "used on defined region between point and mark")
|
|
1430 (make-face 'isearch "used on region matched by isearch")
|
|
1431 (make-face 'list-mode-item-selected
|
|
1432 "Face for the selected list item in list-mode.")
|
|
1433 (make-face 'highlight "highlight face")
|
|
1434 (make-face 'primary-selection)
|
|
1435 (make-face 'secondary-selection)
|
|
1436
|
|
1437 (make-face 'red "red text")
|
|
1438 (set-face-foreground 'red "red" nil 'color)
|
|
1439 (make-face 'green "green text")
|
|
1440 (set-face-foreground 'green "green" nil 'color)
|
|
1441 (make-face 'blue "blue text")
|
|
1442 (set-face-foreground 'blue "blue" nil 'color)
|
|
1443 (make-face 'yellow "yellow text")
|
|
1444 (set-face-foreground 'yellow "yellow" nil 'color)
|
|
1445
|
|
1446 ;;
|
|
1447 ;; Make some useful faces. This happens very early, before creating
|
|
1448 ;; the first non-stream device. We initialize the tty global values here.
|
|
1449 ;; We cannot initialize the X global values here because they depend
|
|
1450 ;; on having already resourced the global face specs, which happens
|
|
1451 ;; when the first X device is created.
|
|
1452 ;;
|
|
1453
|
|
1454 (if (featurep 'tty)
|
|
1455 (set-face-reverse-p 'modeline t 'global 'tty))
|
|
1456 (set-face-background-pixmap 'modeline [nothing])
|
|
1457 ;;
|
|
1458 (if (featurep 'tty)
|
|
1459 (set-face-highlight-p 'highlight t 'global 'tty))
|
|
1460 ;;
|
|
1461 (if (featurep 'tty)
|
|
1462 (set-face-reverse-p 'text-cursor t 'global 'tty))
|
|
1463 ;;
|
|
1464 (if (featurep 'tty)
|
|
1465 (set-face-highlight-p 'bold t 'global 'tty))
|
|
1466 ;;
|
|
1467 (if (featurep 'tty)
|
|
1468 (set-face-underline-p 'italic t 'global 'tty))
|
|
1469 ;;
|
|
1470 (if (featurep 'tty)
|
|
1471 (progn
|
|
1472 (set-face-highlight-p 'bold-italic t 'global 'tty)
|
|
1473 (set-face-underline-p 'bold-italic t 'global 'tty)))
|
|
1474 ;;
|
|
1475 (if (featurep 'tty)
|
|
1476 (set-face-reverse-p 'zmacs-region t 'global 'tty))
|
|
1477 ;;
|
|
1478 (if (featurep 'tty)
|
|
1479 (set-face-reverse-p 'list-mode-item-selected t 'global 'tty))
|
|
1480 ;;
|
|
1481 (if (featurep 'tty)
|
|
1482 (set-face-reverse-p 'isearch t 'global 'tty))
|
12
|
1483
|
|
1484 ;;; faces.el ends here
|