Previous: Example of Receiving Messages, Up: Receiving Messages


60.3.2 Elisp Interface for Receiving Messages

— Function: make-tooltalk-pattern attributes

Create a ToolTalk pattern and initialize its attributes. The value of attributes must be a list of alternating keyword/values, where keywords are symbols that name valid pattern attributes or lists of valid attributes. For example:

            (make-tooltalk-pattern
              '(category TT_OBSERVE
                   scope TT_SESSION
                      op ("operation1" "operation2")
                    args ("arg1" 12345 (TT_INOUT "arg3" "string"))))

Attribute names are the same as those supported by add-tooltalk-pattern-attribute, plus 'args.

Values must always be strings, integers, or symbols that represent ToolTalk constants or lists of same. When a list of values is provided all of the list elements are added to the attribute. In the example above, messages whose ‘op’ attribute is ‘"operation1"’ or ‘"operation2"’ would match the pattern.

The value of args should be a list of pattern arguments where each pattern argument has the following form:

(mode [value [type]])’ or just ‘value

Where mode is one of TT_IN, TT_OUT, or TT_INOUT and type is a string. If type isn't specified then int is used if value is a number; otherwise string is used. If type is string then value is converted to a string (if it isn't a string already) with prin1-to-string. If only a value is specified then mode defaults to TT_IN. If mode is TT_OUT then value and type don't need to be specified. You can find out more about the semantics and uses of ToolTalk pattern arguments in chapter 3 of the ToolTalk Programmer's Guide.

— Function: register-tooltalk-pattern pattern

SXEmacs will begin receiving messages that match this pattern.

— Function: unregister-tooltalk-pattern pattern

SXEmacs will stop receiving messages that match this pattern.

— Function: add-tooltalk-pattern-attribute value pattern indicator

Add one value to the indicated pattern attribute. The names of attributes are the same as the ToolTalk accessors used to set them less the ‘tooltalk_pattern_’ prefix and the ‘_add’ suffix. For example, the name of the attribute for the ‘tt_pattern_disposition_add’ attribute is disposition. The category attribute is handled specially, since a pattern can only be a member of one category (TT_OBSERVE or TT_HANDLE).

Callbacks are handled slightly differently than in the C ToolTalk API. The value of callback should be the name of a function of one argument. It will be called each time the pattern matches an incoming message.

— Function: add-tooltalk-pattern-arg pattern mode vtype &optional value

Add one fully-specified argument to a ToolTalk pattern. mode must be one of TT_IN, TT_INOUT, or TT_OUT. vtype must be a string. value can be an integer, string or nil. If value is an integer then an integer argument (‘tt_pattern_iarg_add’) is added; otherwise a string argument is added. At present there's no way to add a binary data argument.

— Function: create-tooltalk-pattern

Create a new ToolTalk pattern and initialize its session attribute to be the default session.

— Function: destroy-tooltalk-pattern pattern

Apply ‘tt_pattern_destroy’ to the pattern. This effectively unregisters the pattern.

— Function: describe-tooltalk-message msg &optional stream

Print the message's attributes and arguments to stream. This is often useful for debugging.