annotate man/lispref/tooltalk.texi @ 373:6240c7796c7a r21-2b2

Import from CVS: tag r21-2b2
author cvs
date Mon, 13 Aug 2007 11:04:06 +0200
parents cc15677e0335
children 74fd4e045ea6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 @c -*-texinfo-*-
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 @c This is part of the XEmacs Lisp Reference Manual.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 @c Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 @c See the file lispref.texi for copying conditions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 @setfilename ../../info/tooltalk.info
298
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 108
diff changeset
6 @node ToolTalk Support, LDAP Support, X-Windows, top
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 @chapter ToolTalk Support
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 @cindex ToolTalk
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 * XEmacs ToolTalk API Summary::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 * Sending Messages::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 * Receiving Messages::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 @node XEmacs ToolTalk API Summary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 @section XEmacs ToolTalk API Summary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 The XEmacs Lisp interface to ToolTalk is similar, at least in spirit,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 to the standard C ToolTalk API. Only the message and pattern parts
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 of the API are supported at present; more of the API could be added
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 if needed. The Lisp interface departs from the C API in a few ways:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 @itemize @bullet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ToolTalk is initialized automatically at XEmacs startup-time. Messages
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 can only be sent other ToolTalk applications connected to the same X11
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 server that XEmacs is running on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 There are fewer entry points; polymorphic functions with keyword
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 arguments are used instead.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 The callback interface is simpler and marginally less functional.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 A single callback may be associated with a message or a pattern;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 the callback is specified with a Lisp symbol (the symbol should
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 have a function binding).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 The session attribute for messages and patterns is always
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 initialized to the default session.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 Anywhere a ToolTalk enum constant, e.g. @samp{TT_SESSION}, is valid, one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 can substitute the corresponding symbol, e.g. @code{'TT_SESSION}. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 simplifies building lists that represent messages and patterns.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 @end itemize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 @node Sending Messages
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 @section Sending Messages
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 @cindex sending ToolTalk messages
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 @cindex ToolTalk message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 * Example of Sending Messages::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 * Elisp Interface for Sending Messages::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 @node Example of Sending Messages
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 @subsection Example of Sending Messages
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 Here's a simple example that sends a query to another application
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 and then displays its reply. Both the query and the reply are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 stored in the first argument of the message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (defun tooltalk-random-query-handler (msg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (let ((state (get-tooltalk-message-attribute msg 'state)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 ((eq state 'TT_HANDLED)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (message (get-tooltalk-message-attribute msg arg_val 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ((memq state '(TT_FAILED TT_REJECTED))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (message "Random query turns up nothing")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (defvar random-query-message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 '( class TT_REQUEST
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 scope TT_SESSION
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 address TT_PROCEDURE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 op "random-query"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 args '((TT_INOUT "?" "string"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 callback tooltalk-random-query-handler))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (let ((m (make-tooltalk-message random-query-message)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (send-tooltalk-message m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 @node Elisp Interface for Sending Messages
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 @subsection Elisp Interface for Sending Messages
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 @defun make-tooltalk-message attributes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 Create a ToolTalk message and initialize its attributes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 The value of @var{attributes} must be a list of alternating keyword/values,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 where keywords are symbols that name valid message attributes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 For example:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (make-tooltalk-message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 '(class TT_NOTICE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 scope TT_SESSION
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 address TT_PROCEDURE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 op "do-something"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 args ("arg1" 12345 (TT_INOUT "arg3" "string"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 Values must always be strings, integers, or symbols that represent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 ToolTalk constants. Attribute names are the same as those supported by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 @code{set-tooltalk-message-attribute}, plus @code{args}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 The value of @code{args} should be a list of message arguments where
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 each message argument has the following form:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 @quotation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 @samp{(mode [value [type]])} or just @samp{value}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 @end quotation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 Where @var{mode} is one of @code{TT_IN}, @code{TT_OUT}, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 @code{TT_INOUT} and @var{type} is a string. If @var{type} isn't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 specified then @code{int} is used if @var{value} is a number; otherwise
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 @code{string} is used. If @var{type} is @code{string} then @var{value}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 is converted to a string (if it isn't a string already) with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 @code{prin1-to-string}. If only a value is specified then @var{mode}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 defaults to @code{TT_IN}. If @var{mode} is @code{TT_OUT} then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 @var{value} and @var{type} don't need to be specified. You can find out
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 more about the semantics and uses of ToolTalk message arguments in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 chapter 4 of the @cite{ToolTalk Programmer's Guide}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 @refill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 @defun send-tooltalk-message msg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 Send the message on its way. Once the message has been sent it's almost
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 always a good idea to get rid of it with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 @code{destroy-tooltalk-message}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 @refill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 @defun return-tooltalk-message msg &optional mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 Send a reply to this message. The second argument can be @code{reply},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 @code{reject} or @code{fail}; the default is @code{reply}. Before
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 sending a reply, all message arguments whose mode is @code{TT_INOUT} or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 @code{TT_OUT} should have been filled in -- see
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 @code{set-tooltalk-message-attribute}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 @refill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 @defun get-tooltalk-message-attribute msg attribute &optional argn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 Returns the indicated ToolTalk message attribute. Attributes are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 identified by symbols with the same name (underscores and all) as the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 suffix of the ToolTalk @samp{tt_message_<attribute>} function that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 extracts the value. String attribute values are copied and enumerated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 type values (except disposition) are converted to symbols;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 e.g. @samp{TT_HANDLER} is @code{'TT_HANDLER}, @samp{uid} and @samp{gid}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 are represented by fixnums (small integers), @samp{opnum} is converted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 to a string, and @samp{disposition} is converted to a fixnum. We
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 convert @samp{opnum} (a C int) to a string (e.g. @code{123} @result{}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 @code{"123"}) because there's no guarantee that opnums will fit within
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 the range of XEmacs Lisp integers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 @refill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 [TBD] Use the @code{plist} attribute instead of C API @code{user}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 attribute for user-defined message data. To retrieve the value of a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 message property, specify the indicator for @var{argn}. For example, to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 get the value of a property called @code{rflag}, use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (get-tooltalk-message-attribute msg 'plist 'rflag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 To get the value of a message argument use one of the @code{arg_val}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (strings), @code{arg_ival} (integers), or @code{arg_bval} (strings with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 embedded nulls), attributes. For example, to get the integer value of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 the third argument:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (get-tooltalk-message-attribute msg 'arg_ival 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 As you can see, argument numbers are zero-based. The type of each
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 arguments can be retrieved with the @code{arg_type} attribute; however
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 ToolTalk doesn't define any semantics for the string value of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 @code{arg_type}. Conventionally @code{string} is used for strings and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 @code{int} for 32 bit integers. Note that XEmacs Lisp stores the lengths
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 of strings explicitly (unlike C) so treating the value returned by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 @code{arg_bval} like a string is fine.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 @refill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 @defun set-tooltalk-message-attribute value msg attribute &optional argn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 Initialize one ToolTalk message attribute.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 Attribute names and values are the same as for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 @code{get-tooltalk-message-attribute}. A property list is provided for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 user data (instead of the @code{user} message attribute); see
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 @code{get-tooltalk-message-attribute}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 @refill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 Callbacks are handled slightly differently than in the C ToolTalk API.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 The value of @var{callback} should be the name of a function of one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 argument. It will be called each time the state of the message changes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 This is usually used to notice when the message's state has changed to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 @code{TT_HANDLED} (or @code{TT_FAILED}), so that reply argument values
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 can be used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 @refill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 If one of the argument attributes is specified as @code{arg_val},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 @code{arg_ival}, or @code{arg_bval}, then @var{argn} must be the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 number of an already created argument. Arguments can be added to a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 message with @code{add-tooltalk-message-arg}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 @refill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 @defun add-tooltalk-message-arg msg mode type &optional value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 Append one new argument to the message. @var{mode} must be one of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 @code{TT_IN}, @code{TT_INOUT}, or @code{TT_OUT}, @var{type} must be a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 string, and @var{value} can be a string or an integer. ToolTalk doesn't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 define any semantics for @var{type}, so only the participants in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 protocol you're using need to agree what types mean (if anything).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 Conventionally @code{string} is used for strings and @code{int} for 32
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 bit integers. Arguments can initialized by providing a value or with
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
220 @code{set-tooltalk-message-attribute}; the latter is necessary if you
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 want to initialize the argument with a string that can contain embedded
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 nulls (use @code{arg_bval}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 @refill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 @defun create-tooltalk-message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 Create a new ToolTalk message. The message's session attribute is
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
228 initialized to the default session. Other attributes can be initialized
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 with @code{set-tooltalk-message-attribute}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 @code{make-tooltalk-message} is the preferred way to create and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 initialize a message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 @refill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 @defun destroy-tooltalk-message msg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 Apply @samp{tt_message_destroy} to the message. It's not necessary to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 destroy messages after they've been processed by a message or pattern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 callback, the Lisp/ToolTalk callback machinery does this for you.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 @node Receiving Messages
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 @section Receiving Messages
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 @cindex ToolTalk pattern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 @cindex receiving ToolTalk messages
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 * Example of Receiving Messages::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 * Elisp Interface for Receiving Messages::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 @node Example of Receiving Messages
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 @subsection Example of Receiving Messages
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 Here's a simple example of a handler for a message that tells XEmacs to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 display a string in the mini-buffer area. The message operation is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 called @samp{emacs-display-string}. Its first (0th) argument is the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 string to display.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (defun tooltalk-display-string-handler (msg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (message (get-tooltalk-message-attribute msg 'arg_val 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (defvar display-string-pattern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 '(category TT_HANDLE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 scope TT_SESSION
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 op "emacs-display-string"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 callback tooltalk-display-string-handler))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (let ((p (make-tooltalk-pattern display-string-pattern)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (register-tooltalk-pattern p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 @node Elisp Interface for Receiving Messages
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 @subsection Elisp Interface for Receiving Messages
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 @defun make-tooltalk-pattern attributes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 Create a ToolTalk pattern and initialize its attributes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 The value of attributes must be a list of alternating keyword/values,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 where keywords are symbols that name valid pattern attributes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 or lists of valid attributes. For example:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (make-tooltalk-pattern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 '(category TT_OBSERVE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 scope TT_SESSION
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 op ("operation1" "operation2")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 args ("arg1" 12345 (TT_INOUT "arg3" "string"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 Attribute names are the same as those supported by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 @code{add-tooltalk-pattern-attribute}, plus @code{'args}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 Values must always be strings, integers, or symbols that represent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 ToolTalk constants or lists of same. When a list of values is provided
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 all of the list elements are added to the attribute. In the example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 above, messages whose @samp{op} attribute is @samp{"operation1"} or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 @samp{"operation2"} would match the pattern.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 The value of @var{args} should be a list of pattern arguments where each
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 pattern argument has the following form:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 @quotation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 @samp{(mode [value [type]])} or just @samp{value}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 @end quotation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 Where @var{mode} is one of @code{TT_IN}, @code{TT_OUT}, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 @code{TT_INOUT} and @var{type} is a string. If @var{type} isn't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 specified then @code{int} is used if @var{value} is a number; otherwise
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 @code{string} is used. If @var{type} is @code{string} then @var{value}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 is converted to a string (if it isn't a string already) with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 @code{prin1-to-string}. If only a value is specified then @var{mode}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 defaults to @code{TT_IN}. If @var{mode} is @code{TT_OUT} then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 @var{value} and @var{type} don't need to be specified. You can find out
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 more about the semantics and uses of ToolTalk pattern arguments in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 chapter 3 of the @cite{ToolTalk Programmer's Guide}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 @refill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 @defun register-tooltalk-pattern pat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 XEmacs will begin receiving messages that match this pattern.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 @defun unregister-tooltalk-pattern pat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 XEmacs will stop receiving messages that match this pattern.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 @defun add-tooltalk-pattern-attribute value pat indicator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 Add one value to the indicated pattern attribute. The names of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 attributes are the same as the ToolTalk accessors used to set them less
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 the @samp{tooltalk_pattern_} prefix and the @samp{_add} suffix. For
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 example, the name of the attribute for the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 @samp{tt_pattern_disposition_add} attribute is @code{disposition}. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 @code{category} attribute is handled specially, since a pattern can only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 be a member of one category (@code{TT_OBSERVE} or @code{TT_HANDLE}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 @refill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 Callbacks are handled slightly differently than in the C ToolTalk API.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 The value of @var{callback} should be the name of a function of one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 argument. It will be called each time the pattern matches an incoming
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 @defun add-tooltalk-pattern-arg pat mode type value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 Add one fully-specified argument to a ToolTalk pattern. @var{mode} must
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 be one of @code{TT_IN}, @code{TT_INOUT}, or @code{TT_OUT}. @var{type}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 must be a string. @var{value} can be an integer, string or @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 If @var{value} is an integer then an integer argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (@samp{tt_pattern_iarg_add}) is added; otherwise a string argument is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 added. At present there's no way to add a binary data argument.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 @refill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 @defun create-tooltalk-pattern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 Create a new ToolTalk pattern and initialize its session attribute to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 be the default session.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 @defun destroy-tooltalk-pattern pat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 Apply @samp{tt_pattern_destroy} to the pattern. This effectively
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 unregisters the pattern.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 @defun describe-tooltalk-message msg &optional stream
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 Print the message's attributes and arguments to @var{stream}. This is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 often useful for debugging.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 @end defun