Previous: Save Kbd Macro, Up: Keyboard Macros [Contents][Index]
You can use C-x q (kbd-macro-query
), to get an effect similar
to that of query-replace
. The macro asks you each time
whether to make a change. When you are defining the macro, type C-x
q at the point where you want the query to occur. During macro
definition, the C-x q does nothing, but when you invoke the macro,
C-x q reads a character from the terminal to decide whether to
continue.
The special answers to a C-x q query are SPC, DEL, C-d, C-l, and C-r. Any other character terminates execution of the keyboard macro and is then read as a command. SPC means to continue. DEL means to skip the remainder of this repetition of the macro, starting again from the beginning in the next repetition. C-d means to skip the remainder of this repetition and cancel further repetition. C-l redraws the frame and asks you again for a character to specify what to do. C-r enters a recursive editing level, in which you can perform editing that is not part of the macro. When you exit the recursive edit using C-M-c, you are asked again how to continue with the keyboard macro. If you type a SPC at this time, the rest of the macro definition is executed. It is up to you to leave point and the text in a state such that the rest of the macro will do what you want.
C-u C-x q, which is C-x q with a numeric argument, performs a different function. It enters a recursive edit reading input from the keyboard, both when you type it during the definition of the macro and when it is executed from the macro. During definition, the editing you do inside the recursive edit does not become part of the macro. During macro execution, the recursive edit gives you a chance to do some particularized editing. See Recursive Edit.
Previous: Save Kbd Macro, Up: Keyboard Macros [Contents][Index]