restructure read_char quit handling
[bpt/emacs.git] / doc / emacs / kmacro.texi
CommitLineData
eef59362 1@c This is part of the Emacs manual.
ba318903 2@c Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2014 Free Software
ab422c4d 3@c Foundation, Inc.
eef59362 4@c See file emacs.texi for copying conditions.
abb9615e 5@node Keyboard Macros
eef59362 6@chapter Keyboard Macros
eef59362
KS
7@cindex defining keyboard macros
8@cindex keyboard macro
9
f8c2e4d5
RS
10 In this chapter we describe how to record a sequence of editing
11commands so you can repeat it conveniently later.
eef59362 12
c9106f67 13 A @dfn{keyboard macro} is a command defined by an Emacs user to stand for
eef59362 14another sequence of keys. For example, if you discover that you are
f8c2e4d5
RS
15about to type @kbd{C-n M-d C-d} forty times, you can speed your work by
16defining a keyboard macro to do @kbd{C-n M-d C-d}, and then executing
17it 39 more times.
18
19 You define a keyboard macro by executing and recording the commands
20which are its definition. Put differently, as you define a keyboard
21macro, the definition is being executed for the first time. This way,
22you can see the effects of your commands, so that you don't have to
23figure them out in your head. When you close the definition, the
24keyboard macro is defined and also has been, in effect, executed once.
25You can then do the whole thing over again by invoking the macro.
eef59362
KS
26
27 Keyboard macros differ from ordinary Emacs commands in that they are
28written in the Emacs command language rather than in Lisp. This makes it
29easier for the novice to write them, and makes them more convenient as
30temporary hacks. However, the Emacs command language is not powerful
31enough as a programming language to be useful for writing anything
32intelligent or general. For such things, Lisp must be used.
33
34@menu
35* Basic Keyboard Macro:: Defining and running keyboard macros.
36* Keyboard Macro Ring:: Where previous keyboard macros are saved.
37* Keyboard Macro Counter:: Inserting incrementing numbers in macros.
2d2f6581
GM
38* Keyboard Macro Query:: Making keyboard macros do different things each
39 time.
40* Save Keyboard Macro:: Giving keyboard macros names; saving them in
41 files.
eef59362 42* Edit Keyboard Macro:: Editing keyboard macros.
ae48b251
LK
43* Keyboard Macro Step-Edit:: Interactively executing and editing a keyboard
44 macro.
eef59362
KS
45@end menu
46
47@node Basic Keyboard Macro
48@section Basic Use
49
50@table @kbd
947ebc5f 51@item @key{F3}
3a85ea69
CY
52Start defining a keyboard macro
53(@code{kmacro-start-macro-or-insert-counter}).
947ebc5f
KS
54@item @key{F4}
55If a keyboard macro is being defined, end the definition; otherwise,
56execute the most recent keyboard macro
57(@code{kmacro-end-or-call-macro}).
3a85ea69
CY
58@item C-u @key{F3}
59Re-execute last keyboard macro, then append keys to its definition.
60@item C-u C-u @key{F3}
61Append keys to the last keyboard macro without re-executing it.
eef59362 62@item C-x C-k r
8871f2ba 63Run the last keyboard macro on each line that begins in the region
eef59362
KS
64(@code{apply-macro-to-region-lines}).
65@end table
66
947ebc5f
KS
67@kindex F3
68@kindex F4
3a85ea69
CY
69@findex kmacro-start-macro-or-insert-counter
70@findex kmacro-end-or-call-macro
eef59362 71@findex kmacro-end-and-call-macro
3a85ea69
CY
72 To start defining a keyboard macro, type @key{F3}. From then on,
73your keys continue to be executed, but also become part of the
74definition of the macro. @samp{Def} appears in the mode line to
75remind you of what is going on. When you are finished, type @key{F4}
76(@code{kmacro-end-or-call-macro}) to terminate the definition. For
77example,
eef59362
KS
78
79@example
3a85ea69 80@key{F3} M-f foo @key{F4}
eef59362
KS
81@end example
82
83@noindent
84defines a macro to move forward a word and then insert @samp{foo}.
3a85ea69
CY
85Note that @key{F3} and @key{F4} do not become part of the macro.
86
87 After defining the macro, you can call it with @key{F4}. For the
88above example, this has the same effect as typing @kbd{M-f foo} again.
89(Note the two roles of the @key{F4} command: it ends the macro if you
90are in the process of defining one, or calls the last macro
91otherwise.) You can also supply @key{F4} with a numeric prefix
92argument @samp{n}, which means to invoke the macro @samp{n} times. An
93argument of zero repeats the macro indefinitely, until it gets an
94error or you type @kbd{C-g} (or, on MS-DOS, @kbd{C-@key{BREAK}}).
95
96 The above example demonstrates a handy trick that you can employ
97with keyboard macros: if you wish to repeat an operation at regularly
98spaced places in the text, include a motion command as part of the
99macro. In this case, repeating the macro inserts the string
100@samp{foo} after each successive word.
101
102 After terminating the definition of a keyboard macro, you can append
103more keystrokes to its definition by typing @kbd{C-u @key{F3}}. This
104is equivalent to plain @key{F3} followed by retyping the whole
105definition so far. As a consequence, it re-executes the macro as
106previously defined. If you change the variable
107@code{kmacro-execute-before-append} to @code{nil}, the existing macro
108will not be re-executed before appending to it (the default is
109@code{t}). You can also add to the end of the definition of the last
110keyboard macro without re-executing it by typing @kbd{C-u C-u
111@key{F3}}.
eef59362
KS
112
113 When a command reads an argument with the minibuffer, your
114minibuffer input becomes part of the macro along with the command. So
3a85ea69
CY
115when you replay the macro, the command gets the same argument as when
116you entered the macro. For example,
eef59362
KS
117
118@example
3a85ea69 119@key{F3} C-a C-k C-x b foo @key{RET} C-y C-x b @key{RET} @key{F4}
eef59362
KS
120@end example
121
122@noindent
3a85ea69 123defines a macro that kills the current line, yanks it into the buffer
eef59362
KS
124@samp{foo}, then returns to the original buffer.
125
3a85ea69
CY
126 Most keyboard commands work as usual in a keyboard macro definition,
127with some exceptions. Typing @kbd{C-g} (@code{keyboard-quit}) quits
128the keyboard macro definition. Typing @kbd{C-M-c}
129(@code{exit-recursive-edit}) can be unreliable: it works as you'd
130expect if exiting a recursive edit that started within the macro, but
131if it exits a recursive edit that started before you invoked the
132keyboard macro, it also necessarily exits the keyboard macro too.
133Mouse events are also unreliable, even though you can use them in a
134keyboard macro: when the macro replays the mouse event, it uses the
135original mouse position of that event, the position that the mouse had
136while you were defining the macro. The effect of this may be hard to
137predict.
eef59362
KS
138
139@findex apply-macro-to-region-lines
140@kindex C-x C-k r
141 The command @kbd{C-x C-k r} (@code{apply-macro-to-region-lines})
8871f2ba
LT
142repeats the last defined keyboard macro on each line that begins in
143the region. It does this line by line, by moving point to the
eef59362
KS
144beginning of the line and then executing the macro.
145
3a85ea69
CY
146@kindex C-x (
147@kindex C-x )
148@kindex C-x e
149@findex kmacro-start-macro
150@findex kmacro-end-macro
151 In addition to the @key{F3} and @key{F4} commands described above,
e7a3ff06 152Emacs also supports an older set of key bindings for defining and
3a85ea69
CY
153executing keyboard macros. To begin a macro definition, type @kbd{C-x
154(} (@code{kmacro-start-macro}); as with @key{F3}, a prefix argument
155appends this definition to the last keyboard macro. To end a macro
156definition, type @kbd{C-x )} (@code{kmacro-end-macro}). To execute
157the most recent macro, type @kbd{C-x e}
158(@code{kmacro-end-and-call-macro}). If you enter @kbd{C-x e} while
159defining a macro, the macro is terminated and executed immediately.
160Immediately after typing @kbd{C-x e}, you can type @key{e} repeatedly
161to immediately repeat the macro one or more times. You can also give
162@kbd{C-x e} a repeat argument, just like @key{F4}.
163
164 @kbd{C-x )} can be given a repeat count as an argument. This means
165to repeat the macro right after defining it. The macro definition
166itself counts as the first repetition, since it is executed as you
167define it, so @kbd{C-u 4 C-x )} executes the macro immediately 3
168additional times.
169
eef59362 170@node Keyboard Macro Ring
2935e788 171@section The Keyboard Macro Ring
eef59362 172
3a85ea69
CY
173 All defined keyboard macros are recorded in the @dfn{keyboard macro
174ring}. There is only one keyboard macro ring, shared by all buffers.
eef59362 175
f8c2e4d5
RS
176@table @kbd
177@item C-x C-k C-k
178Execute the keyboard macro at the head of the ring (@code{kmacro-end-or-call-macro-repeat}).
179@item C-x C-k C-n
180Rotate the keyboard macro ring to the next macro (defined earlier)
181(@code{kmacro-cycle-ring-next}).
182@item C-x C-k C-p
183Rotate the keyboard macro ring to the previous macro (defined later)
184(@code{kmacro-cycle-ring-previous}).
185@end table
186
34768dde 187 All commands which operate on the keyboard macro ring use the
eef59362
KS
188same @kbd{C-x C-k} prefix. Most of these commands can be executed and
189repeated immediately after each other without repeating the @kbd{C-x
190C-k} prefix. For example,
191
192@example
193C-x C-k C-p C-p C-k C-k C-k C-n C-n C-k C-p C-k C-d
194@end example
195
196@noindent
197will rotate the keyboard macro ring to the ``second previous'' macro,
198execute the resulting head macro three times, rotate back to the
199original head macro, execute that once, rotate to the ``previous''
200macro, execute that, and finally delete it from the macro ring.
201
202@findex kmacro-end-or-call-macro-repeat
203@kindex C-x C-k C-k
204 The command @kbd{C-x C-k C-k} (@code{kmacro-end-or-call-macro-repeat})
205executes the keyboard macro at the head of the macro ring. You can
206repeat the macro immediately by typing another @kbd{C-k}, or you can
207rotate the macro ring immediately by typing @kbd{C-n} or @kbd{C-p}.
208
3a85ea69
CY
209 When a keyboard macro is being defined, @kbd{C-x C-k C-k} behaves
210like @key{F4} except that, immediately afterward, you can use most key
34768dde
LT
211bindings of this section without the @kbd{C-x C-k} prefix. For
212instance, another @kbd{C-k} will re-execute the macro.
213
eef59362
KS
214@findex kmacro-cycle-ring-next
215@kindex C-x C-k C-n
216@findex kmacro-cycle-ring-previous
217@kindex C-x C-k C-p
218 The commands @kbd{C-x C-k C-n} (@code{kmacro-cycle-ring-next}) and
34768dde 219@kbd{C-x C-k C-p} (@code{kmacro-cycle-ring-previous}) rotate the
eef59362
KS
220macro ring, bringing the next or previous keyboard macro to the head
221of the macro ring. The definition of the new head macro is displayed
222in the echo area. You can continue to rotate the macro ring
223immediately by repeating just @kbd{C-n} and @kbd{C-p} until the
224desired macro is at the head of the ring. To execute the new macro
977d0bea 225ring head immediately, just type @kbd{C-k}.
eef59362 226
2935e788 227 Note that Emacs treats the head of the macro ring as the ``last
16152b76 228defined keyboard macro''. For instance, @key{F4} will execute that
f8c2e4d5 229macro, and @kbd{C-x C-k n} will give it a name.
2935e788 230
34768dde
LT
231@vindex kmacro-ring-max
232 The maximum number of macros stored in the keyboard macro ring is
233determined by the customizable variable @code{kmacro-ring-max}.
234
eef59362 235@node Keyboard Macro Counter
1dec4064 236@section The Keyboard Macro Counter
eef59362 237
3a85ea69
CY
238 Each keyboard macro has an associated counter, which is initialized
239to 0 when you start defining the macro. This counter allows you to
240insert a number into the buffer that depends on the number of times
241the macro has been called. The counter is incremented each time its
242value is inserted into the buffer.
243
f8c2e4d5 244@table @kbd
3a85ea69
CY
245@item @key{F3}
246In a keyboard macro definition, insert the keyboard macro counter
247value in the buffer (@code{kmacro-start-macro-or-insert-counter}).
f8c2e4d5
RS
248@item C-x C-k C-i
249Insert the keyboard macro counter value in the buffer
250(@code{kmacro-insert-counter}).
251@item C-x C-k C-c
252Set the keyboard macro counter (@code{kmacro-set-counter}).
253@item C-x C-k C-a
254Add the prefix arg to the keyboard macro counter (@code{kmacro-add-counter}).
255@item C-x C-k C-f
256Specify the format for inserting the keyboard macro counter
257(@code{kmacro-set-format}).
258@end table
259
eef59362
KS
260@findex kmacro-insert-counter
261@kindex C-x C-k C-i
3a85ea69
CY
262 When you are defining a keyboard macro, the command @key{F3}
263(@code{kmacro-start-macro-or-insert-counter}) inserts the current
264value of the keyboard macro's counter into the buffer, and increments
265the counter by 1. (If you are not defining a macro, @key{F3} begins a
266macro definition instead. @xref{Basic Keyboard Macro}.) You can use
267a numeric prefix argument to specify a different increment. If you
268just specify a @kbd{C-u} prefix, that is the same as an increment of
269zero: it inserts the current counter value without changing it.
270
271 As an example, let us show how the keyboard macro counter can be
272used to build a numbered list. Consider the following key sequence:
eef59362
KS
273
274@example
3a85ea69 275@key{F3} C-a @key{F3} . @key{SPC} @key{F4}
eef59362
KS
276@end example
277
278@noindent
3a85ea69
CY
279As part of this keyboard macro definition, the string @samp{0. } was
280inserted into the beginning of the current line. If you now move
281somewhere else in the buffer and type @key{F4} to invoke the macro,
282the string @samp{1. } is inserted at the beginning of that line.
283Subsequent invocations insert @samp{2. }, @samp{3. }, and so forth.
284
285 The command @kbd{C-x C-k C-i} (@code{kmacro-insert-counter}) does
286the same thing as @key{F3}, but it can be used outside a keyboard
287macro definition. When no keyboard macro is being defined or
288executed, it inserts and increments the counter of the macro at the
289head of the keyboard macro ring.
34768dde 290
eef59362
KS
291@findex kmacro-set-counter
292@kindex C-x C-k C-c
c9106f67
RS
293 The command @kbd{C-x C-k C-c} (@code{kmacro-set-counter}) sets the
294current macro counter to the value of the numeric argument. If you use
295it inside the macro, it operates on each repetition of the macro. If
296you specify just @kbd{C-u} as the prefix, while executing the macro,
297that resets the counter to the value it had at the beginning of the
298current repetition of the macro (undoing any increments so far in this
299repetition).
eef59362
KS
300
301@findex kmacro-add-counter
302@kindex C-x C-k C-a
c9106f67
RS
303 The command @kbd{C-x C-k C-a} (@code{kmacro-add-counter}) adds the
304prefix argument to the current macro counter. With just @kbd{C-u} as
305argument, it resets the counter to the last value inserted by any
306keyboard macro. (Normally, when you use this, the last insertion
307will be in the same macro and it will be the same counter.)
eef59362
KS
308
309@findex kmacro-set-format
310@kindex C-x C-k C-f
34768dde
LT
311 The command @kbd{C-x C-k C-f} (@code{kmacro-set-format}) prompts for
312the format to use when inserting the macro counter. The default
313format is @samp{%d}, which means to insert the number in decimal
314without any padding. You can exit with empty minibuffer to reset the
315format to this default. You can specify any format string that the
316@code{format} function accepts and that makes sense with a single
317integer extra argument (@pxref{Formatting Strings,,, elisp, The Emacs
318Lisp Reference Manual}). Do not put the format string inside double
319quotes when you insert it in the minibuffer.
320
c9106f67 321 If you use this command while no keyboard macro is being defined or
34768dde
LT
322executed, the new format affects all subsequent macro definitions.
323Existing macros continue to use the format in effect when they were
324defined. If you set the format while defining a keyboard macro, this
325affects the macro being defined from that point on, but it does not
326affect subsequent macros. Execution of the macro will, at each step,
327use the format in effect at that step during its definition. Changes
328to the macro format during execution of a macro, like the
329corresponding changes during its definition, have no effect on
330subsequent macros.
331
c9106f67 332 The format set by @kbd{C-x C-k C-f} does not affect insertion of
34768dde 333numbers stored in registers.
eef59362 334
3a85ea69
CY
335 If you use a register as a counter, incrementing it on each
336repetition of the macro, that accomplishes the same thing as a
a30ed87b
LMI
337keyboard macro counter. @xref{Number Registers}. For most purposes,
338it is simpler to use a keyboard macro counter.
3a85ea69 339
eef59362
KS
340@node Keyboard Macro Query
341@section Executing Macros with Variations
342
3a85ea69
CY
343 In a keyboard macro, you can create an effect similar to that of
344@code{query-replace}, in that the macro asks you each time around
345whether to make a change.
346
f8c2e4d5
RS
347@table @kbd
348@item C-x q
349When this point is reached during macro execution, ask for confirmation
350(@code{kbd-macro-query}).
351@end table
352
eef59362
KS
353@kindex C-x q
354@findex kbd-macro-query
3a85ea69
CY
355 While defining the macro, type @kbd{C-x q} at the point where you
356want the query to occur. During macro definition, the @kbd{C-x q}
357does nothing, but when you run the macro later, @kbd{C-x q} asks you
358interactively whether to continue.
359
360 The valid responses when @kbd{C-x q} asks are:
361
362@table @asis
363@item @key{SPC} (or @kbd{y})
364Continue executing the keyboard macro.
365
366@item @key{DEL} (or @kbd{n})
367Skip the remainder of this repetition of the macro, and start right
368away with the next repetition.
369
370@item @key{RET} (or @kbd{q})
371Skip the remainder of this repetition and cancel further repetitions.
372
373@item @kbd{C-r}
374Enter a recursive editing level, in which you can perform editing
375which is not part of the macro. When you exit the recursive edit
376using @kbd{C-M-c}, you are asked again how to continue with the
eef59362
KS
377keyboard macro. If you type a @key{SPC} at this time, the rest of the
378macro definition is executed. It is up to you to leave point and the
3a85ea69
CY
379text in a state such that the rest of the macro will do what you want.
380@end table
eef59362
KS
381
382 @kbd{C-u C-x q}, which is @kbd{C-x q} with a numeric argument,
383performs a completely different function. It enters a recursive edit
384reading input from the keyboard, both when you type it during the
385definition of the macro, and when it is executed from the macro. During
386definition, the editing you do inside the recursive edit does not become
387part of the macro. During macro execution, the recursive edit gives you
388a chance to do some particularized editing on each repetition.
389@xref{Recursive Edit}.
390
eef59362
KS
391@node Save Keyboard Macro
392@section Naming and Saving Keyboard Macros
393
85aea0a0 394@table @kbd
f8c2e4d5
RS
395@item C-x C-k n
396Give a command name (for the duration of the Emacs session) to the most
397recently defined keyboard macro (@code{kmacro-name-last-macro}).
398@item C-x C-k b
399Bind the most recently defined keyboard macro to a key sequence (for
400the duration of the session) (@code{kmacro-bind-to-key}).
401@item M-x insert-kbd-macro
402Insert in the buffer a keyboard macro's definition, as Lisp code.
403@end table
404
eef59362 405@cindex saving keyboard macros
8e887df4 406@findex kmacro-name-last-macro
eef59362
KS
407@kindex C-x C-k n
408 If you wish to save a keyboard macro for later use, you can give it
8e887df4 409a name using @kbd{C-x C-k n} (@code{kmacro-name-last-macro}).
2935e788
LT
410This reads a name as an argument using the minibuffer and defines that
411name to execute the last keyboard macro, in its current form. (If you
412later add to the definition of this macro, that does not alter the
413name's definition as a macro.) The macro name is a Lisp symbol, and
414defining it in this way makes it a valid command name for calling with
415@kbd{M-x} or for binding a key to with @code{global-set-key}
416(@pxref{Keymaps}). If you specify a name that has a prior definition
417other than a keyboard macro, an error message is shown and nothing is
418changed.
eef59362
KS
419
420@cindex binding keyboard macros
421@findex kmacro-bind-to-key
422@kindex C-x C-k b
34768dde
LT
423 You can also bind the last keyboard macro (in its current form) to a
424key, using @kbd{C-x C-k b} (@code{kmacro-bind-to-key}) followed by the
425key sequence you want to bind. You can bind to any key sequence in
426the global keymap, but since most key sequences already have other
427bindings, you should select the key sequence carefully. If you try to
428bind to a key sequence with an existing binding (in any keymap), this
429command asks you for confirmation before replacing the existing binding.
eef59362 430
f8c2e4d5 431 To avoid problems caused by overriding existing bindings, the key
eef59362
KS
432sequences @kbd{C-x C-k 0} through @kbd{C-x C-k 9} and @kbd{C-x C-k A}
433through @kbd{C-x C-k Z} are reserved for your own keyboard macro
434bindings. In fact, to bind to one of these key sequences, you only
435need to type the digit or letter rather than the whole key sequences.
436For example,
437
438@example
439C-x C-k b 4
440@end example
441
442@noindent
443will bind the last keyboard macro to the key sequence @kbd{C-x C-k 4}.
444
445@findex insert-kbd-macro
446 Once a macro has a command name, you can save its definition in a file.
447Then it can be used in another editing session. First, visit the file
448you want to save the definition in. Then use this command:
449
450@example
451M-x insert-kbd-macro @key{RET} @var{macroname} @key{RET}
452@end example
453
454@noindent
455This inserts some Lisp code that, when executed later, will define the
456same macro with the same definition it has now. (You need not
457understand Lisp code to do this, because @code{insert-kbd-macro} writes
458the Lisp code for you.) Then save the file. You can load the file
459later with @code{load-file} (@pxref{Lisp Libraries}). If the file you
460save in is your init file @file{~/.emacs} (@pxref{Init File}) then the
461macro will be defined each time you run Emacs.
462
463 If you give @code{insert-kbd-macro} a numeric argument, it makes
2935e788
LT
464additional Lisp code to record the keys (if any) that you have bound
465to @var{macroname}, so that the macro will be reassigned the same keys
466when you load the file.
eef59362
KS
467
468@node Edit Keyboard Macro
2935e788 469@section Editing a Keyboard Macro
eef59362 470
f8c2e4d5
RS
471@table @kbd
472@item C-x C-k C-e
473Edit the last defined keyboard macro (@code{kmacro-edit-macro}).
474@item C-x C-k e @var{name} @key{RET}
475Edit a previously defined keyboard macro @var{name} (@code{edit-kbd-macro}).
476@item C-x C-k l
b0b5100a 477Edit the last 300 keystrokes as a keyboard macro
f8c2e4d5
RS
478(@code{kmacro-edit-lossage}).
479@end table
480
eef59362
KS
481@findex kmacro-edit-macro
482@kindex C-x C-k C-e
483@kindex C-x C-k RET
484 You can edit the last keyboard macro by typing @kbd{C-x C-k C-e} or
1fb3aa3f
CY
485@kbd{C-x C-k @key{RET}} (@code{kmacro-edit-macro}). This formats the
486macro definition in a buffer and enters a specialized major mode for
487editing it. Type @kbd{C-h m} once in that buffer to display details
488of how to edit the macro. When you are finished editing, type
489@kbd{C-c C-c}.
eef59362
KS
490
491@findex edit-kbd-macro
492@kindex C-x C-k e
493 You can edit a named keyboard macro or a macro bound to a key by typing
494@kbd{C-x C-k e} (@code{edit-kbd-macro}). Follow that with the
495keyboard input that you would use to invoke the macro---@kbd{C-x e} or
496@kbd{M-x @var{name}} or some other key sequence.
497
498@findex kmacro-edit-lossage
499@kindex C-x C-k l
b0b5100a 500 You can edit the last 300 keystrokes as a macro by typing
eef59362
KS
501@kbd{C-x C-k l} (@code{kmacro-edit-lossage}).
502
503@node Keyboard Macro Step-Edit
1dec4064 504@section Stepwise Editing a Keyboard Macro
eef59362
KS
505
506@findex kmacro-step-edit-macro
507@kindex C-x C-k SPC
bb18ce6a 508 You can interactively replay and edit the last keyboard
d7e9a7f8 509macro, one command at a time, by typing @kbd{C-x C-k @key{SPC}}
eef59362
KS
510(@code{kmacro-step-edit-macro}). Unless you quit the macro using
511@kbd{q} or @kbd{C-g}, the edited macro replaces the last macro on the
512macro ring.
513
bb18ce6a
RS
514 This macro editing feature shows the last macro in the minibuffer
515together with the first (or next) command to be executed, and prompts
516you for an action. You can enter @kbd{?} to get a summary of your
517options. These actions are available:
eef59362
KS
518
519@itemize @bullet{}
520@item
d7e9a7f8 521@key{SPC} and @kbd{y} execute the current command, and advance to the
eef59362
KS
522next command in the keyboard macro.
523@item
d7e9a7f8 524@kbd{n}, @kbd{d}, and @key{DEL} skip and delete the current command.
eef59362
KS
525@item
526@kbd{f} skips the current command in this execution of the keyboard
527macro, but doesn't delete it from the macro.
528@item
d7e9a7f8 529@key{TAB} executes the current command, as well as all similar
ee6c21a7 530commands immediately following the current command; for example, @key{TAB}
eef59362
KS
531may be used to insert a sequence of characters (corresponding to a
532sequence of @code{self-insert-command} commands).
533@item
534@kbd{c} continues execution (without further editing) until the end of
535the keyboard macro. If execution terminates normally, the edited
536macro replaces the original keyboard macro.
537@item
538@kbd{C-k} skips and deletes the rest of the keyboard macro,
539terminates step-editing, and replaces the original keyboard macro
540with the edited macro.
541@item
542@kbd{q} and @kbd{C-g} cancels the step-editing of the keyboard macro;
543discarding any changes made to the keyboard macro.
544@item
d7e9a7f8 545@kbd{i @var{key}@dots{} C-j} reads and executes a series of key sequences (not
eef59362
KS
546including the final @kbd{C-j}), and inserts them before the current
547command in the keyboard macro, without advancing over the current
548command.
549@item
d7e9a7f8 550@kbd{I @var{key}@dots{}} reads one key sequence, executes it, and inserts it
eef59362
KS
551before the current command in the keyboard macro, without advancing
552over the current command.
553@item
d7e9a7f8 554@kbd{r @var{key}@dots{} C-j} reads and executes a series of key sequences (not
eef59362
KS
555including the final @kbd{C-j}), and replaces the current command in
556the keyboard macro with them, advancing over the inserted key
557sequences.
558@item
d7e9a7f8 559@kbd{R @var{key}@dots{}} reads one key sequence, executes it, and replaces the
eef59362
KS
560current command in the keyboard macro with that key sequence,
561advancing over the inserted key sequence.
562@item
d7e9a7f8 563@kbd{a @var{key}@dots{} C-j} executes the current command, then reads and
eef59362
KS
564executes a series of key sequences (not including the final
565@kbd{C-j}), and inserts them after the current command in the keyboard
566macro; it then advances over the current command and the inserted key
567sequences.
568@item
d7e9a7f8 569@kbd{A @var{key}@dots{} C-j} executes the rest of the commands in the keyboard
eef59362
KS
570macro, then reads and executes a series of key sequences (not
571including the final @kbd{C-j}), and appends them at the end of the
572keyboard macro; it then terminates the step-editing and replaces the
573original keyboard macro with the edited macro.
574@end itemize