annotate man/lispref/commands.texi @ 213:78f53ef88e17 r20-4b5

Import from CVS: tag r20-4b5
author cvs
date Mon, 13 Aug 2007 10:06:47 +0200
parents e45d5e7c476e
children 7df0dd720c89
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, 1994 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/commands.info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 @node Command Loop, Keymaps, Minibuffers, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 @chapter Command Loop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 @cindex editor command loop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 @cindex command loop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 When you run XEmacs, it enters the @dfn{editor command loop} almost
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 immediately. This loop reads events, executes their definitions,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 and displays the results. In this chapter, we describe how these things
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 are done, and the subroutines that allow Lisp programs to do them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 * Command Overview:: How the command loop reads commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 * Defining Commands:: Specifying how a function should read arguments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 * Interactive Call:: Calling a command, so that it will read arguments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 * Command Loop Info:: Variables set by the command loop for you to examine.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 * Events:: What input looks like when you read it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 * Reading Input:: How to read input events from the keyboard or mouse.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 * Waiting:: Waiting for user input or elapsed time.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 * Quitting:: How @kbd{C-g} works. How to catch or defer quitting.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 * Prefix Command Arguments:: How the commands to set prefix args work.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 * Recursive Editing:: Entering a recursive edit,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 and why you usually shouldn't.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 * Disabling Commands:: How the command loop handles disabled commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 * Command History:: How the command history is set up, and how accessed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 * Keyboard Macros:: How keyboard macros are implemented.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 @node Command Overview
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 @section Command Loop Overview
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 The command loop in XEmacs is a standard event loop, reading events
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 one at a time with @code{next-event} and handling them with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 @code{dispatch-event}. An event is typically a single user action, such
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 as a keypress, mouse movement, or menu selection; but they can also be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 notifications from the window system, informing XEmacs that (for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 example) part of its window was just uncovered and needs to be redrawn.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 @xref{Events}. Pending events are held in a first-in, first-out list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 called the @dfn{event queue}: events are read from the head of the list,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 and newly arriving events are added to the tail. In this way, events
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 are always processed in the order in which they arrive.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 @code{dispatch-event} does most of the work of handling user actions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 The first thing it must do is put the events together into a key
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 sequence, which is a sequence of events that translates into a command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 It does this by consulting the active keymaps, which specify what the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 valid key sequences are and how to translate them into commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 @xref{Key Lookup}, for information on how this is done. The result of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 the translation should be a keyboard macro or an interactively callable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 function. If the key is @kbd{M-x}, then it reads the name of another
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 command, which it then calls. This is done by the command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 @code{execute-extended-command} (@pxref{Interactive Call}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 To execute a command requires first reading the arguments for it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 This is done by calling @code{command-execute} (@pxref{Interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 Call}). For commands written in Lisp, the @code{interactive}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 specification says how to read the arguments. This may use the prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 argument (@pxref{Prefix Command Arguments}) or may read with prompting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 in the minibuffer (@pxref{Minibuffers}). For example, the command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 @code{find-file} has an @code{interactive} specification which says to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 read a file name using the minibuffer. The command's function body does
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 not use the minibuffer; if you call this command from Lisp code as a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 function, you must supply the file name string as an ordinary Lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 function argument.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 If the command is a string or vector (i.e., a keyboard macro) then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 @code{execute-kbd-macro} is used to execute it. You can call this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 function yourself (@pxref{Keyboard Macros}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 To terminate the execution of a running command, type @kbd{C-g}. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 character causes @dfn{quitting} (@pxref{Quitting}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 @defvar pre-command-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 The editor command loop runs this normal hook before each command. At
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 that time, @code{this-command} contains the command that is about to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 run, and @code{last-command} describes the previous command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 @xref{Hooks}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 @defvar post-command-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 The editor command loop runs this normal hook after each command. (In
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 FSF Emacs, it is also run when the command loop is entered, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 reentered after an error or quit.) At that time,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 @code{this-command} describes the command that just ran, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 @code{last-command} describes the command before that. @xref{Hooks}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 Quitting is suppressed while running @code{pre-command-hook} and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 @code{post-command-hook}. If an error happens while executing one of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 these hooks, it terminates execution of the hook, but that is all it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 does.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 @node Defining Commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 @section Defining Commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 @cindex defining commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 @cindex commands, defining
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 @cindex functions, making them interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 @cindex interactive function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 A Lisp function becomes a command when its body contains, at top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 level, a form that calls the special form @code{interactive}. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 form does nothing when actually executed, but its presence serves as a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 flag to indicate that interactive calling is permitted. Its argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 controls the reading of arguments for an interactive call.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 * Using Interactive:: General rules for @code{interactive}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 * Interactive Codes:: The standard letter-codes for reading arguments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 in various ways.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 * Interactive Examples:: Examples of how to read interactive arguments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 @node Using Interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 @subsection Using @code{interactive}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 This section describes how to write the @code{interactive} form that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 makes a Lisp function an interactively-callable command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 @defspec interactive arg-descriptor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 @cindex argument descriptors
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 This special form declares that the function in which it appears is a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 command, and that it may therefore be called interactively (via
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 @kbd{M-x} or by entering a key sequence bound to it). The argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 @var{arg-descriptor} declares how to compute the arguments to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 command when the command is called interactively.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 A command may be called from Lisp programs like any other function, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 then the caller supplies the arguments and @var{arg-descriptor} has no
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 effect.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 The @code{interactive} form has its effect because the command loop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (actually, its subroutine @code{call-interactively}) scans through the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 function definition looking for it, before calling the function. Once
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 the function is called, all its body forms including the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 @code{interactive} form are executed, but at this time
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 @code{interactive} simply returns @code{nil} without even evaluating its
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 argument.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 @end defspec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 There are three possibilities for the argument @var{arg-descriptor}:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 @itemize @bullet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 It may be omitted or @code{nil}; then the command is called with no
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 arguments. This leads quickly to an error if the command requires one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 or more arguments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 It may be a Lisp expression that is not a string; then it should be a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 form that is evaluated to get a list of arguments to pass to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 @cindex argument evaluation form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 If this expression reads keyboard input (this includes using the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 minibuffer), keep in mind that the integer value of point or the mark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 before reading input may be incorrect after reading input. This is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 because the current buffer may be receiving subprocess output;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 if subprocess output arrives while the command is waiting for input,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 it could relocate point and the mark.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 Here's an example of what @emph{not} to do:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 @smallexample
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (list (region-beginning) (region-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (read-string "Foo: " nil 'my-history)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 @end smallexample
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 Here's how to avoid the problem, by examining point and the mark only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 after reading the keyboard input:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 @smallexample
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (let ((string (read-string "Foo: " nil 'my-history)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (list (region-beginning) (region-end) string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 @end smallexample
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 @cindex argument prompt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 It may be a string; then its contents should consist of a code character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 followed by a prompt (which some code characters use and some ignore).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 The prompt ends either with the end of the string or with a newline.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 Here is a simple example:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 @smallexample
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (interactive "bFrobnicate buffer: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 @end smallexample
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 The code letter @samp{b} says to read the name of an existing buffer,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 with completion. The buffer name is the sole argument passed to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 command. The rest of the string is a prompt.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 If there is a newline character in the string, it terminates the prompt.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 If the string does not end there, then the rest of the string should
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 contain another code character and prompt, specifying another argument.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 You can specify any number of arguments in this way.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 @c Emacs 19 feature
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 The prompt string can use @samp{%} to include previous argument values
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (starting with the first argument) in the prompt. This is done using
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 @code{format} (@pxref{Formatting Strings}). For example, here is how
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 you could read the name of an existing buffer followed by a new name to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 give to that buffer:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 @smallexample
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (interactive "bBuffer to rename: \nsRename buffer %s to: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 @end smallexample
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 @cindex @samp{*} in interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 @cindex read-only buffers in interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 If the first character in the string is @samp{*}, then an error is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 signaled if the buffer is read-only.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 @cindex @samp{@@} in interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 @c Emacs 19 feature
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 If the first character in the string is @samp{@@}, and if the key
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 sequence used to invoke the command includes any mouse events, then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 the window associated with the first of those events is selected
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 before the command is run.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 @cindex @samp{_} in interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 @c XEmacs feature
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 If the first character in the string is @samp{_}, then this command will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 not cause the region to be deactivated when it completes; that is,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 @code{zmacs-region-stays} will be set to @code{t} when the command exits
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 successfully.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 You can use @samp{*}, @samp{@@}, and @samp{_} together; the order does
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 not matter. Actual reading of arguments is controlled by the rest of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 the prompt string (starting with the first character that is not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 @samp{*}, @samp{@@}, or @samp{_}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 @end itemize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 @node Interactive Codes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 @subsection Code Characters for @code{interactive}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 @cindex interactive code description
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 @cindex description for interactive codes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 @cindex codes, interactive, description of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 @cindex characters for interactive codes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 The code character descriptions below contain a number of key words,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 defined here as follows:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 @table @b
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 @item Completion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 @cindex interactive completion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 Provide completion. @key{TAB}, @key{SPC}, and @key{RET} perform name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 completion because the argument is read using @code{completing-read}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (@pxref{Completion}). @kbd{?} displays a list of possible completions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 @item Existing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 Require the name of an existing object. An invalid name is not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 accepted; the commands to exit the minibuffer do not exit if the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 input is not valid.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 @item Default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 @cindex default argument string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 A default value of some sort is used if the user enters no text in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 minibuffer. The default depends on the code character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 @item No I/O
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 This code letter computes an argument without reading any input.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 Therefore, it does not use a prompt string, and any prompt string you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 supply is ignored.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 Even though the code letter doesn't use a prompt string, you must follow
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 it with a newline if it is not the last code character in the string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 @item Prompt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 A prompt immediately follows the code character. The prompt ends either
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 with the end of the string or with a newline.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 @item Special
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 This code character is meaningful only at the beginning of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 interactive string, and it does not look for a prompt or a newline.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 It is a single, isolated character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 @cindex reading interactive arguments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 Here are the code character descriptions for use with @code{interactive}:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 @table @samp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 @item *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 Signal an error if the current buffer is read-only. Special.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 @item @@
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 Select the window mentioned in the first mouse event in the key
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 sequence that invoked this command. Special.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 @item _
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 Do not cause the region to be deactivated when this command completes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 Special.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 @item a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 A function name (i.e., a symbol satisfying @code{fboundp}). Existing,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 Completion, Prompt.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 @item b
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 The name of an existing buffer. By default, uses the name of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 current buffer (@pxref{Buffers}). Existing, Completion, Default,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 Prompt.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 @item B
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 A buffer name. The buffer need not exist. By default, uses the name of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 a recently used buffer other than the current buffer. Completion,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 Default, Prompt.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 @item c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 A character. The cursor does not move into the echo area. Prompt.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 @item C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 A command name (i.e., a symbol satisfying @code{commandp}). Existing,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 Completion, Prompt.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 @item d
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 @cindex position argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 The position of point, as an integer (@pxref{Point}). No I/O.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 @item D
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 A directory name. The default is the current default directory of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 current buffer, @code{default-directory} (@pxref{System Environment}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 Existing, Completion, Default, Prompt.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 @item e
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 The last mouse-button or misc-user event in the key sequence that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 invoked the command. No I/O.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 You can use @samp{e} more than once in a single command's interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 specification. If the key sequence that invoked the command has @var{n}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 mouse-button or misc-user events, the @var{n}th @samp{e} provides the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 @var{n}th such event.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 @item f
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 A file name of an existing file (@pxref{File Names}). The default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 directory is @code{default-directory}. Existing, Completion, Default,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 Prompt.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 @item F
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 A file name. The file need not exist. Completion, Default, Prompt.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 @item k
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 A key sequence (@pxref{Keymap Terminology}). This keeps reading events
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 until a command (or undefined command) is found in the current key
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 maps. The key sequence argument is represented as a vector of events.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 The cursor does not move into the echo area. Prompt.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 This kind of input is used by commands such as @code{describe-key} and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 @code{global-set-key}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 @item K
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 A key sequence, whose definition you intend to change. This works like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 @samp{k}, except that it suppresses, for the last input event in the key
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 sequence, the conversions that are normally used (when necessary) to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 convert an undefined key into a defined one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 @item m
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 @cindex marker argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 The position of the mark, as an integer. No I/O.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 @item n
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 A number read with the minibuffer. If the input is not a number, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 user is asked to try again. The prefix argument, if any, is not used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 Prompt.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 @item N
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 @cindex raw prefix argument usage
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 The raw prefix argument. If the prefix argument is @code{nil}, then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 read a number as with @kbd{n}. Requires a number. @xref{Prefix Command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 Arguments}. Prompt.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 @item p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 @cindex numeric prefix argument usage
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 The numeric prefix argument. (Note that this @samp{p} is lower case.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 No I/O.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 @item P
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 The raw prefix argument. (Note that this @samp{P} is upper case.) No
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 I/O.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 @item r
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 @cindex region argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 Point and the mark, as two numeric arguments, smallest first. This is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 the only code letter that specifies two successive arguments rather than
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 one. No I/O.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 @item s
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 Arbitrary text, read in the minibuffer and returned as a string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (@pxref{Text from Minibuffer}). Terminate the input with either
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 @key{LFD} or @key{RET}. (@kbd{C-q} may be used to include either of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 these characters in the input.) Prompt.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 @item S
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 An interned symbol whose name is read in the minibuffer. Any whitespace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 character terminates the input. (Use @kbd{C-q} to include whitespace in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 the string.) Other characters that normally terminate a symbol (e.g.,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 parentheses and brackets) do not do so here. Prompt.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 @item v
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 A variable declared to be a user option (i.e., satisfying the predicate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 @code{user-variable-p}). @xref{High-Level Completion}. Existing,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 Completion, Prompt.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 @item x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 A Lisp object, specified with its read syntax, terminated with a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 @key{LFD} or @key{RET}. The object is not evaluated. @xref{Object from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 Minibuffer}. Prompt.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 @item X
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 @cindex evaluated expression argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 A Lisp form is read as with @kbd{x}, but then evaluated so that its
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 value becomes the argument for the command. Prompt.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 @node Interactive Examples
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 @subsection Examples of Using @code{interactive}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 @cindex examples of using @code{interactive}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 @cindex @code{interactive}, examples of using
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 Here are some examples of @code{interactive}:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (defun foo1 () ; @r{@code{foo1} takes no arguments,}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (interactive) ; @r{just moves forward two words.}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (forward-word 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 @result{} foo1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (defun foo2 (n) ; @r{@code{foo2} takes one argument,}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (interactive "p") ; @r{which is the numeric prefix.}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (forward-word (* 2 n)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 @result{} foo2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 (defun foo3 (n) ; @r{@code{foo3} takes one argument,}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 (interactive "nCount:") ; @r{which is read with the Minibuffer.}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 (forward-word (* 2 n)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 @result{} foo3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (defun three-b (b1 b2 b3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 "Select three existing buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 Put them into three windows, selecting the last one."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (interactive "bBuffer1:\nbBuffer2:\nbBuffer3:")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 (delete-other-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (split-window (selected-window) 8)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (switch-to-buffer b1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (other-window 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (split-window (selected-window) 8)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (switch-to-buffer b2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (other-window 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (switch-to-buffer b3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 @result{} three-b
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (three-b "*scratch*" "declarations.texi" "*mail*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 @result{} nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 @node Interactive Call
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 @section Interactive Call
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 @cindex interactive call
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 After the command loop has translated a key sequence into a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 definition, it invokes that definition using the function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 @code{command-execute}. If the definition is a function that is a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 command, @code{command-execute} calls @code{call-interactively}, which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 reads the arguments and calls the command. You can also call these
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 functions yourself.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 @defun commandp object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 Returns @code{t} if @var{object} is suitable for calling interactively;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 that is, if @var{object} is a command. Otherwise, returns @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 The interactively callable objects include strings and vectors (treated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 as keyboard macros), lambda expressions that contain a top-level call to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 @code{interactive}, compiled-function objects made from such lambda
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 expressions, autoload objects that are declared as interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 (non-@code{nil} fourth argument to @code{autoload}), and some of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 primitive functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 A symbol is @code{commandp} if its function definition is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 @code{commandp}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 Keys and keymaps are not commands. Rather, they are used to look up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 commands (@pxref{Keymaps}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 See @code{documentation} in @ref{Accessing Documentation}, for a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 realistic example of using @code{commandp}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 @defun call-interactively command &optional record-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 This function calls the interactively callable function @var{command},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 reading arguments according to its interactive calling specifications.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 An error is signaled if @var{command} is not a function or if it cannot
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 be called interactively (i.e., is not a command). Note that keyboard
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 macros (strings and vectors) are not accepted, even though they are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 considered commands, because they are not functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 @c XEmacs feature?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 If @var{record-flag} is the symbol @code{lambda}, the interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 calling arguments for @code{command} are read and returned as a list,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 but the function is not called on them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 @cindex record command history
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 If @var{record-flag} is @code{t}, then this command and its arguments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 are unconditionally added to the list @code{command-history}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 Otherwise, the command is added only if it uses the minibuffer to read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 an argument. @xref{Command History}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 @defun command-execute command &optional record-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 @cindex keyboard macro execution
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 This function executes @var{command} as an editing command. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 argument @var{command} must satisfy the @code{commandp} predicate; i.e.,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 it must be an interactively callable function or a keyboard macro.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 A string or vector as @var{command} is executed with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 @code{execute-kbd-macro}. A function is passed to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 @code{call-interactively}, along with the optional @var{record-flag}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 A symbol is handled by using its function definition in its place. A
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 symbol with an @code{autoload} definition counts as a command if it was
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 declared to stand for an interactively callable function. Such a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 definition is handled by loading the specified library and then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 rechecking the definition of the symbol.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 @deffn Command execute-extended-command prefix-argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 @cindex read command name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 This function reads a command name from the minibuffer using
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 @code{completing-read} (@pxref{Completion}). Then it uses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 @code{command-execute} to call the specified command. Whatever that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 command returns becomes the value of @code{execute-extended-command}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 @cindex execute with prefix argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 If the command asks for a prefix argument, it receives the value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 @var{prefix-argument}. If @code{execute-extended-command} is called
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 interactively, the current raw prefix argument is used for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 @var{prefix-argument}, and thus passed on to whatever command is run.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 @c !!! Should this be @kindex?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 @cindex @kbd{M-x}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 @code{execute-extended-command} is the normal definition of @kbd{M-x},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 so it uses the string @w{@samp{M-x }} as a prompt. (It would be better
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 to take the prompt from the events used to invoke
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 @code{execute-extended-command}, but that is painful to implement.) A
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 description of the value of the prefix argument, if any, also becomes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 part of the prompt.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 (execute-extended-command 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 ---------- Buffer: Minibuffer ----------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 1 M-x forward-word RET
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 ---------- Buffer: Minibuffer ----------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 @result{} t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 @defun interactive-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 This function returns @code{t} if the containing function (the one that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 called @code{interactive-p}) was called interactively, with the function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 @code{call-interactively}. (It makes no difference whether
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 @code{call-interactively} was called from Lisp or directly from the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 editor command loop.) If the containing function was called by Lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 evaluation (or with @code{apply} or @code{funcall}), then it was not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 called interactively.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 The most common use of @code{interactive-p} is for deciding whether to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 print an informative message. As a special exception,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 @code{interactive-p} returns @code{nil} whenever a keyboard macro is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 being run. This is to suppress the informative messages and speed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 execution of the macro.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 For example:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 (defun foo ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 (and (interactive-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 (message "foo")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 @result{} foo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 (defun bar ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 (setq foobar (list (foo) (interactive-p))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 @result{} bar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 ;; @r{Type @kbd{M-x foo}.}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 @print{} foo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 ;; @r{Type @kbd{M-x bar}.}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 ;; @r{This does not print anything.}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 foobar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 @result{} (nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 @node Command Loop Info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 @section Information from the Command Loop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 The editor command loop sets several Lisp variables to keep status
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 records for itself and for commands that are run.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 @defvar last-command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 This variable records the name of the previous command executed by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 command loop (the one before the current command). Normally the value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 is a symbol with a function definition, but this is not guaranteed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 The value is copied from @code{this-command} when a command returns to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 the command loop, except when the command specifies a prefix argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 for the following command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 @defvar this-command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 @cindex current command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 This variable records the name of the command now being executed by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 the editor command loop. Like @code{last-command}, it is normally a symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 with a function definition.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 The command loop sets this variable just before running a command, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 copies its value into @code{last-command} when the command finishes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 (unless the command specifies a prefix argument for the following
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 command).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 @cindex kill command repetition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 Some commands set this variable during their execution, as a flag for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 whatever command runs next. In particular, the functions for killing text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 set @code{this-command} to @code{kill-region} so that any kill commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 immediately following will know to append the killed text to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 previous kill.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 If you do not want a particular command to be recognized as the previous
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 command in the case where it got an error, you must code that command to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 prevent this. One way is to set @code{this-command} to @code{t} at the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 beginning of the command, and set @code{this-command} back to its proper
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 value at the end, like this:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 (defun foo (args@dots{})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 (interactive @dots{})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 (let ((old-this-command this-command))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 (setq this-command t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 @r{@dots{}do the work@dots{}}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 (setq this-command old-this-command)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 @defun this-command-keys
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 This function returns a vector containing the key and mouse events that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 invoked the present command, plus any previous commands that generated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 the prefix argument for this command. (Note: this is not the same as in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 FSF Emacs, which can return a string.) @xref{Events}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 This function copies the vector and the events; it is safe to keep and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 modify them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 (this-command-keys)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 ;; @r{Now use @kbd{C-u C-x C-e} to evaluate that.}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 @result{} [#<keypress-event control-U> #<keypress-event control-X> #<keypress-event control-E>]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 @ignore Not in XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 @defvar last-nonmenu-event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 This variable holds the last input event read as part of a key
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 sequence, not counting events resulting from mouse menus.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 One use of this variable is to figure out a good default location to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 pop up another menu.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 @end ignore
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 @defvar last-command-event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 This variable is set to the last input event that was read by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 command loop as part of a command. The principal use of this variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 is in @code{self-insert-command}, which uses it to decide which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 character to insert.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 This variable is off limits: you may not set its value or modify the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 event that is its value, as it is destructively modified by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 @code{read-key-sequence}. If you want to keep a pointer to this value,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 you must use @code{copy-event}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 Note that this variable is an alias for @code{last-command-char} in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 FSF Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 last-command-event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 ;; @r{Now type @kbd{C-u C-x C-e}.}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 @result{} #<keypress-event control-E>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 @defvar last-command-char
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
726
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
727 If the value of @code{last-command-event} is a keyboard event, then this
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
728 is the nearest character equivalent to it (or @code{nil} if there is no
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
729 character equivalent). @code{last-command-char} is the character that
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
730 @code{self-insert-command} will insert in the buffer. Remember that
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
731 there is @emph{not} a one-to-one mapping between keyboard events and
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
732 XEmacs characters: many keyboard events have no corresponding character,
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
733 and when the Mule feature is available, most characters can not be input
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
734 on standard keyboards, except possibly with help from an input method.
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
735 So writing code that examines this variable to determine what key has
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
736 been typed is bad practice, unless you are certain that it will be one
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
737 of a small set of characters.
54
05472e90ae02 Import from CVS: tag r19-16-pre2
cvs
parents: 2
diff changeset
738
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
739 This variable exists for compatibility with Emacs version 18.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 @group
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
743 last-command-char
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 ;; @r{Now use @kbd{C-u C-x C-e} to evaluate that.}
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
745 @result{} ?\^E
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 @defvar current-mouse-event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 This variable holds the mouse-button event which invoked this command,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 or @code{nil}. This is what @code{(interactive "e")} returns.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 @defvar echo-keystrokes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 This variable determines how much time should elapse before command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 characters echo. Its value must be an integer, which specifies the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 number of seconds to wait before echoing. If the user types a prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 key (say @kbd{C-x}) and then delays this many seconds before continuing,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 the key @kbd{C-x} is echoed in the echo area. Any subsequent characters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 in the same command will be echoed as well.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 If the value is zero, then command input is not echoed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 @node Events
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 @section Events
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 @cindex events
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 @cindex input events
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 The XEmacs command loop reads a sequence of @dfn{events} that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 represent keyboard or mouse activity. Unlike in Emacs 18 and in FSF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 Emacs, events are a primitive Lisp type that must be manipulated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 using their own accessor and settor primitives. This section describes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 the representation and meaning of input events in detail.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 A key sequence that starts with a mouse event is read using the keymaps
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 of the buffer in the window that the mouse was in, not the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 buffer. This does not imply that clicking in a window selects that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 window or its buffer---that is entirely under the control of the command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 binding of the key sequence.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 For information about how exactly the XEmacs command loop works,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 @xref{Reading Input}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 @defun eventp object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 This function returns non-@code{nil} if @var{event} is an input event.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 * Event Types:: Events come in different types.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 * Event Contents:: What the contents of each event type are.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 * Event Predicates:: Querying whether an event is of a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 particular type.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 * Accessing Mouse Event Positions::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 Determining where a mouse event occurred,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 and over what.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 * Accessing Other Event Info:: Accessing non-positional event info.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 * Working With Events:: Creating, copying, and destroying events.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 * Converting Events:: Converting between events, keys, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 characters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 @node Event Types
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 @subsection Event Types
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 Events represent keyboard or mouse activity or status changes of various
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 sorts, such as process input being available or a timeout being triggered.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 The different event types are as follows:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 @table @asis
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 @item key-press event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 A key was pressed. Note that modifier keys such as ``control'', ``shift'',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 and ``alt'' do not generate events; instead, they are tracked internally
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 by XEmacs, and non-modifier key presses generate events that specify both
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 the key pressed and the modifiers that were held down at the time.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 @item button-press event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 @itemx button-release event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 A button was pressed or released. Along with the button that was pressed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 or released, button events specify the modifier keys that were held down
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 at the time and the position of the pointer at the time.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
825 @item dnd-drop event
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
826 Some dragged data was released. The event provides the button that was used
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
827 to drag the data, the modifier keys that were hold down, the position where
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
828 the drop took place, and a lisp object containing the type and the data
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
829 dropped (Note: until now only the OffiX protocol supports dnd-drop).
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
830
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
831 @item motion event
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 The pointer was moved. Along with the position of the pointer, these events
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 also specify the modifier keys that were held down at the time.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 @item misc-user event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 A menu item was selected, or the scrollbar was used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 @item process event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 Input is available on a process.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 @item timeout event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 A timeout has triggered.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 @item magic event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 Some window-system-specific action (such as a frame being resized or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 a portion of a frame needing to be redrawn) has occurred. The contents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 of this event are not accessible at the E-Lisp level, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 @code{dispatch-event} knows what to do with an event of this type.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 @item eval event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 This is a special kind of event specifying that a particular function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 needs to be called when this event is dispatched. An event of this type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 is sometimes placed in the event queue when a magic event is processed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 This kind of event should generally just be passed off to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 @code{dispatch-event}. @xref{Dispatching an Event}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 @node Event Contents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 @subsection Contents of the Different Types of Events
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 Every event, no matter what type it is, contains a timestamp (which is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 typically an offset in milliseconds from when the X server was started)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 indicating when the event occurred. In addition, many events contain
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 a @dfn{channel}, which specifies which frame the event occurred on,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 and/or a value indicating which modifier keys (shift, control, etc.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 were held down at the time of the event.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 The contents of each event are as follows:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 @table @asis
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 @item key-press event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 @table @asis
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 @item channel
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 @item timestamp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 @item key
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 Which key was pressed. This is an integer (in the printing @sc{ASCII}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 range: >32 and <127) or a symbol such as @code{left} or @code{right}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 Note that many physical keys are actually treated as two separate keys,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 depending on whether the shift key is pressed; for example, the ``a''
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 key is treated as either ``a'' or ``A'' depending on the state of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 shift key, and the ``1'' key is similarly treated as either ``1'' or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 ``!'' on most keyboards. In such cases, the shift key does not show up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 in the modifier list. For other keys, such as @code{backspace}, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 shift key shows up as a regular modifier.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 @item modifiers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 Which modifier keys were pressed. As mentioned above, the shift key
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 is not treated as a modifier for many keys and will not show up in this list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 in such cases.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 @item button-press event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 @itemx button-release event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 @table @asis
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 @item channel
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 @item timestamp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 @item button
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 What button went down or up. Buttons are numbered starting at 1.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 @item modifiers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 Which modifier keys were pressed. The special business mentioned above
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 for the shift key does @emph{not} apply to mouse events.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 @item x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 @itemx y
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 The position of the pointer (in pixels) at the time of the event.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
906 @item dnd-drop event
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
907 @table @asis
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
908 @item channel
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
909 @item timestamp
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
910 @item button
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
911 What button was used to drag. Buttons are numbered starting at 1.
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
912 @item modifiers
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
913 Which modifier keys were pressed to do the drag.
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
914 @item x
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
915 @itemx y
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
916 The position of the pointer (in pixels) at the time of the event.
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
917 @item data
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
918 A lisp object containing the dropped type and data.
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
919 @end table
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
920
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 @item pointer-motion event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 @table @asis
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 @item channel
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 @item timestamp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 @item x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 @itemx y
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 The position of the pointer (in pixels) after it moved.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 @item modifiers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 Which modifier keys were pressed. The special business mentioned above
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 for the shift key does @emph{not} apply to mouse events.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 @item misc-user event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 @table @asis
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 @item timestamp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 @item function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 The E-Lisp function to call for this event. This is normally either
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 @code{eval} or @code{call-interactively}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 @item object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 The object to pass to the function. This is normally the callback that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 was specified in the menu description.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 @item process_event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 @table @asis
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 @item timestamp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 @item process
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 The Emacs ``process'' object in question.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 @item timeout event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 @table @asis
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 @item timestamp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 @item function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 The E-Lisp function to call for this timeout. It is called with one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 argument, the event.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 @item object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 Some Lisp object associated with this timeout, to make it easier to tell
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 them apart. The function and object for this event were specified when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 the timeout was set.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 @item magic event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 @table @asis
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 @item timestamp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 (The rest of the information in this event is not user-accessible.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 @item eval event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 @table @asis
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 @item timestamp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 @item function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 An E-Lisp function to call when this event is dispatched.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 @item object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 The object to pass to the function. The function and object are set
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 when the event is created.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
980 @defun event-type event
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
981 Return the type of @var{event}.
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
982
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
983 This will be a symbol; one of
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
984
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
985 @table @code
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
986 @item key-press
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
987 A key was pressed.
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
988 @item button-press
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
989 A mouse button was pressed.
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
990 @item button-release
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
991 A mouse button was released.
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
992 @item dnd-drop
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
993 A drop occured.
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
994 @item motion
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
995 The mouse moved.
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
996 @item misc-user
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
997 Some other user action happened; typically, this is
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
998 a menu selection or scrollbar action.
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
999 @item process
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
1000 Input is available from a subprocess.
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
1001 @item timeout
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
1002 A timeout has expired.
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
1003 @item eval
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
1004 This causes a specified action to occur when dispatched.
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
1005 @item magic
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
1006 Some window-system-specific event has occurred.
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
1007 @end table
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
1008 @end defun
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
1009
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 @node Event Predicates
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 @subsection Event Predicates
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
1013 The following predicates return whether an object is an event of a
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
1014 particular type.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 @defun key-press-event-p object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 This is true if @var{object} is a key-press event.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
1020 @defun button-event-p object object
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
1021 This is true if @var{object} is a mouse button-press or button-release
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
1022 event.
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
1023 @end defun
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
1024
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
1025 @defun button-press-event-p object
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
1026 This is true if @var{object} is a mouse button-press event.
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
1027 @end defun
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
1028
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
1029 @defun button-release-event-p object
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
1030 This is true if @var{object} is a mouse button-release event.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
1033 @defun dnd-drop-event-p object
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
1034 This is true if @var{object} is a mouse dnd-drop event.
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
1035 @end defun
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
1036
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 @defun motion-event-p object
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
1038 This is true if @var{object} is a mouse motion event.
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
1039 @end defun
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
1040
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
1041 @defun mouse-event-p object
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
1042 This is true if @var{object} is a mouse button-press, button-release
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
1043 or motion event.
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
1044 @end defun
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
1045
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
1046 @defun eval-event-p object
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
1047 This is true if @var{object} is an eval event.
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
1048 @end defun
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
1049
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
1050 @defun misc-user-event-p object
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
1051 This is true if @var{object} is a misc-user event.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 @defun process-event-p object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 This is true if @var{object} is a process event.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058 @defun timeout-event-p object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059 This is true if @var{object} is a timeout event.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 @defun event-live-p object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063 This is true if @var{object} is any event that has not been deallocated.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066 @node Accessing Mouse Event Positions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067 @subsection Accessing the Position of a Mouse Event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
1069 Unlike other events, mouse events (i.e. motion, button-press,
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
1070 button-release, and dnd-drop events) occur in a particular location
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
1071 on the screen. Many primitives are provided for determining exactly
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
1072 where the event occurred and what is under that location.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 * Frame-Level Event Position Info::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076 * Window-Level Event Position Info::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077 * Event Text Position Info::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078 * Event Glyph Position Info::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079 * Event Toolbar Position Info::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080 * Other Event Position Info::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083 @node Frame-Level Event Position Info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084 @subsubsection Frame-Level Event Position Info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086 The following functions return frame-level information about where
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087 a mouse event occurred.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089 @defun event-frame event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090 This function returns the ``channel'' or frame that the given mouse
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
1091 motion, button press, button release, or dnd drop event occurred in.
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
1092 This will be @code{nil} for non-mouse events.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095 @defun event-x-pixel event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096 This function returns the X position in pixels of the given mouse event.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097 The value returned is relative to the frame the event occurred in.
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
1098 This will signal an error if the event is not a mouse event.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101 @defun event-y-pixel event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102 This function returns the Y position in pixels of the given mouse event.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103 The value returned is relative to the frame the event occurred in.
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
1104 This will signal an error if the event is not a mouse event.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1105 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1106
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1107 @node Window-Level Event Position Info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108 @subsubsection Window-Level Event Position Info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1110 The following functions return window-level information about where
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111 a mouse event occurred.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113 @defun event-window event
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
1114 Given a mouse motion, button press, button release, or dnd drop event, compute and
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1115 return the window on which that event occurred. This may be @code{nil}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1116 if the event occurred in the border or over a toolbar. The modeline is
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
1117 considered to be within the window it describes.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1119
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1120 @defun event-buffer event
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
1121 Given a mouse motion, button press, button release, or dnd drop event, compute and
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122 return the buffer of the window on which that event occurred. This may
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123 be @code{nil} if the event occurred in the border or over a toolbar.
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
1124 The modeline is considered to be within the window it describes. This is
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1125 equivalent to calling @code{event-window} and then calling
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
1126 @code{window-buffer} on the result if it is a window.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129 @defun event-window-x-pixel event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130 This function returns the X position in pixels of the given mouse event.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131 The value returned is relative to the window the event occurred in.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132 This will signal an error if the event is not a mouse-motion, button-press,
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
1133 button-release, or dnd-drop event.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136 @defun event-window-y-pixel event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137 This function returns the Y position in pixels of the given mouse event.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138 The value returned is relative to the window the event occurred in.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139 This will signal an error if the event is not a mouse-motion, button-press,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140 or button-release event.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1141 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1142
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143 @node Event Text Position Info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144 @subsubsection Event Text Position Info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146 The following functions return information about the text (including the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147 modeline) that a mouse event occurred over or near.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149 @defun event-over-text-area-p event
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
1150 Given a mouse-motion, button-press, button-release, or dnd-drop event, this
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1151 function returns @code{t} if the event is over the text area of a
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152 window. Otherwise, @code{nil} is returned. The modeline is not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153 considered to be part of the text area.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 @defun event-over-modeline-p event
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
1157 Given a mouse-motion, button-press, button-release, or dnd-drop event, this
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158 function returns @code{t} if the event is over the modeline of a window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159 Otherwise, @code{nil} is returned.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162 @defun event-x event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163 This function returns the X position of the given mouse-motion,
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
1164 button-press, button-release, or dnd-drop event in characters. This is relative
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165 to the window the event occurred over.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168 @defun event-y event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169 This function returns the Y position of the given mouse-motion,
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
1170 button-press, button-release, or dnd-drop event in characters. This is relative
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171 to the window the event occurred over.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174 @defun event-point event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175 This function returns the character position of the given mouse-motion,
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
1176 button-press, button-release, or dnd-drop event. If the event did not occur over
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177 a window, or did not occur over text, then this returns @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1178 Otherwise, it returns an index into the buffer visible in the event's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1179 window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1180 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1181
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182 @defun event-closest-point event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183 This function returns the character position of the given mouse-motion,
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
1184 button-press, button-release, or dnd-drop event. If the event did not occur over
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1185 a window or over text, it returns the closest point to the location of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1186 the event. If the Y pixel position overlaps a window and the X pixel
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1187 position is to the left of that window, the closest point is the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1188 beginning of the line containing the Y position. If the Y pixel
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189 position overlaps a window and the X pixel position is to the right of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190 that window, the closest point is the end of the line containing the Y
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191 position. If the Y pixel position is above a window, 0 is returned. If
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192 it is below a window, the value of @code{(window-end)} is returned.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195 @node Event Glyph Position Info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196 @subsubsection Event Glyph Position Info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1198 The following functions return information about the glyph (if any) that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1199 a mouse event occurred over.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1200
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1201 @defun event-over-glyph-p event
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
1202 Given a mouse-motion, button-press, button-release, or dnd-drop event, this
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1203 function returns @code{t} if the event is over a glyph. Otherwise,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1204 @code{nil} is returned.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1206
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1207 @defun event-glyph-extent event
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
1208 If the given mouse-motion, button-press, button-release, or dnd-drop event happened
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1209 on top of a glyph, this returns its extent; else @code{nil} is returned.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1210 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1211
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1212 @defun event-glyph-x-pixel event
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
1213 Given a mouse-motion, button-press, button-release, or dnd-drop event over a
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1214 glyph, this function returns the X position of the pointer relative to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215 the upper left of the glyph. If the event is not over a glyph, it returns
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216 @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1217 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1218
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1219 @defun event-glyph-y-pixel event
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
1220 Given a mouse-motion, button-press, button-release, or dnd-drop event over a
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1221 glyph, this function returns the Y position of the pointer relative to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222 the upper left of the glyph. If the event is not over a glyph, it returns
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1223 @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1224 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1225
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226 @node Event Toolbar Position Info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1227 @subsubsection Event Toolbar Position Info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1229 @defun event-over-toolbar-p event
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
1230 Given a mouse-motion, button-press, button-release, or dnd-drop event, this
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231 function returns @code{t} if the event is over a toolbar. Otherwise,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1232 @code{nil} is returned.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1233 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235 @defun event-toolbar-button event
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
1236 If the given mouse-motion, button-press, button-release, or dnd-drop event
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237 happened on top of a toolbar button, this function returns the button.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238 Otherwise, @code{nil} is returned.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241 @node Other Event Position Info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242 @subsubsection Other Event Position Info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244 @defun event-over-border-p event
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
1245 Given a mouse-motion, button-press, button-release, or dnd-drop event, this
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1246 function returns @code{t} if the event is over an internal toolbar.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1247 Otherwise, @code{nil} is returned.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1248 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1249
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250 @node Accessing Other Event Info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1251 @subsection Accessing the Other Contents of Events
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1252
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253 The following functions allow access to the contents of events other than
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1254 the position info described in the previous section.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1255
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1256 @defun event-timestamp event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1257 This function returns the timestamp of the given event object.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1258 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1259
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1260 @defun event-device event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1261 This function returns the device that the given event occurred on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1262 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1263
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1264 @defun event-key event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1265 This function returns the Keysym of the given key-press event.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1266 This will be the @sc{ASCII} code of a printing character, or a symbol.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1267 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1268
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1269 @defun event-button event
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
1270 This function returns the button-number of the given button-press or
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
1271 button-release event.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1272 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1273
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1274 @defun event-modifiers event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1275 This function returns a list of symbols, the names of the modifier keys
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1276 which were down when the given mouse or keyboard event was produced.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1277 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1278
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1279 @defun event-modifier-bits event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1280 This function returns a number representing the modifier keys which were down
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1281 when the given mouse or keyboard event was produced.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1282 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1283
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1284 @defun event-function event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1285 This function returns the callback function of the given timeout, misc-user,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1286 or eval event.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1287 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1288
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1289 @defun event-object event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1290 This function returns the callback function argument of the given timeout,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1291 misc-user, or eval event.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1292 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1293
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1294 @defun event-process event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1295 This function returns the process of the given process event.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1296 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1297
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
1298 @defun event-drag-and-drop-data event
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
1299 This function returns a list containing the type of the drop as first element
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
1300 and the data of the drop as second element.
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
1301 @end defun
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 199
diff changeset
1302
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1303 @node Working With Events
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1304 @subsection Working With Events
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1305
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1306 XEmacs provides primitives for creating, copying, and destroying event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1307 objects. Many functions that return events take an event object as an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1308 argument and fill in the fields of this event; or they make accept
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1309 either an event object or @code{nil}, creating the event object first in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1310 the latter case.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1311
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1312 @defun make-event &optional type plist
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1313 This function creates a new event structure. If no arguments are
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1314 specified, the created event will be empty. To specify the event type,
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1315 use the @var{type} argument. The allowed types are @code{empty},
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1316 @code{key-press}, @code{button-press}, @code{button-release}, or
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1317 @code{motion}.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1318
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1319 @var{plist} is a property list, the properties being compatible to those
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1320 returned by @code{event-properties}. For events other than
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1321 @code{empty}, it is mandatory to specify certain properties. For
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1322 @code{empty} events, @var{plist} must be @code{nil}. The list is
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1323 @dfn{canonicalized}, which means that if a property keyword is present
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1324 more than once, only the first instance is taken into account.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1325 Specifying an unknown or illegal property signals an error.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1326
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1327 The following properties are allowed:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1328
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1329 @table @b
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1330 @item @code{channel}
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1331 The event channel. This is a frame or a console. For mouse events (of
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1332 type @code{button-press}, @code{button-release} and @code{motion}), this
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1333 must be a frame. For key-press events, it must be a console. If
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1334 channel is unspecified by @var{plist}, it will be set to the selected
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1335 frame or selected console, as appropriate.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1336
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1337 @item @code{key}
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1338 The event key. This is either a symbol or a character. It is allowed
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1339 (and required) only for key-press events.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1340
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1341 @item @code{button}
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1342 The event button. This an integer, either 1, 2 or 3. It is allowed
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1343 only for button-press and button-release events.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1344
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1345 @item @code{modifiers}
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1346 The event modifiers. This is a list of modifier symbols. It is allowed
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1347 for key-press, button-press, button-release and motion events.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1348
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1349 @item @code{x}
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1350 The event X coordinate. This is an integer. It is relative to the
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1351 channel's root window, and is allowed for button-press, button-release
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1352 and motion events.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1353
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1354 @item @code{y}
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1355 The event Y coordinate. This is an integer. It is relative to the
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1356 channel's root window, and is allowed for button-press, button-release
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1357 and motion events. This means that, for instance, to access the
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1358 toolbar, the @code{y} property will have to be negative.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1359
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1360 @item @code{timestamp}
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1361 The event timestamp, a non-negative integer. Allowed for all types of
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1362 events.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1363 @end table
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1364
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1365 @emph{WARNING}: the event object returned by this function may be a
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1366 reused one; see the function @code{deallocate-event}.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1367
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1368 The events created by @code{make-event} can be used as non-interactive
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1369 arguments to the functions with an @code{(interactive "e")}
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1370 specification.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1371
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1372 Here are some basic examples of usage:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1373
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1374 @lisp
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1375 @group
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1376 ;; @r{Create an empty event.}
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1377 (make-event)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1378 @result{} #<empty-event>
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1379 @end group
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1380
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1381 @group
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1382 ;; @r{Try creating a key-press event.}
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1383 (make-event 'key-press)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1384 @error{} Undefined key for keypress event
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1385 @end group
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1386
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1387 @group
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1388 ;; @r{Creating a key-press event, try No. 2.}
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1389 (make-event 'key-press '(key home))
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1390 @result{} #<keypress-event home>
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1391 @end group
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1392
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1393 @group
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1394 ;; @r{Create a key-press event of dubious fame.}
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1395 (make-event 'key-press '(key escape modifiers (meta alt control shift)))
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1396 @result{} #<keypress-event control-meta-alt-shift-escape>
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1397 @end group
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1398
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1399 @group
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1400 ;; @r{Create a M-button1 event at coordinates defined by variables
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1401 ;; @var{x} and @var{y}.}
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1402 (make-event 'button-press `(button 1 modifiers (meta) x ,x y ,y))
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1403 @result{} #<buttondown-event meta-button1>
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1404 @end group
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1405
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1406 @group
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1407 ;; @r{Create a simmilar button-release event.}
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1408 (make-event 'button-release `(button 1 modifiers (meta) x ,x y ,x))
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1409 @result{} #<buttonup-event meta-button1up>
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1410 @end group
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1411
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1412 @group
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1413 ;; @r{Create a mouse-motion event.}
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1414 (make-event 'motion '(x 20 y 30))
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1415 @result{} #<motion-event 20, 67>
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1416
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1417 ;; @r{(the Y coordinate is printed incompatibly; however:)}
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1418 (event-properties (make-event 'motion '(x 20 y 30)))
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1419 @result{} (channel #<x-frame "emacs" 0x8e2> x 20 y 30 modifiers nil timestamp 0)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1420 @end group
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1421 @end lisp
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1422
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1423 In conjunction with @code{event-properties}, you can use
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1424 @code{make-event} to create modified copies of existing events. For
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1425 instance, the following code will return an @code{equal} copy of
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1426 @var{event}:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1427
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1428 @lisp
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1429 (make-event (event-type @var{event})
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1430 (event-properties @var{event}))
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1431 @end lisp
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1432
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1433 Note, however, that you cannot use @code{make-event} as the generic
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1434 replacement for @code{copy-event}, because it does not allow creating
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1435 all of the event types.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1436
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1437 To create a changed copy of an event, you can use the canonicalization
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1438 feature of @var{plist}. The following example creates a copy of
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1439 @var{event}, but with @code{modifiers} reset to @code{nil}.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1440
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1441 @lisp
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1442 (make-event (event-type @var{event})
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1443 (append '(modifiers nil)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1444 (event-properties @var{event})))
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1445 @end lisp
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1446 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1447
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1448 @defun copy-event event1 &optional event2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1449 This function makes a copy of the given event object. If a second
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1450 argument is given, the first event is copied into the second and the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1451 second is returned. If the second argument is not supplied (or is
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 207
diff changeset
1452 @code{nil}) then a new event will be made.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1453 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1454
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1455 @defun deallocate-event event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1456 This function allows the given event structure to be reused. You
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1457 @strong{MUST NOT} use this event object after calling this function with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1458 it. You will lose. It is not necessary to call this function, as event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1459 objects are garbage-collected like all other objects; however, it may be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1460 more efficient to explicitly deallocate events when you are sure that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1461 that is safe.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1462 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1463
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1464 @node Converting Events
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1465 @subsection Converting Events
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1466
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1467 XEmacs provides some auxiliary functions for converting between events
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1468 and other ways of representing keys. These are useful when working with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1469 @sc{ASCII} strings and with keymaps.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1470
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1471 @defun character-to-event ch &optional event device
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1472 This function converts a numeric @sc{ASCII} value to an event structure,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1473 replete with modifier bits. @var{ch} is the character to convert, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1474 @var{event} is the event object to fill in. This function contains
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1475 knowledge about what the codes ``mean'' -- for example, the number 9 is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1476 converted to the character @key{Tab}, not the distinct character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1477 @key{Control-I}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1478
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1479 Note that @var{ch} does not have to be a numeric value, but can be a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1480 symbol such as @code{clear} or a list such as @code{(control
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1481 backspace)}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1482
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1483 If @code{event} is not @code{nil}, it is modified; otherwise, a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1484 new event object is created. In both cases, the event is returned.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1485
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1486 Optional third arg @var{device} is the device to store in the event;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1487 this also affects whether the high bit is interpreted as a meta key. A
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1488 value of @code{nil} means use the selected device but always treat the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1489 high bit as meta.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1490
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1491 Beware that @code{character-to-event} and @code{event-to-character} are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1492 not strictly inverse functions, since events contain much more
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1493 information than the @sc{ASCII} character set can encode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1494 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1495
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1496 @defun event-to-character event &optional allow-extra-modifiers allow-meta allow-non-ascii
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1497 This function returns the closest @sc{ASCII} approximation to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1498 @var{event}. If the event isn't a keypress, this returns @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1499
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1500 If @var{allow-extra-modifiers} is non-@code{nil}, then this is lenient
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1501 in its translation; it will ignore modifier keys other than
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1502 @key{control} and @key{meta}, and will ignore the @key{shift} modifier
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1503 on those characters which have no shifted @sc{ASCII} equivalent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1504 (@key{Control-Shift-A} for example, will be mapped to the same
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1505 @sc{ASCII} code as @key{Control-A}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1506
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1507 If @var{allow-meta} is non-@code{nil}, then the @key{Meta} modifier will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1508 be represented by turning on the high bit of the byte returned;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1509 otherwise, @code{nil} will be returned for events containing the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1510 @key{Meta} modifier.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1511
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1512 If @var{allow-non-ascii} is non-@code{nil}, then characters which are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1513 present in the prevailing character set (@pxref{Keymaps, variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1514 @code{character-set-property}}) will be returned as their code in that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1515 character set, instead of the return value being restricted to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1516 @sc{ASCII}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1517
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1518 Note that specifying both @var{allow-meta} and @var{allow-non-ascii} is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1519 ambiguous, as both use the high bit; @key{M-x} and @key{oslash} will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1520 indistinguishable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1521 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1522
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1523 @defun events-to-keys events &optional no-mice
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1524 Given a vector of event objects, this function returns a vector of key
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1525 descriptors, or a string (if they all fit in the @sc{ASCII} range).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1526 Optional arg @var{no-mice} means that button events are not allowed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1527 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1528
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1529 @node Reading Input
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1530 @section Reading Input
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1531
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1532 The editor command loop reads keyboard input using the function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1533 @code{next-event} and constructs key sequences out of the events using
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1534 @code{dispatch-event}. Lisp programs can also use the function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1535 @code{read-key-sequence}, which reads input a key sequence at a time.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1536 See also @code{momentary-string-display} in @ref{Temporary Displays},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1537 and @code{sit-for} in @ref{Waiting}. @xref{Terminal Input}, for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1538 functions and variables for controlling terminal input modes and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1539 debugging terminal input.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1540
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1541 For higher-level input facilities, see @ref{Minibuffers}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1542
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1543 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1544 * Key Sequence Input:: How to read one key sequence.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1545 * Reading One Event:: How to read just one event.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1546 * Dispatching an Event:: What to do with an event once it has been read.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1547 * Quoted Character Input:: Asking the user to specify a character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1548 * Peeking and Discarding:: How to reread or throw away input events.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1549 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1550
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1551 @node Key Sequence Input
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1552 @subsection Key Sequence Input
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1553 @cindex key sequence input
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1554
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1555 Lisp programs can read input a key sequence at a time by calling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1556 @code{read-key-sequence}; for example, @code{describe-key} uses it to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1557 read the key to describe.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1558
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1559 @defun read-key-sequence prompt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1560 @cindex key sequence
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1561 This function reads a sequence of keystrokes or mouse clicks and returns
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1562 it as a vector of events. It keeps reading events until it has
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1563 accumulated a full key sequence; that is, enough to specify a non-prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1564 command using the currently active keymaps.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1565
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1566 The vector and the event objects it contains are freshly created, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1567 will not be side-effected by subsequent calls to this function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1568
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1569 The function @code{read-key-sequence} suppresses quitting: @kbd{C-g}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1570 typed while reading with this function works like any other character,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1571 and does not set @code{quit-flag}. @xref{Quitting}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1572
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1573 The argument @var{prompt} is either a string to be displayed in the echo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1574 area as a prompt, or @code{nil}, meaning not to display a prompt.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1575
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1576 @c XEmacs feature
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1577 If the user selects a menu item while we are prompting for a key
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1578 sequence, the returned value will be a vector of a single menu-selection
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1579 event (a misc-user event). An error will be signalled if you pass this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1580 value to @code{lookup-key} or a related function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1581
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1582 In the example below, the prompt @samp{?} is displayed in the echo area,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1583 and the user types @kbd{C-x C-f}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1584
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1585 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1586 (read-key-sequence "?")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1587
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1588 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1589 ---------- Echo Area ----------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1590 ?@kbd{C-x C-f}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1591 ---------- Echo Area ----------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1592
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1593 @result{} [#<keypress-event control-X> #<keypress-event control-F>]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1594 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1595 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1596 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1597
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1598 @ignore @c Not in XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1599 @defvar num-input-keys
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1600 @c Emacs 19 feature
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1601 This variable's value is the number of key sequences processed so far in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1602 this XEmacs session. This includes key sequences read from the terminal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1603 and key sequences read from keyboard macros being executed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1604 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1605 @end ignore
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1606
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1607 @cindex upper case key sequence
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1608 @cindex downcasing in @code{lookup-key}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1609 If an input character is an upper-case letter and has no key binding,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1610 but its lower-case equivalent has one, then @code{read-key-sequence}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1611 converts the character to lower case. Note that @code{lookup-key} does
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1612 not perform case conversion in this way.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1613
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1614 @node Reading One Event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1615 @subsection Reading One Event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1616
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1617 The lowest level functions for command input are those which read a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1618 single event. These functions often make a distinction between
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1619 @dfn{command events}, which are user actions (keystrokes and mouse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1620 actions), and other events, which serve as communication between
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1621 XEmacs and the window system.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1622
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1623 @defun next-event &optional event prompt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1624 This function reads and returns the next available event from the window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1625 system or terminal driver, waiting if necessary until an event is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1626 available. Pass this object to @code{dispatch-event} to handle it. If
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1627 an event object is supplied, it is filled in and returned; otherwise a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1628 new event object will be created.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1629
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1630 Events can come directly from the user, from a keyboard macro, or from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1631 @code{unread-command-events}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1632
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1633 In most cases, the function @code{next-command-event} is more
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1634 appropriate.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1635 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1636
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1637 @defun next-command-event &optional event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1638 This function returns the next available ``user'' event from the window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1639 system or terminal driver. Pass this object to @code{dispatch-event} to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1640 handle it. If an event object is supplied, it is filled in and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1641 returned, otherwise a new event object will be created.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1642
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1643 The event returned will be a keyboard, mouse press, or mouse release
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1644 event. If there are non-command events available (mouse motion,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1645 sub-process output, etc) then these will be executed (with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1646 @code{dispatch-event}) and discarded. This function is provided as a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1647 convenience; it is equivalent to the Lisp code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1648
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1649 @lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1650 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1651 (while (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1652 (next-event event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1653 (not (or (key-press-event-p event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1654 (button-press-event-p event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1655 (button-release-event-p event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1656 (menu-event-p event))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1657 (dispatch-event event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1658 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1659 @end lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1660
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1661 Here is what happens if you call @code{next-command-event} and then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1662 press the right-arrow function key:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1663
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1664 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1665 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1666 (next-command-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1667 @result{} #<keypress-event right>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1668 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1669 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1670 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1671
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1672 @defun read-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1673 This function reads and returns a character of command input. If a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1674 mouse click is detected, an error is signalled. The character typed is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1675 returned as an @sc{ASCII} value. This function is retained for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1676 compatibility with Emacs 18, and is most likely the wrong thing for you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1677 to be using: consider using @code{next-command-event} instead.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1678 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1679
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1680 @defun enqueue-eval-event function object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1681 This function adds an eval event to the back of the queue. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1682 eval event will be the next event read after all pending events.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1683 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1684
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1685 @node Dispatching an Event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1686 @subsection Dispatching an Event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1687 @cindex dispatching an event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1688
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1689 @defun dispatch-event event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1690 Given an event object returned by @code{next-event}, this function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1691 executes it. This is the basic function that makes XEmacs respond to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1692 user input; it also deals with notifications from the window system
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1693 (such as Expose events).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1694 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1695
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1696 @node Quoted Character Input
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1697 @subsection Quoted Character Input
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1698 @cindex quoted character input
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1699
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1700 You can use the function @code{read-quoted-char} to ask the user to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1701 specify a character, and allow the user to specify a control or meta
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1702 character conveniently, either literally or as an octal character code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1703 The command @code{quoted-insert} uses this function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1704
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1705 @defun read-quoted-char &optional prompt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1706 @cindex octal character input
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1707 @cindex control characters, reading
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1708 @cindex nonprinting characters, reading
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1709 This function is like @code{read-char}, except that if the first
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1710 character read is an octal digit (0-7), it reads up to two more octal digits
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1711 (but stopping if a non-octal digit is found) and returns the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1712 character represented by those digits in octal.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1713
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1714 Quitting is suppressed when the first character is read, so that the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1715 user can enter a @kbd{C-g}. @xref{Quitting}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1716
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1717 If @var{prompt} is supplied, it specifies a string for prompting the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1718 user. The prompt string is always displayed in the echo area, followed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1719 by a single @samp{-}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1720
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1721 In the following example, the user types in the octal number 177 (which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1722 is 127 in decimal).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1723
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1724 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1725 (read-quoted-char "What character")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1726
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1727 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1728 ---------- Echo Area ----------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1729 What character-@kbd{177}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1730 ---------- Echo Area ----------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1731
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1732 @result{} 127
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1733 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1734 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1735 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1736
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1737 @need 2000
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1738 @node Peeking and Discarding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1739 @subsection Miscellaneous Event Input Features
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1740
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1741 This section describes how to ``peek ahead'' at events without using
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1742 them up, how to check for pending input, and how to discard pending
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1743 input.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1744
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1745 See also the variables @code{last-command-event} and @code{last-command-char}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1746 (@ref{Command Loop Info}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1747
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1748 @defvar unread-command-events
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1749 @cindex next input
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1750 @cindex peeking at input
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1751 This variable holds a list of events waiting to be read as command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1752 input. The events are used in the order they appear in the list, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1753 removed one by one as they are used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1754
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1755 The variable is needed because in some cases a function reads a event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1756 and then decides not to use it. Storing the event in this variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1757 causes it to be processed normally, by the command loop or by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1758 functions to read command input.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1759
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1760 @cindex prefix argument unreading
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1761 For example, the function that implements numeric prefix arguments reads
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1762 any number of digits. When it finds a non-digit event, it must unread
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1763 the event so that it can be read normally by the command loop.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1764 Likewise, incremental search uses this feature to unread events with no
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1765 special meaning in a search, because these events should exit the search
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1766 and then execute normally.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1767
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1768 @ignore FSF Emacs stuff
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1769 The reliable and easy way to extract events from a key sequence so as to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1770 put them in @code{unread-command-events} is to use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1771 @code{listify-key-sequence} (@pxref{Strings of Events}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1772 @end ignore
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1773 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1774
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1775 @defvar unread-command-event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1776 This variable holds a single event to be read as command input.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1777
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1778 This variable is mostly obsolete now that you can use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1779 @code{unread-command-events} instead; it exists only to support programs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1780 written for versions of XEmacs prior to 19.12.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1781 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1782
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1783 @defun input-pending-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1784 @cindex waiting for command key input
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1785 This function determines whether any command input is currently
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1786 available to be read. It returns immediately, with value @code{t} if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1787 there is available input, @code{nil} otherwise. On rare occasions it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1788 may return @code{t} when no input is available.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1789 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1790
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1791 @defvar last-input-event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1792 This variable is set to the last keyboard or mouse button event received.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1793
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1794 This variable is off limits: you may not set its value or modify the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1795 event that is its value, as it is destructively modified by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1796 @code{read-key-sequence}. If you want to keep a pointer to this value,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1797 you must use @code{copy-event}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1798
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1799 Note that this variable is an alias for @code{last-input-char} in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1800 FSF Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1801
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1802 In the example below, a character is read (the character @kbd{1}). It
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1803 becomes the value of @code{last-input-event}, while @kbd{C-e} (from the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1804 @kbd{C-x C-e} command used to evaluate this expression) remains the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1805 value of @code{last-command-event}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1806
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1807 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1808 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1809 (progn (print (next-command-event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1810 (print last-command-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1811 last-input-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1812 @print{} #<keypress-event 1>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1813 @print{} #<keypress-event control-E>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1814 @result{} #<keypress-event 1>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1815
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1816 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1817 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1818 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1819
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1820 @defvar last-input-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1821 If the value of @code{last-input-event} is a keyboard event, then this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1822 is the nearest @sc{ASCII} equivalent to it. Remember that there is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1823 @emph{not} a 1:1 mapping between keyboard events and @sc{ASCII}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1824 characters: the set of keyboard events is much larger, so writing code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1825 that examines this variable to determine what key has been typed is bad
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1826 practice, unless you are certain that it will be one of a small set of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1827 characters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1828
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1829 This function exists for compatibility with Emacs version 18.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1830 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1831
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1832 @defun discard-input
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1833 @cindex flush input
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1834 @cindex discard input
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1835 @cindex terminate keyboard macro
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1836 This function discards the contents of the terminal input buffer and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1837 cancels any keyboard macro that might be in the process of definition.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1838 It returns @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1839
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1840 In the following example, the user may type a number of characters right
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1841 after starting the evaluation of the form. After the @code{sleep-for}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1842 finishes sleeping, @code{discard-input} discards any characters typed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1843 during the sleep.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1844
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1845 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1846 (progn (sleep-for 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1847 (discard-input))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1848 @result{} nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1849 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1850 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1851
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1852 @node Waiting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1853 @section Waiting for Elapsed Time or Input
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1854 @cindex pausing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1855 @cindex waiting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1856
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1857 The wait functions are designed to wait for a certain amount of time
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1858 to pass or until there is input. For example, you may wish to pause in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1859 the middle of a computation to allow the user time to view the display.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1860 @code{sit-for} pauses and updates the screen, and returns immediately if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1861 input comes in, while @code{sleep-for} pauses without updating the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1862 screen.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1863
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1864 Note that in FSF Emacs, the commands @code{sit-for} and @code{sleep-for}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1865 take two arguments to specify the time (one integer and one float
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1866 value), instead of a single argument that can be either an integer or a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1867 float.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1868
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1869 @defun sit-for seconds &optional nodisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1870 This function performs redisplay (provided there is no pending input
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1871 from the user), then waits @var{seconds} seconds, or until input is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1872 available. The result is @code{t} if @code{sit-for} waited the full
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1873 time with no input arriving (see @code{input-pending-p} in @ref{Peeking
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1874 and Discarding}). Otherwise, the value is @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1875
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1876 The argument @var{seconds} need not be an integer. If it is a floating
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1877 point number, @code{sit-for} waits for a fractional number of seconds.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1878 @ignore FSF Emacs stuff
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1879 Some systems support only a whole number of seconds; on these systems,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1880 @var{seconds} is rounded down.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1881
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1882 The optional argument @var{millisec} specifies an additional waiting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1883 period measured in milliseconds. This adds to the period specified by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1884 @var{seconds}. If the system doesn't support waiting fractions of a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1885 second, you get an error if you specify nonzero @var{millisec}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1886 @end ignore
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1887
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1888 @cindex forcing redisplay
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1889 Redisplay is normally preempted if input arrives, and does not happen at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1890 all if input is available before it starts. (You can force screen
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1891 updating in such a case by using @code{force-redisplay}. @xref{Refresh
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1892 Screen}.) If there is no input pending, you can force an update with no
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1893 delay by using @code{(sit-for 0)}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1894
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1895 If @var{nodisp} is non-@code{nil}, then @code{sit-for} does not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1896 redisplay, but it still returns as soon as input is available (or when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1897 the timeout elapses).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1898
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1899 @ignore
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1900 Iconifying or deiconifying a frame makes @code{sit-for} return, because
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1901 that generates an event. @xref{Misc Events}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1902 @end ignore
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1903
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1904 The usual purpose of @code{sit-for} is to give the user time to read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1905 text that you display.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1906 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1907
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1908 @defun sleep-for seconds
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1909 This function simply pauses for @var{seconds} seconds without updating
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1910 the display. This function pays no attention to available input. It
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1911 returns @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1912
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1913 The argument @var{seconds} need not be an integer. If it is a floating
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1914 point number, @code{sleep-for} waits for a fractional number of seconds.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1915 @ignore FSF Emacs stuff
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1916 Some systems support only a whole number of seconds; on these systems,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1917 @var{seconds} is rounded down.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1918
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1919 The optional argument @var{millisec} specifies an additional waiting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1920 period measured in milliseconds. This adds to the period specified by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1921 @var{seconds}. If the system doesn't support waiting fractions of a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1922 second, you get an error if you specify nonzero @var{millisec}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1923 @end ignore
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1924
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1925 Use @code{sleep-for} when you wish to guarantee a delay.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1926 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1927
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1928 @xref{Time of Day}, for functions to get the current time.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1929
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1930 @node Quitting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1931 @section Quitting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1932 @cindex @kbd{C-g}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1933 @cindex quitting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1934
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1935 Typing @kbd{C-g} while a Lisp function is running causes XEmacs to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1936 @dfn{quit} whatever it is doing. This means that control returns to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1937 innermost active command loop.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1938
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1939 Typing @kbd{C-g} while the command loop is waiting for keyboard input
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1940 does not cause a quit; it acts as an ordinary input character. In the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1941 simplest case, you cannot tell the difference, because @kbd{C-g}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1942 normally runs the command @code{keyboard-quit}, whose effect is to quit.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1943 However, when @kbd{C-g} follows a prefix key, the result is an undefined
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1944 key. The effect is to cancel the prefix key as well as any prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1945 argument.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1946
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1947 In the minibuffer, @kbd{C-g} has a different definition: it aborts out
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1948 of the minibuffer. This means, in effect, that it exits the minibuffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1949 and then quits. (Simply quitting would return to the command loop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1950 @emph{within} the minibuffer.) The reason why @kbd{C-g} does not quit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1951 directly when the command reader is reading input is so that its meaning
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1952 can be redefined in the minibuffer in this way. @kbd{C-g} following a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1953 prefix key is not redefined in the minibuffer, and it has its normal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1954 effect of canceling the prefix key and prefix argument. This too
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1955 would not be possible if @kbd{C-g} always quit directly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1956
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1957 When @kbd{C-g} does directly quit, it does so by setting the variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1958 @code{quit-flag} to @code{t}. XEmacs checks this variable at appropriate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1959 times and quits if it is not @code{nil}. Setting @code{quit-flag}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1960 non-@code{nil} in any way thus causes a quit.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1961
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1962 At the level of C code, quitting cannot happen just anywhere; only at the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1963 special places that check @code{quit-flag}. The reason for this is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1964 that quitting at other places might leave an inconsistency in XEmacs's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1965 internal state. Because quitting is delayed until a safe place, quitting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1966 cannot make XEmacs crash.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1967
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1968 Certain functions such as @code{read-key-sequence} or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1969 @code{read-quoted-char} prevent quitting entirely even though they wait
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1970 for input. Instead of quitting, @kbd{C-g} serves as the requested
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1971 input. In the case of @code{read-key-sequence}, this serves to bring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1972 about the special behavior of @kbd{C-g} in the command loop. In the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1973 case of @code{read-quoted-char}, this is so that @kbd{C-q} can be used
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1974 to quote a @kbd{C-g}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1975
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1976 You can prevent quitting for a portion of a Lisp function by binding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1977 the variable @code{inhibit-quit} to a non-@code{nil} value. Then,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1978 although @kbd{C-g} still sets @code{quit-flag} to @code{t} as usual, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1979 usual result of this---a quit---is prevented. Eventually,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1980 @code{inhibit-quit} will become @code{nil} again, such as when its
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1981 binding is unwound at the end of a @code{let} form. At that time, if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1982 @code{quit-flag} is still non-@code{nil}, the requested quit happens
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1983 immediately. This behavior is ideal when you wish to make sure that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1984 quitting does not happen within a ``critical section'' of the program.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1985
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1986 @cindex @code{read-quoted-char} quitting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1987 In some functions (such as @code{read-quoted-char}), @kbd{C-g} is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1988 handled in a special way that does not involve quitting. This is done
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1989 by reading the input with @code{inhibit-quit} bound to @code{t}, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1990 setting @code{quit-flag} to @code{nil} before @code{inhibit-quit}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1991 becomes @code{nil} again. This excerpt from the definition of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1992 @code{read-quoted-char} shows how this is done; it also shows that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1993 normal quitting is permitted after the first character of input.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1994
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1995 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1996 (defun read-quoted-char (&optional prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1997 "@dots{}@var{documentation}@dots{}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1998 (let ((count 0) (code 0) char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1999 (while (< count 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2000 (let ((inhibit-quit (zerop count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2001 (help-form nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2002 (and prompt (message "%s-" prompt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2003 (setq char (read-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2004 (if inhibit-quit (setq quit-flag nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2005 @dots{})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2006 (logand 255 code)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2007 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2008
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2009 @defvar quit-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2010 If this variable is non-@code{nil}, then XEmacs quits immediately, unless
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2011 @code{inhibit-quit} is non-@code{nil}. Typing @kbd{C-g} ordinarily sets
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2012 @code{quit-flag} non-@code{nil}, regardless of @code{inhibit-quit}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2013 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2014
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2015 @defvar inhibit-quit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2016 This variable determines whether XEmacs should quit when @code{quit-flag}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2017 is set to a value other than @code{nil}. If @code{inhibit-quit} is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2018 non-@code{nil}, then @code{quit-flag} has no special effect.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2019 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2020
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2021 @deffn Command keyboard-quit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2022 This function signals the @code{quit} condition with @code{(signal 'quit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2023 nil)}. This is the same thing that quitting does. (See @code{signal}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2024 in @ref{Errors}.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2025 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2026
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2027 You can specify a character other than @kbd{C-g} to use for quitting.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2028 See the function @code{set-input-mode} in @ref{Terminal Input}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2029
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2030 @node Prefix Command Arguments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2031 @section Prefix Command Arguments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2032 @cindex prefix argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2033 @cindex raw prefix argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2034 @cindex numeric prefix argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2035
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2036 Most XEmacs commands can use a @dfn{prefix argument}, a number
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2037 specified before the command itself. (Don't confuse prefix arguments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2038 with prefix keys.) The prefix argument is at all times represented by a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2039 value, which may be @code{nil}, meaning there is currently no prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2040 argument. Each command may use the prefix argument or ignore it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2041
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2042 There are two representations of the prefix argument: @dfn{raw} and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2043 @dfn{numeric}. The editor command loop uses the raw representation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2044 internally, and so do the Lisp variables that store the information, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2045 commands can request either representation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2046
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2047 Here are the possible values of a raw prefix argument:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2048
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2049 @itemize @bullet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2050 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2051 @code{nil}, meaning there is no prefix argument. Its numeric value is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2052 1, but numerous commands make a distinction between @code{nil} and the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2053 integer 1.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2054
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2055 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2056 An integer, which stands for itself.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2057
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2058 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2059 A list of one element, which is an integer. This form of prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2060 argument results from one or a succession of @kbd{C-u}'s with no
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2061 digits. The numeric value is the integer in the list, but some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2062 commands make a distinction between such a list and an integer alone.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2063
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2064 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2065 The symbol @code{-}. This indicates that @kbd{M--} or @kbd{C-u -} was
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2066 typed, without following digits. The equivalent numeric value is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2067 @minus{}1, but some commands make a distinction between the integer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2068 @minus{}1 and the symbol @code{-}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2069 @end itemize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2070
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2071 We illustrate these possibilities by calling the following function with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2072 various prefixes:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2073
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2074 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2075 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2076 (defun display-prefix (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2077 "Display the value of the raw prefix arg."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2078 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2079 (message "%s" arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2080 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2081 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2082
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2083 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2084 Here are the results of calling @code{display-prefix} with various
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2085 raw prefix arguments:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2086
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2087 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2088 M-x display-prefix @print{} nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2089
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2090 C-u M-x display-prefix @print{} (4)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2091
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2092 C-u C-u M-x display-prefix @print{} (16)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2093
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2094 C-u 3 M-x display-prefix @print{} 3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2095
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2096 M-3 M-x display-prefix @print{} 3 ; @r{(Same as @code{C-u 3}.)}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2097
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2098 C-3 M-x display-prefix @print{} 3 ; @r{(Same as @code{C-u 3}.)}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2099
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2100 C-u - M-x display-prefix @print{} -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2101
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2102 M-- M-x display-prefix @print{} - ; @r{(Same as @code{C-u -}.)}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2103
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2104 C-- M-x display-prefix @print{} - ; @r{(Same as @code{C-u -}.)}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2105
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2106 C-u - 7 M-x display-prefix @print{} -7
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2107
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2108 M-- 7 M-x display-prefix @print{} -7 ; @r{(Same as @code{C-u -7}.)}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2109
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2110 C-- 7 M-x display-prefix @print{} -7 ; @r{(Same as @code{C-u -7}.)}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2111 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2112
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2113 XEmacs uses two variables to store the prefix argument:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2114 @code{prefix-arg} and @code{current-prefix-arg}. Commands such as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2115 @code{universal-argument} that set up prefix arguments for other
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2116 commands store them in @code{prefix-arg}. In contrast,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2117 @code{current-prefix-arg} conveys the prefix argument to the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2118 command, so setting it has no effect on the prefix arguments for future
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2119 commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2120
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2121 Normally, commands specify which representation to use for the prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2122 argument, either numeric or raw, in the @code{interactive} declaration.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2123 (@xref{Using Interactive}.) Alternatively, functions may look at the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2124 value of the prefix argument directly in the variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2125 @code{current-prefix-arg}, but this is less clean.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2126
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2127 @defun prefix-numeric-value arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2128 This function returns the numeric meaning of a valid raw prefix argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2129 value, @var{arg}. The argument may be a symbol, a number, or a list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2130 If it is @code{nil}, the value 1 is returned; if it is @code{-}, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2131 value @minus{}1 is returned; if it is a number, that number is returned;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2132 if it is a list, the @sc{car} of that list (which should be a number) is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2133 returned.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2134 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2135
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2136 @defvar current-prefix-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2137 This variable holds the raw prefix argument for the @emph{current}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2138 command. Commands may examine it directly, but the usual way to access
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2139 it is with @code{(interactive "P")}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2140 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2141
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2142 @defvar prefix-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2143 The value of this variable is the raw prefix argument for the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2144 @emph{next} editing command. Commands that specify prefix arguments for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2145 the following command work by setting this variable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2146 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2147
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2148 Do not call the functions @code{universal-argument},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2149 @code{digit-argument}, or @code{negative-argument} unless you intend to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2150 let the user enter the prefix argument for the @emph{next} command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2151
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2152 @deffn Command universal-argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2153 This command reads input and specifies a prefix argument for the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2154 following command. Don't call this command yourself unless you know
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2155 what you are doing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2156 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2157
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2158 @deffn Command digit-argument arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2159 This command adds to the prefix argument for the following command. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2160 argument @var{arg} is the raw prefix argument as it was before this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2161 command; it is used to compute the updated prefix argument. Don't call
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2162 this command yourself unless you know what you are doing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2163 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2164
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2165 @deffn Command negative-argument arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2166 This command adds to the numeric argument for the next command. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2167 argument @var{arg} is the raw prefix argument as it was before this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2168 command; its value is negated to form the new prefix argument. Don't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2169 call this command yourself unless you know what you are doing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2170 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2171
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2172 @node Recursive Editing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2173 @section Recursive Editing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2174 @cindex recursive command loop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2175 @cindex recursive editing level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2176 @cindex command loop, recursive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2177
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2178 The XEmacs command loop is entered automatically when XEmacs starts up.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2179 This top-level invocation of the command loop never exits; it keeps
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2180 running as long as XEmacs does. Lisp programs can also invoke the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2181 command loop. Since this makes more than one activation of the command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2182 loop, we call it @dfn{recursive editing}. A recursive editing level has
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2183 the effect of suspending whatever command invoked it and permitting the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2184 user to do arbitrary editing before resuming that command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2185
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2186 The commands available during recursive editing are the same ones
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2187 available in the top-level editing loop and defined in the keymaps.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2188 Only a few special commands exit the recursive editing level; the others
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2189 return to the recursive editing level when they finish. (The special
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2190 commands for exiting are always available, but they do nothing when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2191 recursive editing is not in progress.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2192
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2193 All command loops, including recursive ones, set up all-purpose error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2194 handlers so that an error in a command run from the command loop will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2195 not exit the loop.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2196
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2197 @cindex minibuffer input
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2198 Minibuffer input is a special kind of recursive editing. It has a few
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2199 special wrinkles, such as enabling display of the minibuffer and the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2200 minibuffer window, but fewer than you might suppose. Certain keys
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2201 behave differently in the minibuffer, but that is only because of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2202 minibuffer's local map; if you switch windows, you get the usual XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2203 commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2204
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2205 @cindex @code{throw} example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2206 @kindex exit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2207 @cindex exit recursive editing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2208 @cindex aborting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2209 To invoke a recursive editing level, call the function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2210 @code{recursive-edit}. This function contains the command loop; it also
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2211 contains a call to @code{catch} with tag @code{exit}, which makes it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2212 possible to exit the recursive editing level by throwing to @code{exit}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2213 (@pxref{Catch and Throw}). If you throw a value other than @code{t},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2214 then @code{recursive-edit} returns normally to the function that called
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2215 it. The command @kbd{C-M-c} (@code{exit-recursive-edit}) does this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2216 Throwing a @code{t} value causes @code{recursive-edit} to quit, so that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2217 control returns to the command loop one level up. This is called
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2218 @dfn{aborting}, and is done by @kbd{C-]} (@code{abort-recursive-edit}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2219
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2220 Most applications should not use recursive editing, except as part of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2221 using the minibuffer. Usually it is more convenient for the user if you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2222 change the major mode of the current buffer temporarily to a special
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2223 major mode, which should have a command to go back to the previous mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2224 (The @kbd{e} command in Rmail uses this technique.) Or, if you wish to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2225 give the user different text to edit ``recursively'', create and select
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2226 a new buffer in a special mode. In this mode, define a command to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2227 complete the processing and go back to the previous buffer. (The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2228 @kbd{m} command in Rmail does this.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2229
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2230 Recursive edits are useful in debugging. You can insert a call to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2231 @code{debug} into a function definition as a sort of breakpoint, so that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2232 you can look around when the function gets there. @code{debug} invokes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2233 a recursive edit but also provides the other features of the debugger.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2234
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2235 Recursive editing levels are also used when you type @kbd{C-r} in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2236 @code{query-replace} or use @kbd{C-x q} (@code{kbd-macro-query}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2237
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2238 @defun recursive-edit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2239 @cindex suspend evaluation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2240 This function invokes the editor command loop. It is called
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2241 automatically by the initialization of XEmacs, to let the user begin
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2242 editing. When called from a Lisp program, it enters a recursive editing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2243 level.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2244
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2245 In the following example, the function @code{simple-rec} first
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2246 advances point one word, then enters a recursive edit, printing out a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2247 message in the echo area. The user can then do any editing desired, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2248 then type @kbd{C-M-c} to exit and continue executing @code{simple-rec}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2249
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2250 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2251 (defun simple-rec ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2252 (forward-word 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2253 (message "Recursive edit in progress")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2254 (recursive-edit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2255 (forward-word 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2256 @result{} simple-rec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2257 (simple-rec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2258 @result{} nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2259 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2260 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2261
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2262 @deffn Command exit-recursive-edit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2263 This function exits from the innermost recursive edit (including
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2264 minibuffer input). Its definition is effectively @code{(throw 'exit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2265 nil)}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2266 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2267
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2268 @deffn Command abort-recursive-edit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2269 This function aborts the command that requested the innermost recursive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2270 edit (including minibuffer input), by signaling @code{quit}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2271 after exiting the recursive edit. Its definition is effectively
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2272 @code{(throw 'exit t)}. @xref{Quitting}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2273 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2274
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2275 @deffn Command top-level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2276 This function exits all recursive editing levels; it does not return a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2277 value, as it jumps completely out of any computation directly back to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2278 the main command loop.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2279 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2280
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2281 @defun recursion-depth
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2282 This function returns the current depth of recursive edits. When no
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2283 recursive edit is active, it returns 0.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2284 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2285
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2286 @node Disabling Commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2287 @section Disabling Commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2288 @cindex disabled command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2289
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2290 @dfn{Disabling a command} marks the command as requiring user
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2291 confirmation before it can be executed. Disabling is used for commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2292 which might be confusing to beginning users, to prevent them from using
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2293 the commands by accident.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2294
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2295 @kindex disabled
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2296 The low-level mechanism for disabling a command is to put a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2297 non-@code{nil} @code{disabled} property on the Lisp symbol for the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2298 command. These properties are normally set up by the user's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2299 @file{.emacs} file with Lisp expressions such as this:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2300
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2301 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2302 (put 'upcase-region 'disabled t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2303 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2304
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2305 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2306 For a few commands, these properties are present by default and may be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2307 removed by the @file{.emacs} file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2308
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2309 If the value of the @code{disabled} property is a string, the message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2310 saying the command is disabled includes that string. For example:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2311
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2312 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2313 (put 'delete-region 'disabled
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2314 "Text deleted this way cannot be yanked back!\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2315 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2316
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2317 @xref{Disabling,,, emacs, The XEmacs Reference Manual}, for the details on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2318 what happens when a disabled command is invoked interactively.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2319 Disabling a command has no effect on calling it as a function from Lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2320 programs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2321
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2322 @deffn Command enable-command command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2323 Allow @var{command} to be executed without special confirmation from now
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2324 on, and (if the user confirms) alter the user's @file{.emacs} file so
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2325 that this will apply to future sessions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2326 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2327
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2328 @deffn Command disable-command command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2329 Require special confirmation to execute @var{command} from now on, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2330 (if the user confirms) alter the user's @file{.emacs} file so that this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2331 will apply to future sessions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2332 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2333
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2334 @defvar disabled-command-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2335 This normal hook is run instead of a disabled command, when the user
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2336 invokes the disabled command interactively. The hook functions can use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2337 @code{this-command-keys} to determine what the user typed to run the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2338 command, and thus find the command itself. @xref{Hooks}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2339
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2340 By default, @code{disabled-command-hook} contains a function that asks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2341 the user whether to proceed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2342 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2343
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2344 @node Command History
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2345 @section Command History
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2346 @cindex command history
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2347 @cindex complex command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2348 @cindex history of commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2349
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2350 The command loop keeps a history of the complex commands that have
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2351 been executed, to make it convenient to repeat these commands. A
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2352 @dfn{complex command} is one for which the interactive argument reading
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2353 uses the minibuffer. This includes any @kbd{M-x} command, any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2354 @kbd{M-:} command, and any command whose @code{interactive}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2355 specification reads an argument from the minibuffer. Explicit use of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2356 the minibuffer during the execution of the command itself does not cause
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2357 the command to be considered complex.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2358
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2359 @defvar command-history
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2360 This variable's value is a list of recent complex commands, each
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2361 represented as a form to evaluate. It continues to accumulate all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2362 complex commands for the duration of the editing session, but all but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2363 the first (most recent) thirty elements are deleted when a garbage
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2364 collection takes place (@pxref{Garbage Collection}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2365
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2366 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2367 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2368 command-history
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2369 @result{} ((switch-to-buffer "chistory.texi")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2370 (describe-key "^X^[")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2371 (visit-tags-table "~/emacs/src/")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2372 (find-tag "repeat-complex-command"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2373 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2374 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2375 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2376
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2377 This history list is actually a special case of minibuffer history
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2378 (@pxref{Minibuffer History}), with one special twist: the elements are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2379 expressions rather than strings.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2380
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2381 There are a number of commands devoted to the editing and recall of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2382 previous commands. The commands @code{repeat-complex-command}, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2383 @code{list-command-history} are described in the user manual
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2384 (@pxref{Repetition,,, emacs, The XEmacs Reference Manual}). Within the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2385 minibuffer, the history commands used are the same ones available in any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2386 minibuffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2387
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2388 @node Keyboard Macros
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2389 @section Keyboard Macros
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2390 @cindex keyboard macros
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2391
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2392 A @dfn{keyboard macro} is a canned sequence of input events that can
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2393 be considered a command and made the definition of a key. The Lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2394 representation of a keyboard macro is a string or vector containing the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2395 events. Don't confuse keyboard macros with Lisp macros
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2396 (@pxref{Macros}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2397
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2398 @defun execute-kbd-macro macro &optional count
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2399 This function executes @var{macro} as a sequence of events. If
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2400 @var{macro} is a string or vector, then the events in it are executed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2401 exactly as if they had been input by the user. The sequence is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2402 @emph{not} expected to be a single key sequence; normally a keyboard
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2403 macro definition consists of several key sequences concatenated.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2404
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2405 If @var{macro} is a symbol, then its function definition is used in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2406 place of @var{macro}. If that is another symbol, this process repeats.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2407 Eventually the result should be a string or vector. If the result is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2408 not a symbol, string, or vector, an error is signaled.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2409
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2410 The argument @var{count} is a repeat count; @var{macro} is executed that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2411 many times. If @var{count} is omitted or @code{nil}, @var{macro} is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2412 executed once. If it is 0, @var{macro} is executed over and over until it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2413 encounters an error or a failing search.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2414 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2415
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2416 @defvar executing-macro
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2417 This variable contains the string or vector that defines the keyboard
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2418 macro that is currently executing. It is @code{nil} if no macro is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2419 currently executing. A command can test this variable to behave
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2420 differently when run from an executing macro. Do not set this variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2421 yourself.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2422 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2423
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2424 @defvar defining-kbd-macro
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2425 This variable indicates whether a keyboard macro is being defined. A
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2426 command can test this variable to behave differently while a macro is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2427 being defined. The commands @code{start-kbd-macro} and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2428 @code{end-kbd-macro} set this variable---do not set it yourself.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2429 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2430
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2431 @defvar last-kbd-macro
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2432 This variable is the definition of the most recently defined keyboard
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2433 macro. Its value is a string or vector, or @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2434 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2435
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2436 @c Broke paragraph to prevent overfull hbox. --rjc 15mar92
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2437 The commands are described in the user's manual (@pxref{Keyboard
199
169c0442b401 Import from CVS: tag r20-3b26
cvs
parents: 149
diff changeset
2438 Macros,,, xemacs, The XEmacs Reference Manual}).