annotate lisp/faces.el @ 265:8efd647ea9ca r20-5b31

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