428
|
1 @c -*-texinfo-*-
|
|
2 @c This is part of the XEmacs Lisp Reference Manual.
|
|
3 @c Copyright (C) 1995, 1996 Ben Wing.
|
1882
|
4 @c Copyright (C) 2002, 2004 Free Software Foundation, Inc.
|
428
|
5 @c See the file lispref.texi for copying conditions.
|
|
6 @setfilename ../../info/specifiers.info
|
|
7 @node Specifiers, Faces and Window-System Objects, Extents, top
|
|
8 @chapter Specifiers
|
|
9 @cindex specifier
|
|
10
|
|
11 A specifier is an object used to keep track of a property whose value
|
1135
|
12 should vary according to @emph{display context}, a window, a frame, or
|
|
13 device. The value of many built-in properties, such as the font,
|
|
14 foreground, background, and such properties of a face and variables
|
|
15 such as @code{modeline-shadow-thickness} and
|
|
16 @code{top-toolbar-height}, is actually a specifier object. The
|
|
17 specifier object, in turn, is ``instanced'' in a particular situation
|
|
18 to yield the real value of the property in the current context.
|
428
|
19
|
|
20 @defun specifierp object
|
|
21 This function returns non-@code{nil} if @var{object} is a specifier.
|
|
22 @end defun
|
|
23
|
|
24 @menu
|
440
|
25 * Introduction to Specifiers:: Specifiers provide a clean way for
|
|
26 display and other properties to vary
|
|
27 (under user control) in a wide variety
|
|
28 of contexts.
|
1135
|
29 * Simple Specifier Usage:: Getting started with specifiers.
|
440
|
30 * Specifiers In-Depth:: Gory details about specifier innards.
|
|
31 * Specifier Instancing:: Instancing means obtaining the ``value'' of
|
|
32 a specifier in a particular context.
|
|
33 * Specifier Types:: Specifiers come in different flavors.
|
|
34 * Adding Specifications:: Specifications control a specifier's ``value''
|
|
35 by giving conditions under which a
|
|
36 particular value is valid.
|
|
37 * Retrieving Specifications:: Querying a specifier's specifications.
|
|
38 * Specifier Tag Functions:: Working with specifier tags.
|
428
|
39 * Specifier Instancing Functions::
|
440
|
40 Functions to instance a specifier.
|
1869
|
41 * Specifier Examples:: Making all this stuff clearer.
|
440
|
42 * Creating Specifiers:: Creating specifiers for your own use.
|
428
|
43 * Specifier Validation Functions::
|
440
|
44 Validating the components of a specifier.
|
428
|
45 * Other Specification Functions::
|
440
|
46 Other ways of working with specifications.
|
2028
|
47 * Specifier Compatibility Notes::
|
|
48 Backward compatibility and GNU Emacs.
|
428
|
49 @end menu
|
|
50
|
|
51 @node Introduction to Specifiers
|
|
52 @section Introduction to Specifiers
|
|
53
|
1135
|
54 Perhaps the most useful way to explain specifiers is via an analogy.
|
|
55 Emacs Lisp programmers are used to @emph{buffer-local variables}
|
1138
|
56 @ref{Buffer-Local Variables}. For example, the variable
|
428
|
57 @code{modeline-format}, which controls the format of the modeline, can
|
|
58 have different values depending on the particular buffer being edited.
|
|
59 The variable has a default value which most modes will use, but a
|
1138
|
60 specialized package such as Calendar might change the variable so as to
|
|
61 tailor the modeline to its own purposes. Other variables are perhaps
|
|
62 best thought of as ``mode local,'' such as font-lock keywords, but they
|
|
63 are implemented as buffer locals.
|
428
|
64
|
|
65 Other properties (such as those that can be changed by the
|
|
66 @code{modify-frame-parameters} function, for example the color of the
|
|
67 text cursor) can have frame-local values, although it might also make
|
|
68 sense for them to have buffer-local values. In other cases, you might
|
|
69 want the property to vary depending on the particular window within the
|
|
70 frame that applies (e.g. the top or bottom window in a split frame), the
|
|
71 device type that that frame appears on (X or tty), etc. Perhaps you can
|
|
72 envision some more complicated scenario where you want a particular
|
|
73 value in a specified buffer, another value in all other buffers
|
|
74 displayed on a particular frame, another value in all other buffers
|
|
75 displayed in all other frames on any mono (two-color, e.g. black and
|
|
76 white only) displays, and a default value in all other circumstances.
|
|
77
|
1135
|
78 Specifiers generalize both buffer- and frame-local properties.
|
|
79 Specifiers vary according to the @emph{display} context. Font-lock
|
|
80 keywords in a buffer will be the same no matter which window the
|
|
81 buffer is displayed in, but windows on TTY devices will simply not be
|
|
82 capable of the flexibility that windows on modern GUI devices are.
|
1875
|
83 Specifiers provide a way for the programmer to @emph{declare} that an
|
1135
|
84 emphasized text should be italic on GUI devices and inverse video on
|
|
85 TTYs. They also provide a way for the programmer to declare
|
|
86 fallbacks, so that a color specified as ``chartreuse'' where possible
|
|
87 can fall back to ``yellow'' on devices where only ANSI (4-bit) color
|
|
88 is available. The complex calculations and device querying are
|
|
89 transparent to both user and programmer. You ask for what you want;
|
|
90 it's up to XEmacs to provide it, or a reasonable approximation.
|
|
91
|
|
92 We call such a declaration a @dfn{specification}. A @dfn{specification}
|
|
93 applies in a particular @dfn{locale}, which is a window, buffer, frame,
|
|
94 device, or the global locale. The value part of the specification is
|
|
95 called an @dfn{instantiator}. The process of determining the value in a
|
|
96 particular context, or @dfn{domain}, is called @dfn{instantiation} or
|
|
97 @dfn{instancing}. A domain is a window, frame, or device.
|
|
98
|
|
99 The difference between @dfn{locale} and @dfn{domain} is somewhat subtle.
|
|
100 You may think of a locale as a class of domains, which may span
|
|
101 different devices. Since the specification is abstract (a Lisp form),
|
|
102 you can state it without reference to a device. On the other hand, when
|
|
103 you instantiate a specification, you must know the type of the device.
|
1875
|
104 It is useless to specify that ``blue means emphasis'' on a monochrome
|
1135
|
105 device. Thus instantiation requires specification of the device on
|
|
106 which it will be rendered.
|
|
107
|
|
108 Thus a @dfn{specifier} allows a great deal of flexibility in
|
|
109 controlling exactly what value a property has in which circumstances.
|
1875
|
110 Specifiers are most commonly used for display properties, such as an image or
|
1135
|
111 the foreground color of a face. As a simple example, you can specify
|
|
112 that the foreground of the default face be
|
428
|
113
|
|
114 @itemize @bullet
|
|
115 @item
|
|
116 blue for a particular buffer
|
|
117 @item
|
|
118 green for all other buffers
|
|
119 @end itemize
|
|
120
|
|
121 As a more complicated example, you could specify that the foreground of
|
|
122 the default face be
|
|
123
|
|
124 @itemize @bullet
|
|
125 @item
|
|
126 forest green for all buffers displayed in a particular Emacs window, or
|
|
127 green if the X server doesn't recognize the color @samp{forest green}
|
|
128 @item
|
|
129 blue for all buffers displayed in a particular frame
|
|
130 @item
|
|
131 red for all other buffers displayed on a color device
|
|
132 @item
|
|
133 white for all other buffers
|
|
134 @end itemize
|
|
135
|
1135
|
136 @node Simple Specifier Usage
|
|
137 @section Simple Specifier Usage
|
|
138 @cindex specifier examples
|
|
139 @cindex examples, specifier
|
|
140 @cindex adding a button to a toolbar
|
|
141 @cindex toolbar button, adding
|
|
142
|
|
143 A useful specifier application is adding a button to a toolbar. XEmacs
|
|
144 provides several toolbars, one along each edge of the frame. Normally
|
|
145 only one is used at a time, the default. The default toolbar is
|
1875
|
146 actually a specifier object which is the value of
|
|
147 @code{default-toolbar}. @xref{Toolbar Intro}.
|
1135
|
148
|
|
149 The specification of a toolbar is simple: it is a list of buttons.
|
|
150 Each button is a vector with four elements: an icon, a command, the
|
|
151 enabled flag, and a help string. Let's retrieve the instance of the
|
|
152 toolbar you see in the selected frame.
|
|
153
|
|
154 @example
|
|
155 (specifier-instance default-toolbar)
|
|
156 @end example
|
|
157
|
|
158 The value returned is, as promised, a list of vectors. Now let's build
|
|
159 up a button, and add it to the toolbar. Our button will invoke the last
|
|
160 defined keyboard macro. This is an alternative to
|
|
161 @code{name-last-kbd-macro} for creating a persistent macro, rather than
|
|
162 an alias for @kbd{C-x e}.
|
|
163
|
|
164 A toolbar button icon can be quite sophisticated, with different images
|
|
165 for button up, button down, and disabled states, and a similar set with
|
|
166 captions. We'll use a very simple icon, but we have to jump through a
|
|
167 few non-obvious hoops designed to support the sophisticated applications.
|
|
168 The rest of the button descriptor is straightforward.
|
|
169
|
|
170 @example
|
|
171 (setq toolbar-my-kbd-macro-button
|
|
172 `[ (list (make-glyph "MyKbdMac"))
|
|
173 (lambda () (interactive) (execute-kbd-macro ,last-kbd-macro))
|
|
174 t
|
|
175 "Execute a previously defined keyboard macro." ])
|
|
176
|
|
177 (set-specifier default-toolbar
|
|
178 (cons toolbar-my-kbd-macro-button
|
|
179 (specifier-specs default-toolbar 'global))
|
|
180 'global)
|
|
181 @end example
|
|
182
|
|
183 To remove the button, just substitute the function @code{delete} for the
|
|
184 @code{cons} above.
|
|
185
|
|
186 What is the difference between @code{specifier-instance}, which we used
|
|
187 in the example of retrieving the toolbar descriptor, and
|
|
188 @code{specifier-specs}, which was used in the toolbar manipulating code?
|
|
189 @code{specifier-specs} retrieves a copy of the instantiator, which is
|
|
190 abstract and does not depend on context. @code{specifier-instance}, on
|
|
191 the other hand, actually instantiates the specification, and returns the
|
|
192 result for the given context. Another way to express this is:
|
|
193 @code{specifier-specs} takes a @emph{locale} as an argument, while
|
|
194 @code{specifier-instance} takes a @emph{domain}. The reason for
|
|
195 providing @code{specifier-instance} is that sometimes you wish to see
|
|
196 the object that XEmacs will actually use. @code{specifier-specs}, on
|
|
197 the other hand, shows you what the programmer (or user) requested. When
|
|
198 a program manipulates specifications, clearly it's the latter that is
|
|
199 desirable.
|
|
200
|
|
201 In the case of the toolbar descriptor, it turns out that these are the
|
|
202 same: the instancing process is trivial. However, many specifications
|
|
203 have non-trivial instancing. Compare the results of the following forms
|
|
204 on my system. (The @samp{(cdr (first ...))} form is due to my use of
|
|
205 Mule. On non-Mule XEmacsen, just use @code{specifier-specs}.)
|
|
206
|
|
207 @example
|
|
208 (cdr (first (specifier-specs (face-font 'default) 'global)))
|
|
209 => "-*--14-*jisx0208*-0"
|
|
210
|
|
211 (specifier-instance (face-font 'default))
|
|
212 #<font-instance "-*--14-*jisx0208*-0" on #<x-device on ":0.0" 0x970> 0xe0028b 0x176b>
|
|
213 @end example
|
|
214
|
|
215 In this case, @code{specifier-instance} returns an opaque object;
|
|
216 programs can't work on it, they can only pass it around. Worse, in some
|
|
217 environments the instantiation will fail, resulting in a different value
|
|
218 (when another instantiation succeeds), or worse yet, an error, if all
|
|
219 attempts to instance the specifier fail. @code{specifier-instance} is
|
|
220 context-dependent, even for the exact same specification.
|
|
221 @code{specifier-specs} is deterministic, and only depends on the
|
|
222 specifications.
|
|
223
|
|
224 Note that in the toolbar-changing code we operate in the global locale.
|
|
225 This means that narrower locales, if they have specifications, will
|
|
226 shadow our changes. (Specifier instancing does not merge
|
|
227 specifications. It selects the "highest-priority successful
|
|
228 specification" and instances that.)
|
|
229
|
|
230 In fact, in our example, it seems pretty likely that different buffers
|
|
231 @emph{should} have different buttons. (The icon can be the same, but
|
|
232 the keyboard macro you create in a Dired buffer is highly unlikely to be
|
|
233 useful in a LaTeX buffer!) Here's one way to implement this:
|
|
234
|
|
235 @example
|
|
236 (setq toolbar-my-kbd-macro-button
|
|
237 `[ (list (make-glyph "MyKbdMac"))
|
|
238 (lambda () (interactive) (execute-kbd-macro ,last-kbd-macro))
|
|
239 t
|
|
240 "Execute a previously defined keyboard macro." ])
|
|
241
|
|
242 (set-specifier default-toolbar
|
|
243 (cons toolbar-my-kbd-macro-button
|
|
244 (cond ((specifier-specs default-toolbar
|
|
245 (current-buffer)))
|
|
246 ((specifier-specs default-toolbar
|
|
247 'global)))
|
|
248 (current-buffer))
|
|
249 @end example
|
|
250
|
|
251 Finally, a cautionary note: the use of @code{specifier-specs} in the
|
|
252 code above is for expository purposes. Don't use it in production code.
|
|
253 In fact, the @code{set-specifier} form above is likely to fail
|
|
254 occasionally, because you can add many specifications for the same
|
|
255 locale.
|
|
256
|
|
257 In these cases, @code{specifier-specs} will return a list. A further
|
|
258 refinement is that a specification may be associated with a set of
|
|
259 @dfn{specifier tags}. If the list of specifier tags is non-nil, then
|
|
260 @code{specifier-specs} will return a cons of the tag set and the
|
|
261 instantiator. Evidently @code{specifier-specs} is a bit unreliable.
|
|
262 (For toolbars, the code above should work 99% of the time, because
|
|
263 toolbars are rarely changed. Since instantiation is trivial, multiple
|
|
264 specs are not useful---the first one always succeeds.)
|
|
265
|
|
266 In fact, @code{specifier-specs} is intended to be used to display specs
|
1138
|
267 to humans with a minimum of clutter. The robust way to access
|
|
268 specifications is via @code{specifier-spec-list}. @xref{Adding
|
|
269 Specifications}, for the definition of @dfn{spec-list}. @xref{Retrieving
|
|
270 Specifications}, for documentation of @code{specifier-specs} and
|
|
271 @code{specifier-spec-list}. To get the desired effect, replace the form
|
|
272 @code{(specifier-spec default-toolbar 'global)} with
|
1135
|
273
|
|
274 @example
|
|
275 (cdr (second (first (specifier-spec-list default-toolbar 'global))))
|
|
276 @end example
|
|
277
|
|
278 (It should be obvious why the example uses the lazy unreliable method!)
|
|
279
|
428
|
280 @node Specifiers In-Depth
|
|
281 @section In-Depth Overview of a Specifier
|
|
282 @cindex specification (in a specifier)
|
|
283 @cindex domain (in a specifier)
|
|
284 @cindex locale (in a specifier)
|
|
285 @cindex instantiator (in a specifier)
|
|
286 @cindex instancing (in a specifier)
|
|
287 @cindex instance (in a specifier)
|
|
288 @cindex inst-list (in a specifier)
|
|
289 @cindex inst-pair (in a specifier)
|
|
290 @cindex tag (in a specifier)
|
|
291 @cindex tag set (in a specifier)
|
|
292 @cindex specifier, specification
|
|
293 @cindex specifier, domain
|
|
294 @cindex specifier, locale
|
|
295 @cindex specifier, instantiator
|
|
296 @cindex specifier, instancing
|
|
297 @cindex specifier, instance
|
|
298 @cindex specifier, inst-list
|
|
299 @cindex specifier, inst-pair
|
|
300 @cindex specifier, tag
|
|
301 @cindex specifier, tag set
|
|
302
|
1135
|
303 Having variables vary according the editing context is very useful, and
|
|
304 the buffer is the natural ``atomic'' unit of editing context. In a GUI
|
|
305 environment, it can be similarly useful to have variables whose values
|
|
306 vary according to display context. The atomic unit of display context
|
|
307 is the Emacs window. Buffers are cleanly grouped by modes, but windows
|
|
308 are not so easily pigeonholed. On the one hand, a window displays a
|
|
309 buffer, and thus one possible hierarchy is window, buffer, mode. On the
|
|
310 other, a window is a component of a frame. This generates the window,
|
|
311 frame, device hierarchy. Finally, there are objects such as toolbars
|
|
312 whose properties are described by specifiers. These do not fit
|
|
313 naturally into either hierarchy. This problem is as yet not cleanly
|
|
314 solved.
|
|
315
|
|
316 Another potential source of conceptual confusion is the instantiation
|
|
317 process. Instantiating a buffer-local variable is simple: at any given
|
|
318 point in time there is a current buffer, and its local values are used
|
|
319 and set whenever the variable is accessed, unless the programmer goes to
|
|
320 some special effort (uses @code{default-value} and @code{set-default}.
|
|
321 However, a specifier object encapsulates a set of @dfn{specifications},
|
|
322 each of which says what its value should be if a particular condition
|
|
323 applies. Several such conditions might apply simultaneously in a given
|
|
324 window.
|
|
325
|
428
|
326 For example, one specification might be ``The value should be
|
|
327 darkseagreen2 on X devices'' another might be ``The value should be blue
|
1135
|
328 in the *Help* buffer''. So what do we do for "the *Help* buffer on an X
|
|
329 device"? The answer is simple: give each type of locale a priority and
|
|
330 check them in priority order, returning the first instantiator that
|
|
331 successfully instantiates a value.
|
|
332
|
428
|
333 Given a specifier, a logical question is ``What is its value in a
|
|
334 particular situation?'' This involves looking through the specifications
|
|
335 to see which ones apply to this particular situation, and perhaps
|
|
336 preferring one over another if more than one applies. In specifier
|
|
337 terminology, a ``particular situation'' is called a @dfn{domain}, and
|
|
338 determining its value in a particular domain is called @dfn{instancing}.
|
|
339 Most of the time, a domain is identified by a particular window. For
|
|
340 example, if the redisplay engine is drawing text in the default face in
|
|
341 a particular window, it retrieves the specifier for the foreground color
|
|
342 of the default face and @dfn{instances} it in the domain given by that
|
|
343 window; in other words, it asks the specifier, ``What is your value in
|
|
344 this window?''.
|
|
345
|
1135
|
346 Note that the redisplay example is in a sense canonical. That is,
|
|
347 specifiers are designed to present a uniform and @emph{efficient} API
|
|
348 to redisplay. It is the efficiency constraint that motivates the
|
|
349 introduction of specifier tags, and many restrictions on access (for
|
|
350 example, a buffer is not a domain, and you cannot instantiate a
|
|
351 specifier over a buffer).
|
|
352
|
428
|
353 More specifically, a specifier contains a set of @dfn{specifications},
|
|
354 each of which associates a @dfn{locale} (a window object, a buffer
|
|
355 object, a frame object, a device object, or the symbol @code{global})
|
|
356 with an @dfn{inst-list}, which is a list of one or more
|
|
357 @dfn{inst-pairs}. (For each possible locale, there can be at most one
|
|
358 specification containing that locale.) Each inst-pair is a cons of a
|
|
359 @dfn{tag set} (an unordered list of zero or more symbols, or @dfn{tags})
|
|
360 and an @dfn{instantiator} (the allowed form of this varies depending on
|
|
361 the type of specifier). In a given specification, there may be more
|
|
362 than one inst-pair with the same tag set; this is unlike for locales.
|
|
363
|
|
364 The tag set is used to restrict the sorts of devices over which the
|
|
365 instantiator is valid and to uniquely identify instantiators added by a
|
|
366 particular application, so that different applications can work on the
|
|
367 same specifier and not interfere with each other. Each tag can have a
|
|
368 @dfn{predicate} associated with it, which is a function of one argument
|
|
369 (a device) that specifies whether the tag matches that particular
|
|
370 device. (If a tag does not have a predicate, it matches all devices.)
|
|
371 All tags in a tag set must match a device for the associated inst-pair
|
|
372 to be instantiable over that device. (A null tag set is perfectly
|
1135
|
373 valid, and trivially matches all devices.)
|
428
|
374
|
1135
|
375 @c #### don't we have more device types now, gtk, ms-windows, mac-carbon?
|
428
|
376 The valid device types (normally @code{x}, @code{tty}, and
|
|
377 @code{stream}) and device classes (normally @code{color},
|
|
378 @code{grayscale}, and @code{mono}) can always be used as tags, and match
|
|
379 devices of the associated type or class (@pxref{Consoles and Devices}).
|
|
380 User-defined tags may be defined, with an optional predicate specified.
|
|
381 An application can create its own tag, use it to mark all its
|
|
382 instantiators, and be fairly confident that it will not interfere with
|
440
|
383 other applications that modify the same specifier---Functions that add
|
428
|
384 a specification to a specifier usually only overwrite existing
|
|
385 inst-pairs with the same tag set as was given, and a particular tag or
|
|
386 tag set can be specified when removing instantiators.
|
|
387
|
|
388 When a specifier is instanced in a domain, both the locale and the tag
|
|
389 set can be viewed as specifying necessary conditions that must apply in
|
|
390 that domain for an instantiator to be considered as a possible result of
|
|
391 the instancing. More specific locales always override more general
|
|
392 locales (thus, there is no particular ordering of the specifications in
|
|
393 a specifier); however, the tag sets are simply considered in the order
|
|
394 that the inst-pairs occur in the specification's inst-list.
|
|
395
|
|
396 Note also that the actual object that results from the instancing
|
|
397 (called an @dfn{instance object}) may not be the same as the instantiator
|
|
398 from which it was derived. For some specifier types (such as integer
|
|
399 specifiers and boolean specifiers), the instantiator will be returned
|
|
400 directly as the instance object. For other types, however, this
|
|
401 is not the case. For example, for font specifiers, the instantiator
|
|
402 is a font-description string and the instance object is a font-instance
|
|
403 object, which describes how the font is displayed on a particular device.
|
|
404 A font-instance object encapsulates such things as the actual font name
|
|
405 used to display the font on that device (a font-description string
|
|
406 under X is usually a wildcard specification that may resolve to
|
|
407 different font names, with possibly different foundries, widths, etc.,
|
|
408 on different devices), the extra properties of that font on that
|
|
409 device, etc. Furthermore, this conversion (called @dfn{instantiation})
|
440
|
410 might fail---a font or color might not exist on a particular device,
|
428
|
411 for example.
|
|
412
|
|
413 @node Specifier Instancing
|
|
414 @section How a Specifier Is Instanced
|
|
415 @cindex fallback (in a specifier)
|
|
416 @cindex specifier, fallback
|
|
417
|
|
418 Instancing of a specifier in a particular window domain proceeds as
|
|
419 follows:
|
|
420
|
|
421 @itemize @bullet
|
|
422 @item
|
|
423 First, XEmacs searches for a specification whose locale is the same as
|
|
424 the window. If that fails, the search is repeated, looking for a locale
|
|
425 that is the same as the window's buffer. If that fails, the search is
|
|
426 repeated using the window's frame, then using the device that frame is
|
|
427 on. Finally, the specification whose locale is the symbol @code{global}
|
|
428 (if there is such a specification) is considered.
|
|
429 @item
|
|
430 The inst-pairs contained in the specification that was found are
|
|
431 considered in their order in the inst-list, looking for one whose tag
|
|
432 set matches the device that is derived from the window domain. (The
|
|
433 tag set is an unordered list of zero or more tag symbols. For all
|
|
434 tags that have predicates associated with them, the predicate must
|
|
435 match the device.)
|
|
436 @item
|
|
437 If a matching tag set is found, the corresponding instantiator is passed
|
|
438 to the specifier's instantiation method, which is specific to the type
|
|
439 of the specifier. If it succeeds, the resulting instance object is
|
|
440 returned as the result of the instancing and the instancing is done.
|
|
441 Otherwise, the operation continues, looking for another matching
|
|
442 inst-pair in the current specification.
|
|
443 @item
|
|
444 When there are no more inst-pairs to be considered in the current
|
|
445 specification, the search starts over, looking for another specification
|
|
446 as in the first step above.
|
|
447 @item
|
|
448 If all specifications are exhausted and no instance object can be
|
|
449 derived, the instancing fails. (Actually, this is not completely true.
|
|
450 Some specifier objects for built-in properties have a @dfn{fallback}
|
|
451 value, which is either an inst-list or another specifier object, that is
|
|
452 consulted if the instancing is about to fail. If it is an inst-list,
|
|
453 the searching proceeds using the inst-pairs in that list. If it is a
|
|
454 specifier, the entire instancing starts over using that specifier
|
|
455 instead of the given one. Fallback values are set by the C code and
|
|
456 cannot be modified, except perhaps indirectly, using any Lisp functions.
|
|
457 The purpose of them is to supply some values to make sure that
|
|
458 instancing of built-in properties can't fail and to implement some basic
|
|
459 specifier inheritance, such as the fact that faces inherit their
|
|
460 properties from the @code{default} face.)
|
|
461 @end itemize
|
|
462
|
|
463 It is also possible to instance a specifier over a frame domain or
|
|
464 device domain instead of over a window domain. The C code, for example,
|
|
465 instances the @code{top-toolbar-height} variable over a frame domain in
|
|
466 order to determine the height of a frame's top toolbar. Instancing over
|
|
467 a frame or device is similar to instancing over a window except that
|
|
468 specifications for locales that cannot be derived from the domain are
|
|
469 ignored. Specifically, instancing over a frame looks first for frame
|
|
470 locales, then device locales, then the @code{global} locale. Instancing
|
|
471 over a device domain looks only for device locales and the @code{global}
|
|
472 locale.
|
|
473
|
|
474 @node Specifier Types
|
|
475 @section Specifier Types
|
|
476
|
|
477 There are various different types of specifiers. The type of a
|
|
478 specifier controls what sorts of instantiators are valid, how an
|
|
479 instantiator is instantiated, etc. Here is a list of built-in specifier
|
|
480 types:
|
|
481
|
|
482 @table @code
|
|
483 @item boolean
|
|
484 The valid instantiators are the symbols @code{t} and @code{nil}.
|
|
485 Instance objects are the same as instantiators so no special
|
|
486 instantiation function is needed.
|
|
487
|
|
488 @item integer
|
|
489 The valid instantiators are integers. Instance objects are the same as
|
|
490 instantiators so no special instantiation function is needed.
|
|
491 @code{modeline-shadow-thickness} is an example of an integer specifier
|
|
492 (negative thicknesses indicate that the shadow is drawn recessed instead
|
|
493 of raised).
|
|
494
|
|
495 @item natnum
|
|
496 The valid instantiators are natnums (non-negative integers). Instance
|
|
497 objects are the same as instantiators so no special instantiation
|
|
498 function is needed. Natnum specifiers are used for dimension variables
|
|
499 such as @code{top-toolbar-height}.
|
|
500
|
|
501 @item generic
|
|
502 All Lisp objects are valid instantiators. Instance objects are the same
|
|
503 as instantiators so no special instantiation function is needed.
|
|
504
|
|
505 @item font
|
|
506 The valid instantiators are strings describing fonts or vectors
|
|
507 indicating inheritance from the font of some face. Instance objects are
|
|
508 font-instance objects, which are specific to a particular device. The
|
|
509 instantiation method for font specifiers can fail, unlike for integer,
|
|
510 natnum, boolean, and generic specifiers.
|
|
511
|
|
512 @item color
|
|
513 The valid instantiators are strings describing colors or vectors
|
|
514 indicating inheritance from the foreground or background of some face.
|
|
515 Instance objects are color-instance objects, which are specific to a
|
|
516 particular device. The instantiation method for color specifiers can fail,
|
|
517 as for font specifiers.
|
|
518
|
|
519 @item image
|
|
520 Images are perhaps the most complicated type of built-in specifier. The
|
|
521 valid instantiators are strings (a filename, inline data for a pixmap,
|
|
522 or text to be displayed in a text glyph) or vectors describing inline
|
|
523 data of various sorts or indicating inheritance from the
|
|
524 background-pixmap property of some face. Instance objects are either
|
|
525 strings (for text images), image-instance objects (for pixmap images),
|
|
526 or subwindow objects (for subwindow images). The instantiation method
|
|
527 for image specifiers can fail, as for font and color specifiers.
|
|
528
|
|
529 @item face-boolean
|
|
530 The valid instantiators are the symbols @code{t} and @code{nil} and
|
|
531 vectors indicating inheritance from a boolean property of some face.
|
|
532 Specifiers of this sort are used for all of the built-in boolean
|
|
533 properties of faces. Instance objects are either the symbol @code{t}
|
|
534 or the symbol @code{nil}.
|
|
535
|
|
536 @item toolbar
|
|
537 The valid instantiators are toolbar descriptors, which are lists
|
|
538 of toolbar-button descriptors (each of which is a vector of two
|
|
539 or four elements). @xref{Toolbar}, for more information.
|
|
540 @end table
|
|
541
|
|
542 Color and font instance objects can also be used in turn as
|
|
543 instantiators for a new color or font instance object. Since these
|
|
544 instance objects are device-specific, the instantiator can be used
|
|
545 directly as the new instance object, but only if they are of the same
|
|
546 device. If the devices differ, the base color or font of the
|
|
547 instantiating object is effectively used instead as the instantiator.
|
|
548
|
|
549 @xref{Faces and Window-System Objects}, for more information on fonts,
|
|
550 colors, and face-boolean specifiers. @xref{Glyphs}, for more information
|
|
551 about image specifiers. @xref{Toolbar}, for more information on toolbar
|
|
552 specifiers.
|
|
553
|
|
554 @defun specifier-type specifier
|
|
555 This function returns the type of @var{specifier}. The returned value
|
|
556 will be a symbol: one of @code{integer}, @code{boolean}, etc., as
|
|
557 listed in the above table.
|
|
558 @end defun
|
|
559
|
|
560 Functions are also provided to query whether an object is a particular
|
|
561 kind of specifier:
|
|
562
|
|
563 @defun boolean-specifier-p object
|
|
564 This function returns non-@code{nil} if @var{object} is a boolean
|
|
565 specifier.
|
|
566 @end defun
|
|
567
|
|
568 @defun integer-specifier-p object
|
|
569 This function returns non-@code{nil} if @var{object} is an integer
|
|
570 specifier.
|
|
571 @end defun
|
|
572
|
|
573 @defun natnum-specifier-p object
|
|
574 This function returns non-@code{nil} if @var{object} is a natnum
|
|
575 specifier.
|
|
576 @end defun
|
|
577
|
|
578 @defun generic-specifier-p object
|
|
579 This function returns non-@code{nil} if @var{object} is a generic
|
|
580 specifier.
|
|
581 @end defun
|
|
582
|
|
583 @defun face-boolean-specifier-p object
|
|
584 This function returns non-@code{nil} if @var{object} is a face-boolean
|
|
585 specifier.
|
|
586 @end defun
|
|
587
|
|
588 @defun toolbar-specifier-p object
|
|
589 This function returns non-@code{nil} if @var{object} is a toolbar
|
|
590 specifier.
|
|
591 @end defun
|
|
592
|
|
593 @defun font-specifier-p object
|
|
594 This function returns non-@code{nil} if @var{object} is a font
|
|
595 specifier.
|
|
596 @end defun
|
|
597
|
|
598 @defun color-specifier-p object
|
|
599 This function returns non-@code{nil} if @var{object} is a color
|
|
600 specifier.
|
|
601 @end defun
|
|
602
|
|
603 @defun image-specifier-p object
|
|
604 This function returns non-@code{nil} if @var{object} is an image
|
|
605 specifier.
|
|
606 @end defun
|
|
607
|
|
608 @node Adding Specifications
|
|
609 @section Adding specifications to a Specifier
|
|
610
|
|
611 @defun add-spec-to-specifier specifier instantiator &optional locale tag-set how-to-add
|
|
612 This function adds a specification to @var{specifier}. The
|
|
613 specification maps from @var{locale} (which should be a window, buffer,
|
|
614 frame, device, or the symbol @code{global}, and defaults to
|
|
615 @code{global}) to @var{instantiator}, whose allowed values depend on the
|
|
616 type of the specifier. Optional argument @var{tag-set} limits the
|
|
617 instantiator to apply only to the specified tag set, which should be a
|
|
618 list of tags all of which must match the device being instantiated over
|
|
619 (tags are a device type, a device class, or tags defined with
|
|
620 @code{define-specifier-tag}). Specifying a single symbol for
|
|
621 @var{tag-set} is equivalent to specifying a one-element list containing
|
|
622 that symbol. Optional argument @var{how-to-add} specifies what to do if
|
|
623 there are already specifications in the specifier. It should be one of
|
|
624
|
|
625 @table @code
|
|
626 @item prepend
|
|
627 Put at the beginning of the current list of instantiators for @var{locale}.
|
|
628 @item append
|
|
629 Add to the end of the current list of instantiators for @var{locale}.
|
|
630 @item remove-tag-set-prepend
|
|
631 This is the default. Remove any existing instantiators whose tag set is
|
|
632 the same as @var{tag-set}; then put the new instantiator at the
|
|
633 beginning of the current list.
|
|
634 @item remove-tag-set-append
|
|
635 Remove any existing instantiators whose tag set is the same as
|
|
636 @var{tag-set}; then put the new instantiator at the end of the current
|
|
637 list.
|
|
638 @item remove-locale
|
|
639 Remove all previous instantiators for this locale before adding the new
|
|
640 spec.
|
|
641 @item remove-locale-type
|
|
642 Remove all specifications for all locales of the same type as
|
|
643 @var{locale} (this includes @var{locale} itself) before adding the new
|
|
644 spec.
|
|
645 @item remove-all
|
|
646 Remove all specifications from the specifier before adding the new spec.
|
|
647 @end table
|
|
648
|
|
649 @code{remove-tag-set-prepend} is the default.
|
|
650
|
|
651 You can retrieve the specifications for a particular locale or locale type
|
|
652 with the function @code{specifier-spec-list} or @code{specifier-specs}.
|
|
653 @end defun
|
|
654
|
|
655 @defun add-spec-list-to-specifier specifier spec-list &optional how-to-add
|
|
656 This function adds a @dfn{spec-list} (a list of specifications) to
|
|
657 @var{specifier}. The format of a spec-list is
|
|
658
|
|
659 @example
|
|
660 @code{((@var{locale} (@var{tag-set} . @var{instantiator}) ...) ...)}
|
|
661 @end example
|
|
662
|
|
663 where
|
|
664
|
|
665 @itemize @bullet
|
|
666 @item
|
|
667 @var{locale} := a window, a buffer, a frame, a device, or @code{global}
|
|
668 @item
|
|
669 @var{tag-set} := an unordered list of zero or more @var{tags}, each of
|
|
670 which is a symbol
|
|
671 @item
|
|
672 @var{tag} := a device class (@pxref{Consoles and Devices}), a device type,
|
|
673 or a tag defined with @code{define-specifier-tag}
|
|
674 @item
|
|
675 @var{instantiator} := format determined by the type of specifier
|
|
676 @end itemize
|
|
677
|
|
678 The pair @code{(@var{tag-set} . @var{instantiator})} is called an
|
|
679 @dfn{inst-pair}. A list of inst-pairs is called an @dfn{inst-list}.
|
|
680 The pair @code{(@var{locale} . @var{inst-list})} is called a
|
|
681 @dfn{specification}. A spec-list, then, can be viewed as a list of
|
|
682 specifications.
|
|
683
|
|
684 @var{how-to-add} specifies how to combine the new specifications with
|
|
685 the existing ones, and has the same semantics as for
|
|
686 @code{add-spec-to-specifier}.
|
|
687
|
1875
|
688 The higher-level function @code{set-specifier} is often
|
|
689 more convenient because it allows abbreviations of spec-lists to be used
|
|
690 instead of the heavily nested canonical syntax. However, one should
|
|
691 take great care in using them with specifiers types which can have lists
|
|
692 as instantiators, such as toolbar specifiers and generic specifiers. In
|
|
693 those cases it's probably best to use @code{add-spec-to-specifier} or
|
|
694 @code{add-spec-list-to-specifier}.
|
428
|
695 @end defun
|
|
696
|
444
|
697 @defspec let-specifier specifier-list &rest body
|
428
|
698 This special form temporarily adds specifications to specifiers,
|
|
699 evaluates forms in @var{body} and restores the specifiers to their
|
|
700 previous states. The specifiers and their temporary specifications are
|
|
701 listed in @var{specifier-list}.
|
|
702
|
|
703 The format of @var{specifier-list} is
|
|
704
|
|
705 @example
|
|
706 ((@var{specifier} @var{value} &optional @var{locale} @var{tag-set} @var{how-to-add}) ...)
|
|
707 @end example
|
|
708
|
|
709 @var{specifier} is the specifier to be temporarily modified.
|
|
710 @var{value} is the instantiator to be temporarily added to specifier in
|
|
711 @var{locale}. @var{locale}, @var{tag-set} and @var{how-to-add} have the
|
|
712 same meaning as in @code{add-spec-to-specifier}.
|
|
713
|
|
714 This special form is implemented as a macro; the code resulting from
|
|
715 macro expansion will add specifications to specifiers using
|
|
716 @code{add-spec-to-specifier}. After forms in @var{body} are evaluated,
|
|
717 the temporary specifications are removed and old specifier spec-lists
|
|
718 are restored.
|
|
719
|
|
720 @var{locale}, @var{tag-set} and @var{how-to-add} may be omitted, and
|
|
721 default to @code{nil}. The value of the last form in @var{body} is
|
|
722 returned.
|
|
723
|
|
724 NOTE: If you want the specifier's instance to change in all
|
|
725 circumstances, use @code{(selected-window)} as the @var{locale}. If
|
|
726 @var{locale} is @code{nil} or omitted, it defaults to @code{global}.
|
|
727
|
|
728 The following example removes the 3D modeline effect in the currently
|
|
729 selected window for the duration of a second:
|
|
730
|
|
731 @example
|
|
732 (let-specifier ((modeline-shadow-thickness 0 (selected-window)))
|
|
733 (sit-for 1))
|
|
734 @end example
|
444
|
735 @end defspec
|
428
|
736
|
444
|
737 @defun set-specifier specifier value &optional locale tag-set how-to-add
|
428
|
738 This function adds some specifications to @var{specifier}. @var{value}
|
|
739 can be a single instantiator or tagged instantiator (added as a global
|
|
740 specification), a list of tagged and/or untagged instantiators (added as
|
|
741 a global specification), a cons of a locale and instantiator or locale
|
|
742 and instantiator list, a list of such conses, or nearly any other
|
|
743 reasonable form. More specifically, @var{value} can be anything
|
1875
|
744 accepted by @code{canonicalize-spec-list} (described below).
|
428
|
745
|
444
|
746 @var{locale}, @var{tag-set}, and @var{how-to-add} are the same as in
|
|
747 @code{add-spec-to-specifier}.
|
428
|
748
|
|
749 Note that @code{set-specifier} is exactly complementary to
|
|
750 @code{specifier-specs} except in the case where @var{specifier} has no
|
|
751 specs at all in it but @code{nil} is a valid instantiator (in that case,
|
|
752 @code{specifier-specs} will return @code{nil} (meaning no specs) and
|
|
753 @code{set-specifier} will interpret the @code{nil} as meaning ``I'm
|
|
754 adding a global instantiator and its value is @code{nil}''), or in
|
|
755 strange cases where there is an ambiguity between a spec-list and an
|
|
756 inst-list, etc. (The built-in specifier types are designed in such a way
|
1875
|
757 as to avoid any such ambiguities.) For robust code,
|
|
758 @code{set-specifier} should probably be avoided for specifier types
|
|
759 which accept lists as instantiators (currently toolbar specifiers and
|
|
760 generic specifiers).
|
428
|
761
|
|
762 If you want to work with spec-lists, you should probably not use these
|
|
763 functions, but should use the lower-level functions
|
|
764 @code{specifier-spec-list} and @code{add-spec-list-to-specifier}. These
|
|
765 functions always work with fully-qualified spec-lists; thus, there is no
|
|
766 ambiguity.
|
|
767 @end defun
|
|
768
|
|
769 @defun canonicalize-inst-pair inst-pair specifier-type &optional noerror
|
|
770 This function canonicalizes the given @var{inst-pair}.
|
|
771
|
|
772 @var{specifier-type} specifies the type of specifier that this
|
|
773 @var{spec-list} will be used for.
|
|
774
|
|
775 Canonicalizing means converting to the full form for an inst-pair, i.e.
|
|
776 @code{(@var{tag-set} . @var{instantiator})}. A single, untagged
|
|
777 instantiator is given a tag set of @code{nil} (the empty set), and a
|
|
778 single tag is converted into a tag set consisting only of that tag.
|
|
779
|
|
780 If @var{noerror} is non-@code{nil}, signal an error if the inst-pair is
|
|
781 invalid; otherwise return @code{t}.
|
|
782 @end defun
|
|
783
|
|
784 @defun canonicalize-inst-list inst-list specifier-type &optional noerror
|
|
785 This function canonicalizes the given @var{inst-list} (a list of
|
|
786 inst-pairs).
|
|
787
|
|
788 @var{specifier-type} specifies the type of specifier that this @var{inst-list}
|
|
789 will be used for.
|
|
790
|
|
791 Canonicalizing means converting to the full form for an inst-list, i.e.
|
|
792 @code{((@var{tag-set} . @var{instantiator}) ...)}. This function
|
|
793 accepts a single inst-pair or any abbreviation thereof or a list of
|
|
794 (possibly abbreviated) inst-pairs. (See @code{canonicalize-inst-pair}.)
|
|
795
|
|
796 If @var{noerror} is non-@code{nil}, signal an error if the inst-list is
|
|
797 invalid; otherwise return @code{t}.
|
|
798 @end defun
|
|
799
|
|
800 @defun canonicalize-spec spec specifier-type &optional noerror
|
|
801 This function canonicalizes the given @var{spec} (a specification).
|
|
802
|
|
803 @var{specifier-type} specifies the type of specifier that this
|
|
804 @var{spec-list} will be used for.
|
|
805
|
|
806 Canonicalizing means converting to the full form for a spec, i.e.
|
|
807 @code{(@var{locale} (@var{tag-set} . @var{instantiator}) ...)}. This
|
|
808 function accepts a possibly abbreviated inst-list or a cons of a locale
|
|
809 and a possibly abbreviated inst-list. (See
|
|
810 @code{canonicalize-inst-list}.)
|
|
811
|
|
812 If @var{noerror} is @code{nil}, signal an error if the specification is
|
|
813 invalid; otherwise return @code{t}.
|
|
814 @end defun
|
|
815
|
|
816 @defun canonicalize-spec-list spec-list specifier-type &optional noerror
|
|
817 This function canonicalizes the given @var{spec-list} (a list of
|
|
818 specifications).
|
|
819
|
|
820 @var{specifier-type} specifies the type of specifier that this
|
|
821 @var{spec-list} will be used for.
|
|
822
|
1875
|
823 If @var{noerror} is @code{nil}, signal an error if the spec-list is
|
|
824 invalid; otherwise return @code{t} for an invalid spec-list. (Note that
|
|
825 this cannot be confused with a canonical spec-list.)
|
|
826
|
428
|
827 Canonicalizing means converting to the full form for a spec-list, i.e.
|
|
828 @code{((@var{locale} (@var{tag-set} . @var{instantiator}) ...) ...)}.
|
|
829 This function accepts a possibly abbreviated specification or a list of
|
|
830 such things. (See @code{canonicalize-spec}.) This is the function used
|
|
831 to convert spec-lists accepted by @code{set-specifier} and such into a
|
|
832 form suitable for @code{add-spec-list-to-specifier}.
|
|
833
|
|
834 This function tries extremely hard to resolve any ambiguities,
|
|
835 and the built-in specifier types (font, image, toolbar, etc.) are
|
|
836 designed so that there won't be any ambiguities.
|
|
837
|
1875
|
838 The canonicalization algorithm is as follows:
|
|
839
|
|
840 @enumerate
|
|
841 @item
|
|
842 Attempt to parse @var{spec-list} as a single, possibly abbreviated,
|
|
843 specification.
|
|
844 @item
|
|
845 If that fails, attempt to parse @var{spec-list} as a list of (abbreviated)
|
|
846 specifications.
|
|
847 @item
|
|
848 If that fails, @var{spec-list} is invalid.
|
|
849 @end enumerate
|
|
850
|
|
851 A possibly abbreviated specification @var{spec} is parsed by
|
|
852
|
|
853 @enumerate
|
|
854 @item
|
|
855 Attempt to parse @var{spec} as a possibly abbreviated inst-list.
|
|
856 @item
|
|
857 If that fails, attempt to parse @var{spec} as a cons of a locale and an
|
|
858 (abbreviated) inst-list.
|
|
859 @item
|
|
860 If that fails, @var{spec} is invalid.
|
|
861 @end enumerate
|
|
862
|
|
863 A possibly abbreviated inst-list @var{inst-list} is parsed by
|
|
864
|
|
865 @enumerate
|
|
866 @item
|
|
867 Attempt to parse @var{inst-list} as a possibly abbreviated inst-pair.
|
|
868 @item
|
|
869 If that fails, attempt to parse @var{inst-list} as a list of (abbreviated)
|
|
870 inst-pairs.
|
|
871 @item
|
|
872 If that fails, @var{inst-list} is invalid.
|
|
873 @end enumerate
|
|
874
|
|
875 A possibly abbreviated inst-pair @var{inst-pair} is parsed by
|
|
876
|
|
877 @enumerate
|
|
878 @item
|
|
879 Check if @var{inst-pair} is @code{valid-instantiator-p}.
|
|
880 @item
|
|
881 If not, check if @var{inst-pair} is a cons of something that is a tag, ie,
|
|
882 @code{valid-specifier-tag-p}, and something that is @code{valid-instantiator-p}.
|
|
883 @item
|
|
884 If not, check if @var{inst-pair} is a cons of a list of tags and something that
|
|
885 is @code{valid-instantiator-p}.
|
|
886 @item
|
|
887 Otherwise, @var{inst-pair} is invalid.
|
|
888 @end enumerate
|
|
889
|
|
890 In summary, this function generally prefers more abbreviated forms.
|
428
|
891 @end defun
|
|
892
|
|
893 @node Retrieving Specifications
|
|
894 @section Retrieving the Specifications from a Specifier
|
|
895
|
|
896 @defun specifier-spec-list specifier &optional locale tag-set exact-p
|
|
897 This function returns the spec-list of specifications for
|
|
898 @var{specifier} in @var{locale}.
|
|
899
|
|
900 If @var{locale} is a particular locale (a window, buffer, frame, device,
|
|
901 or the symbol @code{global}), a spec-list consisting of the
|
|
902 specification for that locale will be returned.
|
|
903
|
444
|
904 If @var{locale} is a locale type (i.e. one of the symbols @code{window},
|
428
|
905 @code{buffer}, @code{frame}, or @code{device}), a spec-list of the
|
|
906 specifications for all locales of that type will be returned.
|
|
907
|
|
908 If @var{locale} is @code{nil} or the symbol @code{all}, a spec-list of
|
|
909 all specifications in @var{specifier} will be returned.
|
|
910
|
|
911 @var{locale} can also be a list of locales, locale types, and/or
|
|
912 @code{all}; the result is as if @code{specifier-spec-list} were called
|
|
913 on each element of the list and the results concatenated together.
|
|
914
|
|
915 Only instantiators where @var{tag-set} (a list of zero or more tags) is
|
|
916 a subset of (or possibly equal to) the instantiator's tag set are
|
444
|
917 returned. (The default value of @code{nil} is a subset of all tag sets,
|
428
|
918 so in this case no instantiators will be screened out.) If @var{exact-p}
|
|
919 is non-@code{nil}, however, @var{tag-set} must be equal to an
|
|
920 instantiator's tag set for the instantiator to be returned.
|
|
921 @end defun
|
|
922
|
|
923 @defun specifier-specs specifier &optional locale tag-set exact-p
|
|
924 This function returns the specification(s) for @var{specifier} in
|
|
925 @var{locale}.
|
|
926
|
|
927 If @var{locale} is a single locale or is a list of one element
|
|
928 containing a single locale, then a ``short form'' of the instantiators
|
|
929 for that locale will be returned. Otherwise, this function is identical
|
|
930 to @code{specifier-spec-list}.
|
|
931
|
|
932 The ``short form'' is designed for readability and not for ease of use
|
|
933 in Lisp programs, and is as follows:
|
|
934
|
|
935 @enumerate
|
|
936 @item
|
|
937 If there is only one instantiator, then an inst-pair (i.e. cons of tag
|
|
938 and instantiator) will be returned; otherwise a list of inst-pairs will
|
|
939 be returned.
|
|
940 @item
|
|
941 For each inst-pair returned, if the instantiator's tag is @code{any},
|
|
942 the tag will be removed and the instantiator itself will be returned
|
|
943 instead of the inst-pair.
|
|
944 @item
|
|
945 If there is only one instantiator, its value is @code{nil}, and its tag
|
|
946 is @code{any}, a one-element list containing @code{nil} will be returned
|
|
947 rather than just @code{nil}, to distinguish this case from there being
|
|
948 no instantiators at all.
|
|
949 @end enumerate
|
|
950
|
|
951 @end defun
|
|
952
|
|
953 @defun specifier-fallback specifier
|
|
954 This function returns the fallback value for @var{specifier}. Fallback
|
|
955 values are provided by the C code for certain built-in specifiers to
|
|
956 make sure that instancing won't fail even if all specs are removed from
|
|
957 the specifier, or to implement simple inheritance behavior (e.g. this
|
|
958 method is used to ensure that faces other than @code{default} inherit
|
|
959 their attributes from @code{default}). By design, you cannot change the
|
|
960 fallback value, and specifiers created with @code{make-specifier} will
|
|
961 never have a fallback (although a similar, Lisp-accessible capability
|
|
962 may be provided in the future to allow for inheritance).
|
|
963
|
|
964 The fallback value will be an inst-list that is instanced like
|
|
965 any other inst-list, a specifier of the same type as @var{specifier}
|
|
966 (results in inheritance), or @code{nil} for no fallback.
|
|
967
|
|
968 When you instance a specifier, you can explicitly request that the
|
|
969 fallback not be consulted. (The C code does this, for example, when
|
|
970 merging faces.) See @code{specifier-instance}.
|
|
971 @end defun
|
|
972
|
|
973 @node Specifier Tag Functions
|
|
974 @section Working With Specifier Tags
|
|
975
|
|
976 A specifier tag set is an entity that is attached to an instantiator
|
|
977 and can be used to restrict the scope of that instantiator to a
|
|
978 particular device class or device type and/or to mark instantiators
|
|
979 added by a particular package so that they can be later removed.
|
|
980
|
442
|
981 A specifier tag set consists of a list of zero or more specifier tags,
|
428
|
982 each of which is a symbol that is recognized by XEmacs as a tag. (The
|
|
983 valid device types and device classes are always tags, as are any tags
|
|
984 defined by @code{define-specifier-tag}.) It is called a ``tag set'' (as
|
|
985 opposed to a list) because the order of the tags or the number of times
|
|
986 a particular tag occurs does not matter.
|
|
987
|
|
988 Each tag has a predicate associated with it, which specifies whether
|
|
989 that tag applies to a particular device. The tags which are device
|
|
990 types and classes match devices of that type or class. User-defined
|
|
991 tags can have any predicate, or none (meaning that all devices match).
|
|
992 When attempting to instance a specifier, a particular instantiator is
|
|
993 only considered if the device of the domain being instanced over matches
|
|
994 all tags in the tag set attached to that instantiator.
|
|
995
|
|
996 Most of the time, a tag set is not specified, and the instantiator gets
|
|
997 a null tag set, which matches all devices.
|
|
998
|
|
999 @defun valid-specifier-tag-p tag
|
|
1000 This function returns non-@code{nil} if @var{tag} is a valid specifier
|
|
1001 tag.
|
|
1002 @end defun
|
|
1003
|
|
1004 @defun valid-specifier-tag-set-p tag-set
|
|
1005 This function returns non-@code{nil} if @var{tag-set} is a valid
|
|
1006 specifier tag set.
|
|
1007 @end defun
|
|
1008
|
|
1009 @defun canonicalize-tag-set tag-set
|
|
1010 This function canonicalizes the given tag set. Two canonicalized tag
|
|
1011 sets can be compared with @code{equal} to see if they represent the same
|
|
1012 tag set. (Specifically, canonicalizing involves sorting by symbol name
|
|
1013 and removing duplicates.)
|
|
1014 @end defun
|
|
1015
|
|
1016 @defun device-matches-specifier-tag-set-p device tag-set
|
|
1017 This function returns non-@code{nil} if @var{device} matches specifier
|
|
1018 tag set @var{tag-set}. This means that @var{device} matches each tag in
|
|
1019 the tag set.
|
|
1020 @end defun
|
|
1021
|
|
1022 @defun define-specifier-tag tag &optional predicate
|
|
1023 This function defines a new specifier tag. If @var{predicate} is
|
|
1024 specified, it should be a function of one argument (a device) that
|
|
1025 specifies whether the tag matches that particular device. If
|
|
1026 @var{predicate} is omitted, the tag matches all devices.
|
|
1027
|
|
1028 You can redefine an existing user-defined specifier tag. However, you
|
|
1029 cannot redefine the built-in specifier tags (the device types and
|
|
1030 classes) or the symbols @code{nil}, @code{t}, @code{all}, or
|
|
1031 @code{global}.
|
|
1032 @end defun
|
|
1033
|
|
1034 @defun device-matching-specifier-tag-list &optional device
|
|
1035 This function returns a list of all specifier tags matching
|
|
1036 @var{device}. @var{device} defaults to the selected device if omitted.
|
|
1037 @end defun
|
|
1038
|
|
1039 @defun specifier-tag-list
|
|
1040 This function returns a list of all currently-defined specifier tags.
|
|
1041 This includes the built-in ones (the device types and classes).
|
|
1042 @end defun
|
|
1043
|
|
1044 @defun specifier-tag-predicate tag
|
|
1045 This function returns the predicate for the given specifier tag.
|
|
1046 @end defun
|
|
1047
|
|
1048 @node Specifier Instancing Functions
|
|
1049 @section Functions for Instancing a Specifier
|
|
1050
|
|
1051 @defun specifier-instance specifier &optional domain default no-fallback
|
1882
|
1052 This function instantiates @var{specifier} (returns its value) in
|
428
|
1053 @var{domain}. If no instance can be generated for this domain, return
|
|
1054 @var{default}.
|
|
1055
|
|
1056 @var{domain} should be a window, frame, or device. Other values that
|
|
1057 are legal as a locale (e.g. a buffer) are not valid as a domain because
|
|
1058 they do not provide enough information to identify a particular device
|
|
1059 (see @code{valid-specifier-domain-p}). @var{domain} defaults to the
|
|
1060 selected window if omitted.
|
|
1061
|
|
1062 @dfn{Instantiating} a specifier in a particular domain means determining
|
|
1063 the specifier's ``value'' in that domain. This is accomplished by
|
|
1064 searching through the specifications in the specifier that correspond to
|
|
1065 all locales that can be derived from the given domain, from specific to
|
|
1066 general. In most cases, the domain is an Emacs window. In that case
|
|
1067 specifications are searched for as follows:
|
|
1068
|
|
1069 @enumerate
|
|
1070 @item
|
|
1071 A specification whose locale is the window itself;
|
|
1072 @item
|
|
1073 A specification whose locale is the window's buffer;
|
|
1074 @item
|
|
1075 A specification whose locale is the window's frame;
|
|
1076 @item
|
|
1077 A specification whose locale is the window's frame's device;
|
|
1078 @item
|
|
1079 A specification whose locale is the symbol @code{global}.
|
|
1080 @end enumerate
|
|
1081
|
|
1082 If all of those fail, then the C-code-provided fallback value for this
|
|
1083 specifier is consulted (see @code{specifier-fallback}). If it is an
|
|
1084 inst-list, then this function attempts to instantiate that list just as
|
|
1085 when a specification is located in the first five steps above. If the
|
|
1086 fallback is a specifier, @code{specifier-instance} is called recursively
|
|
1087 on this specifier and the return value used. Note, however, that if the
|
|
1088 optional argument @var{no-fallback} is non-@code{nil}, the fallback
|
|
1089 value will not be consulted.
|
|
1090
|
|
1091 Note that there may be more than one specification matching a particular
|
|
1092 locale; all such specifications are considered before looking for any
|
|
1093 specifications for more general locales. Any particular specification
|
|
1094 that is found may be rejected because it is tagged to a particular
|
|
1095 device class (e.g. @code{color}) or device type (e.g. @code{x}) or both
|
|
1096 and the device for the given domain does not match this, or because the
|
|
1097 specification is not valid for the device of the given domain (e.g. the
|
|
1098 font or color name does not exist for this particular X server).
|
|
1099
|
|
1100 The returned value is dependent on the type of specifier. For example,
|
|
1101 for a font specifier (as returned by the @code{face-font} function), the
|
|
1102 returned value will be a font-instance object. For images, the returned
|
|
1103 value will be a string, pixmap, or subwindow.
|
|
1104 @end defun
|
|
1105
|
1875
|
1106 @defun specifier-matching-instance specifier matchspec &optional domain default no-fallback
|
1882
|
1107 This function returns an instance for @var{specifier} in @var{domain}
|
1875
|
1108 that matches @var{matchspec}. If no instance can be generated for
|
2028
|
1109 @var{domain}, return @var{default}. @xref{Specifier Compatibility Notes}.
|
1875
|
1110
|
|
1111 This function is identical to @code{specifier-instance} except that a
|
|
1112 specification will only be considered if it matches @var{matchspec}.
|
|
1113 The definition of ``match,'' and allowed values for @var{matchspec}, are
|
|
1114 dependent on the particular type of specifier. Here are some examples:
|
|
1115
|
|
1116 @itemize
|
|
1117 @item
|
|
1118 For chartable (e.g. display table) specifiers, @var{matchspec} should be a
|
|
1119 character, and the specification (a chartable) must give a value for
|
|
1120 that character in order to be considered. This allows you to specify,
|
1877
|
1121 @emph{e.g.}, a buffer-local display table that only gives values for particular
|
1875
|
1122 characters. All other characters are handled as if the buffer-local
|
|
1123 display table is not there. (Chartable specifiers are not yet
|
|
1124 implemented.)
|
1877
|
1125 @item
|
1875
|
1126 For font specifiers, @var{matchspec} should be a list (@var{charset}
|
|
1127 . @var{second-stage-p}), and the specification (a font string) must have
|
|
1128 a registry that matches the charset's registry. (This only makes sense
|
|
1129 with Mule support.) This makes it easy to choose a font that can
|
|
1130 display a particular character. (This is what redisplay does, in fact.)
|
|
1131 @var{second-stage-p} means to ignore the font's registry and instead
|
|
1132 look at the characters in the font to see if the font can support the
|
|
1133 charset. This currently only makes sense under MS Windows.
|
1878
|
1134 @end itemize
|
1875
|
1135 @end defun
|
|
1136
|
428
|
1137 @defun specifier-instance-from-inst-list specifier domain inst-list &optional default
|
|
1138 This function attempts to convert a particular inst-list into an
|
|
1139 instance. This attempts to instantiate @var{inst-list} in the given
|
|
1140 @var{domain}, as if @var{inst-list} existed in a specification in
|
|
1141 @var{specifier}. If the instantiation fails, @var{default} is returned.
|
|
1142 In most circumstances, you should not use this function; use
|
|
1143 @code{specifier-instance} instead.
|
|
1144 @end defun
|
|
1145
|
1869
|
1146 @node Specifier Examples
|
|
1147 @section Examples of Specifier Usage
|
428
|
1148
|
|
1149 Now let us present an example to clarify the theoretical discussions we
|
|
1150 have been through. In this example, we will use the general specifier
|
|
1151 functions for clarity. Keep in mind that many types of specifiers, and
|
|
1152 some other types of objects that are associated with specifiers
|
|
1153 (e.g. faces), provide convenience functions making it easier to work
|
|
1154 with objects of that type.
|
|
1155
|
|
1156 Let us consider the background color of the default face. A specifier
|
|
1157 is used to specify how that color will appear in different domains.
|
|
1158 First, let's retrieve the specifier:
|
|
1159
|
|
1160 @example
|
|
1161 (setq sp (face-property 'default 'background))
|
|
1162 @result{} #<color-specifier 0x3da>
|
|
1163 @end example
|
|
1164
|
|
1165 @example
|
|
1166 (specifier-specs sp)
|
|
1167 @result{} ((#<buffer "device.c"> (nil . "forest green"))
|
|
1168 (#<window on "Makefile" 0x8a2b> (nil . "hot pink"))
|
|
1169 (#<x-frame "emacs" 0x4ac> (nil . "puke orange")
|
440
|
1170 (nil . "moccasin"))
|
428
|
1171 (#<x-frame "VM" 0x4ac> (nil . "magenta"))
|
440
|
1172 (global ((tty) . "cyan") (nil . "white"))
|
428
|
1173 )
|
|
1174 @end example
|
|
1175
|
|
1176 Then, say we want to determine what the background color of the default
|
|
1177 face is for the window currently displaying the buffer @samp{*scratch*}.
|
|
1178 We call
|
|
1179
|
|
1180 @example
|
|
1181 (get-buffer-window "*scratch*")
|
|
1182 @result{} #<window on "*scratch*" 0x4ad>
|
|
1183 (window-frame (get-buffer-window "*scratch*"))
|
|
1184 @result{} #<x-frame "emacs" 0x4ac>
|
|
1185 (specifier-instance sp (get-buffer-window "*scratch*"))
|
|
1186 @result{} #<color-instance moccasin 47=(FFFF,E4E4,B5B5) 0x6309>
|
|
1187 @end example
|
|
1188
|
|
1189 Note that we passed a window to @code{specifier-instance}, not a buffer.
|
|
1190 We cannot pass a buffer because a buffer by itself does not provide enough
|
|
1191 information. The buffer might not be displayed anywhere at all, or
|
|
1192 could be displayed in many different frames on different devices.
|
|
1193
|
|
1194 The result is arrived at like this:
|
|
1195
|
|
1196 @enumerate
|
|
1197 @item
|
|
1198 First, we look for a specification matching the buffer displayed in the
|
440
|
1199 window, i.e. @samp{*scratch*}. There are none, so we proceed.
|
428
|
1200 @item
|
|
1201 Then, we look for a specification matching the window itself. Again, there
|
|
1202 are none.
|
|
1203 @item
|
|
1204 Then, we look for a specification matching the window's frame. The
|
|
1205 specification @code{(#<x-frame "emacs" 0x4ac> . "puke orange")} is
|
|
1206 found. We call the instantiation method for colors, passing it the
|
|
1207 locale we were searching over (i.e. the window, in this case) and the
|
|
1208 instantiator (@samp{"puke orange"}). However, the particular device
|
|
1209 which this window is on (let's say it's an X connection) doesn't
|
|
1210 recognize the color @samp{"puke orange"}, so the specification is
|
|
1211 rejected.
|
|
1212 @item
|
|
1213 So we continue looking for a specification matching the window's frame.
|
|
1214 We find @samp{(#<x-frame "emacs" 0x4ac> . "moccasin")}. Again, we
|
|
1215 call the instantiation method for colors. This time, the X server
|
|
1216 our window is on recognizes the color @samp{moccasin}, and so the
|
|
1217 instantiation method succeeds and returns a color instance.
|
|
1218 @end enumerate
|
|
1219
|
1869
|
1220 Here's another example, which implements something like GNU Emacs's
|
|
1221 ``frame-local'' variables.
|
|
1222
|
|
1223 @example
|
|
1224 ;; Implementation
|
|
1225
|
|
1226 ;; There are probably better ways to write this macro
|
|
1227 ;; Heaven help you if VAR is a buffer-local; you will become very
|
|
1228 ;; confused. Probably should error on that.
|
|
1229 (defmacro define-frame-local-variable (var)
|
|
1230 "Make the unbound symbol VAR become a frame-local variable."
|
|
1231 (let ((val (if (boundp var) (symbol-value var) nil)))
|
|
1232 `(progn
|
|
1233 (setq ,var (make-specifier 'generic))
|
|
1234 (add-spec-to-specifier ,var ',val 'global))))
|
|
1235
|
|
1236 ;; I'm not real happy about this terminology, how can `setq' be a defun?
|
|
1237 ;; But `frame-set' would have people writing "(frame-set 'foo value)".
|
|
1238 (defun frame-setq (var value &optional frame)
|
|
1239 "Set the local value of VAR to VALUE in FRAME.
|
|
1240
|
|
1241 FRAME defaults to the selected frame."
|
|
1242 (and frame (not (framep frame))
|
|
1243 (error 'invalid-argument "FRAME must be a frame", frame))
|
|
1244 (add-spec-to-specifier var value (or frame (selected-frame))))
|
|
1245
|
|
1246 (defun frame-value (var &optional frame)
|
|
1247 "Get the local value of VAR in FRAME.
|
|
1248
|
|
1249 FRAME defaults to the selected frame."
|
|
1250 (and frame (not (framep frame))
|
|
1251 (error 'invalid-argument "FRAME must be a frame", frame))
|
|
1252 ;; this is not just a map from frames to values; it also falls back
|
|
1253 ;; to the global value
|
|
1254 (specifier-instance var (or frame (selected-frame))))
|
|
1255
|
|
1256 ;; for completeness
|
|
1257 (defun frame-set-default (var value)
|
|
1258 "Set the default value of frame-local variable VAR to VALUE."
|
|
1259 (add-spec-to-specifier var value 'global))
|
|
1260
|
|
1261 (defun frame-get-default (var)
|
|
1262 "Get the default value of frame-local variable VAR."
|
|
1263 (car (specifier-specs var 'global)))
|
|
1264 @end example
|
|
1265
|
|
1266 Now you can execute the above definitions (eg, with @code{eval-last-sexp})
|
|
1267 and switch to @file{*scratch*} to play. Things will work differently if
|
|
1268 you already have a variable named @code{foo}.
|
|
1269
|
|
1270 @example
|
|
1271 ;; Usage
|
|
1272
|
|
1273 foo
|
|
1274 @error{} Symbol's value as variable is void: foo
|
|
1275
|
|
1276 (define-frame-local-variable foo)
|
|
1277 @result{} nil
|
|
1278
|
|
1279 ;; the value of foo is a specifier, which is an opaque object;
|
|
1280 ;; you must use accessor functions to get values
|
|
1281
|
|
1282 foo
|
|
1283 @result{} #<generic-specifier global=(nil) 0x4f5cb>
|
|
1284
|
|
1285 ;; since no frame-local value is set, the global value (which is the
|
|
1286 ;; constant `nil') is returned
|
|
1287 (frame-value foo)
|
|
1288 @result{} nil
|
|
1289
|
|
1290 ;; get the default explicitly
|
|
1291 (frame-get-default foo)
|
|
1292 @result{} nil
|
|
1293
|
|
1294 ;; get the whole specification list
|
|
1295 (specifier-specs foo 'global)
|
|
1296 @result{} (nil)
|
|
1297
|
|
1298 ;; give foo a frame-local value
|
|
1299
|
|
1300 (frame-setq foo 'bar)
|
|
1301 @result{} nil
|
|
1302
|
|
1303 ;; access foo in several ways
|
|
1304
|
|
1305 ;; Note that the print function for this kind of specifier only
|
|
1306 ;; gives you the global setting. To get the full list of specs for
|
|
1307 ;; debugging or study purposes, you must use specifier-specs or
|
|
1308 ;; specifier-spec-list.
|
|
1309 foo
|
|
1310 @result{} #<generic-specifier global=(nil) 0x4f5cb>
|
|
1311
|
|
1312 ;; get the whole specification list
|
|
1313 (specifier-specs foo)
|
|
1314 @result{} ((#<x-frame "Message" 0x1bd66> (nil . bar)) (global (nil)))
|
|
1315
|
|
1316 ;; get the frame-local value
|
|
1317 (frame-value foo)
|
|
1318 @result{} bar
|
|
1319
|
|
1320 ;; get the default explicitly
|
|
1321 (frame-get-default foo)
|
|
1322 @result{} nil
|
|
1323
|
|
1324 ;; Switch to another frame and evaluate:
|
|
1325 ;; C-x 5 o M-: (frame-setq foo 'baz) RET M-: (frame-value foo) RET
|
|
1326 @result{} baz
|
|
1327
|
|
1328 ;; Switch back.
|
|
1329 ;; C-x 5 o
|
|
1330 (specifier-specs foo)
|
|
1331 @result{} ((#<x-frame "emacs" 0x28ec> (nil . baz))
|
|
1332 (#<x-frame "Message" 0x1bd66> (nil . bar))
|
|
1333 (global (nil)))
|
|
1334
|
|
1335 (frame-value foo)
|
|
1336 @result{} bar
|
|
1337
|
|
1338 (frame-get-default foo)
|
|
1339 @result{} nil
|
|
1340 @end example
|
|
1341
|
|
1342 Note that since specifiers generalize both frame-local and buffer-local
|
|
1343 variables in a sensible way, XEmacs is not likely to put a high priority
|
2028
|
1344 on implementing frame-local variables @ref{Specifier Compatibility Notes}.
|
1869
|
1345
|
|
1346
|
428
|
1347 @node Creating Specifiers
|
|
1348 @section Creating New Specifier Objects
|
|
1349
|
|
1350 @defun make-specifier type
|
|
1351 This function creates a new specifier.
|
|
1352
|
|
1353 A specifier is an object that can be used to keep track of a property
|
|
1354 whose value can be per-buffer, per-window, per-frame, or per-device,
|
|
1355 and can further be restricted to a particular device-type or device-class.
|
|
1356 Specifiers are used, for example, for the various built-in properties of a
|
|
1357 face; this allows a face to have different values in different frames,
|
444
|
1358 buffers, etc. For more information, see @code{specifier-instance},
|
|
1359 @code{specifier-specs}, and @code{add-spec-to-specifier}; or, for a detailed
|
428
|
1360 description of specifiers, including how they are instantiated over a
|
|
1361 particular domain (i.e. how their value in that domain is determined),
|
|
1362 see the chapter on specifiers in the XEmacs Lisp Reference Manual.
|
|
1363
|
|
1364 @var{type} specifies the particular type of specifier, and should be one
|
|
1365 of the symbols @code{generic}, @code{integer}, @code{natnum},
|
|
1366 @code{boolean}, @code{color}, @code{font}, @code{image},
|
|
1367 @code{face-boolean}, or @code{toolbar}.
|
|
1368
|
|
1369 For more information on particular types of specifiers, see the
|
442
|
1370 functions @code{make-generic-specifier}, @code{make-integer-specifier},
|
|
1371 @code{make-natnum-specifier}, @code{make-boolean-specifier},
|
|
1372 @code{make-color-specifier}, @code{make-font-specifier},
|
|
1373 @code{make-image-specifier}, @code{make-face-boolean-specifier}, and
|
|
1374 @code{make-toolbar-specifier}.
|
428
|
1375 @end defun
|
|
1376
|
|
1377 @defun make-specifier-and-init type spec-list &optional dont-canonicalize
|
1875
|
1378 This function creates and initializes a new specifier.
|
428
|
1379
|
1875
|
1380 This is a convenience API combining @code{make-specifier} and
|
|
1381 @code{set-specifier} that allows you to create
|
428
|
1382 a specifier and add specs to it at the same time. @var{type} specifies
|
1875
|
1383 the specifier type. Allowed types are as for @code{make-specifier}.
|
|
1384
|
|
1385 @var{spec-list} supplies the specification(s) to be
|
|
1386 added to the specifier. Any abbreviation of
|
|
1387 the full spec-list form accepted by @code{canonicalize-spec-list} may
|
|
1388 be used.
|
|
1389 However, if the optional argument @var{dont-canonicalize} is non-@code{nil},
|
|
1390 canonicalization is not performed, and the @var{spec-list} must already
|
|
1391 be in full form.
|
428
|
1392 @end defun
|
|
1393
|
442
|
1394 @defun make-integer-specifier spec-list
|
|
1395
|
|
1396 Return a new @code{integer} specifier object with the given
|
|
1397 specification list. @var{spec-list} can be a list of specifications
|
|
1398 (each of which is a cons of a locale and a list of instantiators), a
|
|
1399 single instantiator, or a list of instantiators.
|
|
1400
|
|
1401 Valid instantiators for integer specifiers are integers.
|
|
1402 @end defun
|
|
1403
|
|
1404 @defun make-boolean-specifier spec-list
|
|
1405
|
|
1406 Return a new @code{boolean} specifier object with the given
|
|
1407 specification list. @var{spec-list} can be a list of specifications
|
|
1408 (each of which is a cons of a locale and a list of instantiators), a
|
|
1409 single instantiator, or a list of instantiators.
|
|
1410
|
|
1411 Valid instantiators for boolean specifiers are @code{t} and @code{nil}.
|
|
1412 @end defun
|
|
1413
|
|
1414 @defun make-natnum-specifier spec-list
|
|
1415
|
|
1416 Return a new @code{natnum} specifier object with the given specification
|
|
1417 list. @var{spec-list} can be a list of specifications (each of which is
|
|
1418 a cons of a locale and a list of instantiators), a single instantiator,
|
|
1419 or a list of instantiators.
|
|
1420
|
|
1421 Valid instantiators for natnum specifiers are non-negative integers.
|
|
1422 @end defun
|
|
1423
|
|
1424 @defun make-generic-specifier spec-list
|
|
1425
|
|
1426 Return a new @code{generic} specifier object with the given
|
|
1427 specification list. @var{spec-list} can be a list of specifications
|
|
1428 (each of which is a cons of a locale and a list of instantiators), a
|
|
1429 single instantiator, or a list of instantiators.
|
|
1430
|
|
1431 Valid instantiators for generic specifiers are all Lisp values. They
|
|
1432 are returned back unchanged when a specifier is instantiated.
|
|
1433 @end defun
|
|
1434
|
|
1435 @defun make-display-table-specifier spec-list
|
|
1436
|
|
1437 Return a new @code{display-table} specifier object with the given spec
|
|
1438 list. @var{spec-list} can be a list of specifications (each of which is
|
|
1439 a cons of a locale and a list of instantiators), a single instantiator,
|
|
1440 or a list of instantiators.
|
|
1441
|
|
1442 Valid instantiators for display-table specifiers are described in detail
|
|
1443 in the doc string for @code{current-display-table} (@pxref{Active
|
|
1444 Display Table}).
|
|
1445 @end defun
|
|
1446
|
428
|
1447 @node Specifier Validation Functions
|
|
1448 @section Functions for Checking the Validity of Specifier Components
|
|
1449
|
|
1450 @defun valid-specifier-domain-p domain
|
|
1451 This function returns non-@code{nil} if @var{domain} is a valid
|
|
1452 specifier domain. A domain is used to instance a specifier
|
|
1453 (i.e. determine the specifier's value in that domain). Valid domains
|
|
1454 are a window, frame, or device. (@code{nil} is not valid.)
|
|
1455 @end defun
|
|
1456
|
|
1457 @defun valid-specifier-locale-p locale
|
|
1458 This function returns non-@code{nil} if @var{locale} is a valid
|
|
1459 specifier locale. Valid locales are a device, a frame, a window, a
|
|
1460 buffer, and @code{global}. (@code{nil} is not valid.)
|
|
1461 @end defun
|
|
1462
|
|
1463 @defun valid-specifier-locale-type-p locale-type
|
444
|
1464 Given a specifier @var{locale-type}, this function returns non-@code{nil} if it
|
428
|
1465 is valid. Valid locale types are the symbols @code{global},
|
|
1466 @code{device}, @code{frame}, @code{window}, and @code{buffer}. (Note,
|
|
1467 however, that in functions that accept either a locale or a locale type,
|
|
1468 @code{global} is considered an individual locale.)
|
|
1469 @end defun
|
|
1470
|
|
1471 @defun valid-specifier-type-p specifier-type
|
|
1472 Given a @var{specifier-type}, this function returns non-@code{nil} if it
|
|
1473 is valid. Valid types are @code{generic}, @code{integer},
|
|
1474 @code{boolean}, @code{color}, @code{font}, @code{image},
|
|
1475 @code{face-boolean}, and @code{toolbar}.
|
|
1476 @end defun
|
|
1477
|
|
1478 @defun valid-specifier-tag-p tag
|
|
1479 This function returns non-@code{nil} if @var{tag} is a valid specifier
|
|
1480 tag.
|
|
1481 @end defun
|
|
1482
|
|
1483 @defun valid-instantiator-p instantiator specifier-type
|
|
1484 This function returns non-@code{nil} if @var{instantiator} is valid for
|
|
1485 @var{specifier-type}.
|
|
1486 @end defun
|
|
1487
|
|
1488 @defun valid-inst-list-p inst-list type
|
|
1489 This function returns non-@code{nil} if @var{inst-list} is valid for
|
|
1490 specifier type @var{type}.
|
|
1491 @end defun
|
|
1492
|
|
1493 @defun valid-spec-list-p spec-list type
|
|
1494 This function returns non-@code{nil} if @var{spec-list} is valid for
|
|
1495 specifier type @var{type}.
|
|
1496 @end defun
|
|
1497
|
|
1498 @defun check-valid-instantiator instantiator specifier-type
|
|
1499 This function signals an error if @var{instantiator} is invalid for
|
|
1500 @var{specifier-type}.
|
|
1501 @end defun
|
|
1502
|
|
1503 @defun check-valid-inst-list inst-list type
|
|
1504 This function signals an error if @var{inst-list} is invalid for
|
|
1505 specifier type @var{type}.
|
|
1506 @end defun
|
|
1507
|
|
1508 @defun check-valid-spec-list spec-list type
|
|
1509 This function signals an error if @var{spec-list} is invalid for
|
|
1510 specifier type @var{type}.
|
|
1511 @end defun
|
|
1512
|
|
1513 @node Other Specification Functions
|
|
1514 @section Other Functions for Working with Specifications in a Specifier
|
|
1515
|
|
1516 @defun copy-specifier specifier &optional dest locale tag-set exact-p how-to-add
|
|
1517 This function copies @var{specifier} to @var{dest}, or creates a new one
|
|
1518 if @var{dest} is @code{nil}.
|
|
1519
|
|
1520 If @var{dest} is @code{nil} or omitted, a new specifier will be created
|
|
1521 and the specifications copied into it. Otherwise, the specifications
|
|
1522 will be copied into the existing specifier in @var{dest}.
|
|
1523
|
|
1524 If @var{locale} is @code{nil} or the symbol @code{all}, all
|
|
1525 specifications will be copied. If @var{locale} is a particular locale,
|
|
1526 the specification for that particular locale will be copied. If
|
|
1527 @var{locale} is a locale type, the specifications for all locales of
|
|
1528 that type will be copied. @var{locale} can also be a list of locales,
|
|
1529 locale types, and/or @code{all}; this is equivalent to calling
|
|
1530 @code{copy-specifier} for each of the elements of the list. See
|
|
1531 @code{specifier-spec-list} for more information about @var{locale}.
|
|
1532
|
|
1533 Only instantiators where @var{tag-set} (a list of zero or more tags) is
|
|
1534 a subset of (or possibly equal to) the instantiator's tag set are
|
|
1535 copied. (The default value of @code{nil} is a subset of all tag sets,
|
|
1536 so in this case no instantiators will be screened out.) If @var{exact-p}
|
|
1537 is non-@code{nil}, however, @var{tag-set} must be equal to an
|
|
1538 instantiator's tag set for the instantiator to be copied.
|
|
1539
|
|
1540 Optional argument @var{how-to-add} specifies what to do with existing
|
444
|
1541 specifications in @var{dest}. If @code{nil}, then whichever locales or locale
|
428
|
1542 types are copied will first be completely erased in @var{dest}.
|
|
1543 Otherwise, it is the same as in @code{add-spec-to-specifier}.
|
|
1544 @end defun
|
|
1545
|
|
1546 @defun remove-specifier specifier &optional locale tag-set exact-p
|
|
1547 This function removes specification(s) for @var{specifier}.
|
|
1548
|
|
1549 If @var{locale} is a particular locale (a buffer, window, frame, device,
|
|
1550 or the symbol @code{global}), the specification for that locale will be
|
|
1551 removed.
|
|
1552
|
|
1553 If instead, @var{locale} is a locale type (i.e. a symbol @code{buffer},
|
|
1554 @code{window}, @code{frame}, or @code{device}), the specifications for
|
|
1555 all locales of that type will be removed.
|
|
1556
|
|
1557 If @var{locale} is @code{nil} or the symbol @code{all}, all
|
|
1558 specifications will be removed.
|
|
1559
|
|
1560 @var{locale} can also be a list of locales, locale types, and/or
|
|
1561 @code{all}; this is equivalent to calling @code{remove-specifier} for
|
|
1562 each of the elements in the list.
|
|
1563
|
|
1564 Only instantiators where @var{tag-set} (a list of zero or more tags) is
|
|
1565 a subset of (or possibly equal to) the instantiator's tag set are
|
|
1566 removed. (The default value of @code{nil} is a subset of all tag sets,
|
|
1567 so in this case no instantiators will be screened out.) If @var{exact-p}
|
|
1568 is non-@code{nil}, however, @var{tag-set} must be equal to an
|
|
1569 instantiator's tag set for the instantiator to be removed.
|
|
1570 @end defun
|
|
1571
|
|
1572 @defun map-specifier specifier func &optional locale maparg
|
|
1573 This function applies @var{func} to the specification(s) for
|
|
1574 @var{locale} in @var{specifier}.
|
|
1575
|
1875
|
1576 If optional @var{locale} is a locale, @var{func} will be called for that
|
|
1577 locale.
|
428
|
1578 If @var{locale} is a locale type, @var{func} will be mapped over all
|
|
1579 locales of that type. If @var{locale} is @code{nil} or the symbol
|
|
1580 @code{all}, @var{func} will be mapped over all locales in
|
|
1581 @var{specifier}.
|
|
1582
|
1875
|
1583 Optional @var{ms-tag-set} and @var{ms-exact-p} are as in
|
|
1584 @code{specifier-spec-list'}.
|
|
1585 Optional @var{ms-maparg} will be passed to @var{ms-func}.
|
|
1586
|
428
|
1587 @var{func} is called with four arguments: the @var{specifier}, the
|
|
1588 locale being mapped over, the inst-list for that locale, and the
|
|
1589 optional @var{maparg}. If any invocation of @var{func} returns
|
|
1590 non-@code{nil}, the mapping will stop and the returned value becomes the
|
|
1591 value returned from @code{map-specifier}. Otherwise,
|
|
1592 @code{map-specifier} returns @code{nil}.
|
|
1593 @end defun
|
|
1594
|
|
1595 @defun specifier-locale-type-from-locale locale
|
|
1596 Given a specifier @var{locale}, this function returns its type.
|
|
1597 @end defun
|
2028
|
1598
|
|
1599 @node Specifier Compatibility Notes
|
|
1600 @section Specifier Compatibility Notes
|
|
1601
|
|
1602 This node describes compatibility issues in the use of specifiers known
|
|
1603 as of 2004-01-22.
|
|
1604 @c I considered basing the main text on 21.4, but then future
|
|
1605 @c maintenance of this documentation would be a pain.
|
|
1606 The main text refers to XEmacs 21.5.16.
|
|
1607
|
|
1608 Effort will be made to describe changes in the API or semantics between
|
|
1609 XEmacs versions accurately. Any inaccuracy or missing information about
|
|
1610 backward and forward compatibility is a bug, and we greatly appreciate
|
|
1611 your reports, whether you can provide a patch or not.
|
|
1612
|
|
1613 A change is reported as @dfn{changed} when we believe that the new or
|
|
1614 changed API will cause old code to malfunction. When old code is
|
|
1615 believed to be upward compatible with the changed API, the change is
|
|
1616 reported as @dfn{added}.
|
|
1617
|
|
1618 We would like to also describe compatibility with GNU Emacs, but this is
|
|
1619 not so high a priority. Inaccuracies or omissions will be addressed at
|
|
1620 the priority of a feature request, and as such processing will be
|
|
1621 greatly expedited if you can provide a patch.
|
|
1622 @c #### xref here to bug reporting and patch submissions
|
|
1623
|
|
1624 @c #### write and xref a file on compatibility policy
|
|
1625
|
|
1626 @subsection Compatibility with GNU Emacs
|
|
1627
|
|
1628 Specifiers are not used in GNU Emacs. If your program depends on
|
|
1629 specifers, you will probably have to rewrite the functionality
|
|
1630 completely for GNU Emacs. If you wish to maximize portability, you
|
|
1631 should plan to encapsulate use of specifiers.
|
|
1632
|
|
1633 GNU Emacs provides two features for context-sensitive variables,
|
|
1634 buffer-local variables and frame-local variables. XEmacs implements
|
|
1635 buffer-local variables 100%-compatibly with GNU Emacs. If buffer-local
|
|
1636 variables will server your purpose and portability is a major concern,
|
|
1637 consider using them instead of specifiers.
|
|
1638
|
|
1639 XEmacs does not implement frame-local variables at all. In this case
|
|
1640 specifiers must be used to provide equivalent functionality.
|
|
1641
|
|
1642 It is not clear whether XEmacs will provide this feature in the future.
|
|
1643 @c Thanks to Jerry James for the following explanation. He is not
|
|
1644 @c responsible for its use here, Stephen Turnbull is.
|
|
1645 In fact, some core XEmacs developers think that both frame-local
|
|
1646 variables and buffer-local variables are evil, because the declaration
|
|
1647 is both global and invisible. That is, you cannot tell whether a
|
|
1648 variable is ``normal,'' buffer-local, or frame-local just by looking at
|
|
1649 it. So if you have namespace management problems, and some other Lisp
|
|
1650 package happens to use a variable name that you already declared frame-
|
|
1651 or buffer-local, weird stuff happens, and it is extremely hard to track
|
|
1652 down.
|
|
1653 @c #### Direct comments to xemacs-design?
|
|
1654
|
|
1655 @subsection Backwards Compatibility with XEmacs 21.4
|
|
1656
|
|
1657 Sorry, I'm unwilling to find out exactly when these changes were made.
|
|
1658
|
|
1659 Changed by 21.5.16: the second argument of
|
|
1660 @code{specifier-matching-instance} is now a cons of a charset and a
|
|
1661 boolean value. Previously it was a charset or a symbol (a name of a
|
|
1662 charset). It was not documented in Info.
|
|
1663
|
|
1664 Changed by 21.5.16: the specifier-specific error symbols
|
|
1665 @code{specifier_syntax_error}, @code{specifier_argument_error}, and
|
|
1666 @code{specifier_change_error} were removed. (This probably only
|
|
1667 affected internal code.)
|
|
1668
|
|
1669 Added by 21.5.16: @code{map-specifier} got two new arguments,
|
|
1670 @code{ms-tag-set} and @code{ms-exact-p}.
|
|
1671
|
|
1672 Added by 21.5.16: when skipping instantiators, XEmacs warns at level
|
|
1673 `debug'.
|
|
1674
|
|
1675 Added by 21.5.16: new convenience APIs:
|
|
1676 @code{instance-to-instantiator},
|
|
1677 @code{device-type-matches-spec},
|
|
1678 @code{add-tag-to-inst-list},
|
|
1679 @code{derive-domain-from-locale},
|
|
1680 @code{derive-device-type-from-tag-set},
|
|
1681 @code{derive-device-type-from-locale-and-tag-set}, and
|
|
1682 @code{derive-specifier-specs-from-locale}.
|