comparison man/kmacro.texi @ 90054:f2ebccfa87d4

Revision: miles@gnu.org--gnu-2004/emacs--unicode--0--patch-74 Merge from emacs--cvs-trunk--0 Patches applied: * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-709 Update from CVS: src/indent.c (Fvertical_motion): Fix last change. * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-710 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-715 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-716 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-74 Update from CVS
author Miles Bader <miles@gnu.org>
date Wed, 08 Dec 2004 05:02:30 +0000
parents 939c9f3f6cd6
children 36b2efe4eb14 549734260e34
comparison
equal deleted inserted replaced
90053:fff5f1a61d92 90054:f2ebccfa87d4
118 of 4 executes the macro immediately 3 additional times. An argument 118 of 4 executes the macro immediately 3 additional times. An argument
119 of zero to @kbd{C-x e} or @kbd{C-x )} means repeat the macro 119 of zero to @kbd{C-x e} or @kbd{C-x )} means repeat the macro
120 indefinitely (until it gets an error or you type @kbd{C-g} or, on 120 indefinitely (until it gets an error or you type @kbd{C-g} or, on
121 MS-DOS, @kbd{C-@key{BREAK}}). 121 MS-DOS, @kbd{C-@key{BREAK}}).
122 122
123 @kindex C-x C-k C-s
124 @kindex C-x C-k C-k
125 Alternatively, you can use @kbd{C-x C-k C-s} to start a keyboard macro,
126 and @kbd{C-x C-k C-k...} to end and execute it.
127
128 If you wish to repeat an operation at regularly spaced places in the 123 If you wish to repeat an operation at regularly spaced places in the
129 text, define a macro and include as part of the macro the commands to move 124 text, define a macro and include as part of the macro the commands to move
130 to the next place you want to use it. For example, if you want to change 125 to the next place you want to use it. For example, if you want to change
131 each line, you should position point at the start of a line, and define a 126 each line, you should position point at the start of a line, and define a
132 macro to change that line and leave point at the start of the next line. 127 macro to change that line and leave point at the start of the next line.
183 178
184 All defined keyboard macros are recorded in the ``keyboard macro ring'', 179 All defined keyboard macros are recorded in the ``keyboard macro ring'',
185 a list of sequences of keys. There is only one keyboard macro ring, 180 a list of sequences of keys. There is only one keyboard macro ring,
186 shared by all buffers. 181 shared by all buffers.
187 182
188 All commands which operates on the keyboard macro ring use the 183 All commands which operate on the keyboard macro ring use the
189 same @kbd{C-x C-k} prefix. Most of these commands can be executed and 184 same @kbd{C-x C-k} prefix. Most of these commands can be executed and
190 repeated immediately after each other without repeating the @kbd{C-x 185 repeated immediately after each other without repeating the @kbd{C-x
191 C-k} prefix. For example, 186 C-k} prefix. For example,
192 187
193 @example 188 @example
205 The command @kbd{C-x C-k C-k} (@code{kmacro-end-or-call-macro-repeat}) 200 The command @kbd{C-x C-k C-k} (@code{kmacro-end-or-call-macro-repeat})
206 executes the keyboard macro at the head of the macro ring. You can 201 executes the keyboard macro at the head of the macro ring. You can
207 repeat the macro immediately by typing another @kbd{C-k}, or you can 202 repeat the macro immediately by typing another @kbd{C-k}, or you can
208 rotate the macro ring immediately by typing @kbd{C-n} or @kbd{C-p}. 203 rotate the macro ring immediately by typing @kbd{C-n} or @kbd{C-p}.
209 204
205 When a keyboard macro is being defined, @kbd{C-x C-k C-k} behaves like
206 @kbd{C-x )} except that, immediately afterward, you can use most key
207 bindings of this section without the @kbd{C-x C-k} prefix. For
208 instance, another @kbd{C-k} will re-execute the macro.
209
210 @findex kmacro-cycle-ring-next 210 @findex kmacro-cycle-ring-next
211 @kindex C-x C-k C-n 211 @kindex C-x C-k C-n
212 @findex kmacro-cycle-ring-previous 212 @findex kmacro-cycle-ring-previous
213 @kindex C-x C-k C-p 213 @kindex C-x C-k C-p
214 The commands @kbd{C-x C-k C-n} (@code{kmacro-cycle-ring-next}) and 214 The commands @kbd{C-x C-k C-n} (@code{kmacro-cycle-ring-next}) and
215 @kbd{C-x C-k C-p} (@code{kmacro-cycle-ring-previous}) rotates the 215 @kbd{C-x C-k C-p} (@code{kmacro-cycle-ring-previous}) rotate the
216 macro ring, bringing the next or previous keyboard macro to the head 216 macro ring, bringing the next or previous keyboard macro to the head
217 of the macro ring. The definition of the new head macro is displayed 217 of the macro ring. The definition of the new head macro is displayed
218 in the echo area. You can continue to rotate the macro ring 218 in the echo area. You can continue to rotate the macro ring
219 immediately by repeating just @kbd{C-n} and @kbd{C-p} until the 219 immediately by repeating just @kbd{C-n} and @kbd{C-p} until the
220 desired macro is at the head of the ring. To execute the new macro 220 desired macro is at the head of the ring. To execute the new macro
225 @kbd{C-x e} will execute. 225 @kbd{C-x e} will execute.
226 226
227 @findex kmacro-view-macro-repeat 227 @findex kmacro-view-macro-repeat
228 @kindex C-x C-k C-v 228 @kindex C-x C-k C-v
229 229
230 The commands @kbd{C-x C-k C-v} (@code{kmacro-view-macro-repeat}) 230 The command @kbd{C-x C-k C-v} (@code{kmacro-view-macro-repeat})
231 displays the last keyboard macro, or when repeated (with @kbd{C-v}), 231 displays the last keyboard macro, or when repeated (with @kbd{C-v}),
232 it displays the previous macro on the macro ring, just like @kbd{C-x 232 it displays the previous macro on the macro ring, just like @kbd{C-x
233 C-k C-p}, but without actually rotating the macro ring. If you enter 233 C-k C-p}, but without actually rotating the macro ring. If you enter
234 @kbd{C-k} immediately after displaying a macro from the ring, that 234 @kbd{C-k} immediately after displaying a macro from the ring, that
235 macro is executed, but still without altering the macro ring. 235 macro is executed, but still without altering the macro ring.
236 236
237 So while e.g. @kbd{C-x C-k C-p C-p C-k C-k} makes the 3rd previous 237 So while e.g. @kbd{C-x C-k C-p C-p C-p C-k C-k} makes the 3rd previous
238 macro the current macro and executes it twice, @kbd{C-x C-k C-v C-v 238 macro the current macro and executes it twice, @kbd{C-x C-k C-v C-v
239 C-v C-k C-k} will display and execute the 3rd previous macro once and 239 C-v C-k C-k} will display and execute the 3rd previous macro once and
240 then the current macro once. 240 then the current macro once.
241 241
242 @findex kmacro-delete-ring-head 242 @findex kmacro-delete-ring-head
243 @kindex C-x C-k C-d 243 @kindex C-x C-k C-d
244 244
245 The commands @kbd{C-x C-k C-d} (@code{kmacro-delete-ring-head}) 245 The command @kbd{C-x C-k C-d} (@code{kmacro-delete-ring-head})
246 removes and deletes the macro currently at the head of the macro 246 removes and deletes the macro currently at the head of the macro
247 ring. You can use this to delete a macro that didn't work as 247 ring. You can use this to delete a macro that didn't work as
248 expected, or which you don't need anymore. 248 expected, or which you don't need anymore.
249 249
250 @findex kmacro-swap-ring 250 @findex kmacro-swap-ring
251 @kindex C-x C-k C-t 251 @kindex C-x C-k C-t
252 252
253 The commands @kbd{C-x C-k C-t} (@code{kmacro-swap-ring}) 253 The command @kbd{C-x C-k C-t} (@code{kmacro-swap-ring})
254 interchanges the head of the macro ring with the previous element on 254 interchanges the head of the macro ring with the previous element on
255 the macro ring. 255 the macro ring.
256 256
257 @findex kmacro-call-ring-2nd-repeat 257 @findex kmacro-call-ring-2nd-repeat
258 @kindex C-x C-k C-l 258 @kindex C-x C-k C-l
259 259
260 The commands @kbd{C-x C-k C-l} (@code{kmacro-call-ring-2nd-repeat}) 260 The command @kbd{C-x C-k C-l} (@code{kmacro-call-ring-2nd-repeat})
261 executes the previous (rather than the head) element on the macro ring. 261 executes the previous (rather than the head) element on the macro ring.
262
263 @vindex kmacro-ring-max
264 The maximum number of macros stored in the keyboard macro ring is
265 determined by the customizable variable @code{kmacro-ring-max}.
262 266
263 @node Keyboard Macro Counter 267 @node Keyboard Macro Counter
264 @section The Keyboard Macro Counter 268 @section The Keyboard Macro Counter
265 269
266 Each keyboard macro has an associated counter which is automatically 270 Each keyboard macro has an associated counter. Normally, the
267 incremented on every repetition of the keyboard macro. Normally, the
268 macro counter is initialized to 0 when you start defining the macro, 271 macro counter is initialized to 0 when you start defining the macro,
269 and incremented by 1 after each insertion of the counter value; 272 and incremented by 1 after each insertion of the counter value;
270 that is, if you insert the macro counter twice while defining the 273 that is, if you insert the macro counter twice while defining the
271 macro, the counter will increase by 2 on each repetition of the macro. 274 macro, the counter will increase by 2 on each repetition of the macro.
272 275
273 @findex kmacro-insert-counter 276 @findex kmacro-insert-counter
274 @kindex C-x C-k C-i 277 @kindex C-x C-k C-i
275 The command @kbd{C-x C-k C-i} (@code{kmacro-insert-counter}) inserts 278 The command @kbd{C-x C-k C-i} (@code{kmacro-insert-counter}) inserts
276 the current value of the keyboard macro counter and increments the 279 the current value of the keyboard macro counter and increments the
277 counter by 1. You can use a numeric prefix argument to specify a 280 counter by 1. You can use a numeric prefix argument to specify a
278 different increment. If you specify a @kbd{C-u} prefix, the last 281 different increment. If you just specify a @kbd{C-u} prefix, the last
279 inserted counter value is repeated and the counter is not incremented. 282 inserted counter value is repeated and the counter is not incremented.
280 For example, if you enter the following sequence while defining a macro 283 For example, if you enter the following sequence while defining a macro
281 284
282 @example 285 @example
283 C-x C-k C-i C-x C-k C-i C-u C-x C-k C-i C-x C-k C-i 286 C-x C-k C-i C-x C-k C-i C-u C-x C-k C-i C-x C-k C-i
285 288
286 @noindent 289 @noindent
287 the text @samp{0112} is inserted in the buffer, and for the first and 290 the text @samp{0112} is inserted in the buffer, and for the first and
288 second execution of the macro @samp{3445} and @samp{6778} are 291 second execution of the macro @samp{3445} and @samp{6778} are
289 inserted. 292 inserted.
293
294 This command usually only makes sense while defining a keyboard macro.
295 But its behavior when no keyboard macro is being defined or executed
296 is predictable: it inserts and increments the counter of the head of
297 the keyboard macro ring.
290 298
291 @findex kmacro-set-counter 299 @findex kmacro-set-counter
292 @kindex C-x C-k C-c 300 @kindex C-x C-k C-c
293 The command @kbd{C-x C-k C-c} (@code{kmacro-set-counter}) prompts 301 The command @kbd{C-x C-k C-c} (@code{kmacro-set-counter}) prompts
294 for the initial value of the keyboard macro counter if you use it 302 for the initial value of the keyboard macro counter if you use it
295 before you define a keyboard macro. If you use it while defining a 303 before you define a keyboard macro. If you use it before executing a
296 keyboard macro, you set the macro counter to the same (initial) value 304 keyboard macro, it resets that macro's counter. If you use it while
297 on each repetition of the macro. If you specify a @kbd{C-u} prefix, 305 defining a keyboard macro, then the macro counter gets reset to that same
298 the counter is reset to the value it had prior to the current 306 value on each repetition of the macro. Rather than having the command
299 repetition of the macro (undoing any increments so far in this 307 prompt for a value, you can also specify the value with a numeric
300 repetition). 308 prefix argument. If you just specify a @kbd{C-u} prefix, the counter
309 is reset to the value it had prior to the current repetition of the
310 macro (undoing any increments so far in this repetition). If you just
311 specify a @kbd{C-u} prefix while no macro is being defined or executed,
312 then the new value of the counter is essentially unpredictable.
301 313
302 @findex kmacro-add-counter 314 @findex kmacro-add-counter
303 @kindex C-x C-k C-a 315 @kindex C-x C-k C-a
304 The command @kbd{C-x C-k C-a} (@code{kmacro-add-counter}) prompts 316 The command @kbd{C-x C-k C-a} (@code{kmacro-add-counter}) prompts
305 for a value to add to the macro counter. 317 for a value to add to the macro counter. You can also specify the
318 value with a numeric prefix argument. If you just specify a @kbd{C-u}
319 prefix, the counter is reset to the last value inserted by any
320 keyboard macro. Usually, this will only make sense if that value was
321 inserted during the current macro definition or repetition.
322
323 This command normally only makes sense while defining a keyboard macro.
324 But its behavior when no keyboard macro is being defined or executed
325 is predictable: it affects the counter of the head of the keyboard
326 macro ring.
306 327
307 @findex kmacro-set-format 328 @findex kmacro-set-format
308 @kindex C-x C-k C-f 329 @kindex C-x C-k C-f
309 The command @kbd{C-x C-k C-f} (@code{kmacro-set-format}) prompts 330 The command @kbd{C-x C-k C-f} (@code{kmacro-set-format}) prompts for
310 for the format to use when inserting the macro counter. The default 331 the format to use when inserting the macro counter. The default
311 format is @samp{%d}. If you set the counter format before you define a 332 format is @samp{%d}, which means to insert the number in decimal
312 macro, that format is restored before each repetition of the macro. 333 without any padding. You can exit with empty minibuffer to reset the
313 Consequently, any changes you make to the macro counter format while 334 format to this default. You can specify any format string that the
314 defining a macro are only active for the rest of the macro. 335 @code{format} function accepts and that makes sense with a single
336 integer extra argument (@pxref{Formatting Strings,,, elisp, The Emacs
337 Lisp Reference Manual}). Do not put the format string inside double
338 quotes when you insert it in the minibuffer.
339
340 If you use this command while no keyboard macro is being defined or
341 executed, the new format affects all subsequent macro definitions.
342 Existing macros continue to use the format in effect when they were
343 defined. If you set the format while defining a keyboard macro, this
344 affects the macro being defined from that point on, but it does not
345 affect subsequent macros. Execution of the macro will, at each step,
346 use the format in effect at that step during its definition. Changes
347 to the macro format during execution of a macro, like the
348 corresponding changes during its definition, have no effect on
349 subsequent macros.
350
351 The format set by @kbd{C-x C-k C-f} does not affect insertion of
352 numbers stored in registers.
315 353
316 @node Keyboard Macro Query 354 @node Keyboard Macro Query
317 @section Executing Macros with Variations 355 @section Executing Macros with Variations
318 356
319 @kindex C-x q 357 @kindex C-x q
376 changed. 414 changed.
377 415
378 @cindex binding keyboard macros 416 @cindex binding keyboard macros
379 @findex kmacro-bind-to-key 417 @findex kmacro-bind-to-key
380 @kindex C-x C-k b 418 @kindex C-x C-k b
381 You can also bind the last keyboard macro to a key, using 419 You can also bind the last keyboard macro (in its current form) to a
382 @kbd{C-x C-k b} (@code{kmacro-bind-to-key}) followed by the 420 key, using @kbd{C-x C-k b} (@code{kmacro-bind-to-key}) followed by the
383 key sequence you want the keyboard macro to be bound to. You can 421 key sequence you want to bind. You can bind to any key sequence in
384 bind to any key sequence in the global keymap, but since most key 422 the global keymap, but since most key sequences already have other
385 sequences already have other bindings, you should select the key 423 bindings, you should select the key sequence carefully. If you try to
386 sequence carefully. If you try to bind to a key sequence with an 424 bind to a key sequence with an existing binding (in any keymap), this
387 existing binding (in any keymap), you will be asked if you really 425 command asks you for confirmation before replacing the existing binding.
388 want to replace the existing binding of that key.
389 426
390 To avoid problems caused by overriding existing bindings, the key 427 To avoid problems caused by overriding existing bindings, the key
391 sequences @kbd{C-x C-k 0} through @kbd{C-x C-k 9} and @kbd{C-x C-k A} 428 sequences @kbd{C-x C-k 0} through @kbd{C-x C-k 9} and @kbd{C-x C-k A}
392 through @kbd{C-x C-k Z} are reserved for your own keyboard macro 429 through @kbd{C-x C-k Z} are reserved for your own keyboard macro
393 bindings. In fact, to bind to one of these key sequences, you only 430 bindings. In fact, to bind to one of these key sequences, you only