annotate man/lispref/specifiers.texi @ 5585:86d6adeb1cf4

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