comparison man/kmacro.texi @ 56748:ae642a03d4da

(Keyboard Macro Ring): Rename section. Emacs treats the head of the macro ring as the `last keyboard macro'. (Keyboard Macro Counter): Minor change. (Save Keyboard Macro): Some clarifications. (Edit Keyboard Macro): Rename section.
author Luc Teirlinck <teirllm@auburn.edu>
date Sun, 22 Aug 2004 02:23:55 +0000
parents 10fec56d4052
children 83b46711cad2
comparison
equal deleted inserted replaced
56747:cbb63f6f6786 56748:ae642a03d4da
1 @c This is part of the Emacs manual. 1 @c This is part of the Emacs manual.
2 @c Copyright (C) 1985,86,87,93,94,95,97,2000,2001,2002,2003 2 @c Copyright (C) 1985,86,87,93,94,95,97,2000,2001,2002,2003,2004
3 @c Free Software Foundation, Inc. 3 @c Free Software Foundation, Inc.
4 @c See file emacs.texi for copying conditions. 4 @c See file emacs.texi for copying conditions.
5 @node Keyboard Macros, Files, Fixit, Top 5 @node Keyboard Macros, Files, Fixit, Top
6 @chapter Keyboard Macros 6 @chapter Keyboard Macros
7 @cindex defining keyboard macros 7 @cindex defining keyboard macros
177 repeats the last defined keyboard macro on each complete line within 177 repeats the last defined keyboard macro on each complete line within
178 the current region. It does this line by line, by moving point to the 178 the current region. It does this line by line, by moving point to the
179 beginning of the line and then executing the macro. 179 beginning of the line and then executing the macro.
180 180
181 @node Keyboard Macro Ring 181 @node Keyboard Macro Ring
182 @section Where previous keyboard macros are saved 182 @section The Keyboard Macro Ring
183 183
184 All defined keyboard macros are recorded in the ``keyboard macro ring'', 184 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, 185 a list of sequences of keys. There is only one keyboard macro ring,
186 shared by all buffers. 186 shared by all buffers.
187 187
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
221 ring head immediately, just type @kbd{C-k}. 221 ring head immediately, just type @kbd{C-k}.
222 222
223 Note that Emacs treats the head of the macro ring as the ``last
224 defined keyboard macro''. For instance, it is the keyboard macro that
225 @kbd{C-x e} will execute.
226
223 @findex kmacro-view-macro-repeat 227 @findex kmacro-view-macro-repeat
224 @kindex C-x C-k C-v 228 @kindex C-x C-k C-v
225 229
226 The commands @kbd{C-x C-k C-v} (@code{kmacro-view-macro-repeat}) 230 The commands @kbd{C-x C-k C-v} (@code{kmacro-view-macro-repeat})
227 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}),
262 Each keyboard macro has an associated counter which is automatically 266 Each keyboard macro has an associated counter which is automatically
263 incremented on every repetition of the keyboard macro. Normally, the 267 incremented on every repetition of the keyboard macro. Normally, the
264 macro counter is initialized to 0 when you start defining the macro, 268 macro counter is initialized to 0 when you start defining the macro,
265 and incremented by 1 after each insertion of the counter value; 269 and incremented by 1 after each insertion of the counter value;
266 that is, if you insert the macro counter twice while defining the 270 that is, if you insert the macro counter twice while defining the
267 macro, it will be incremented by 2 time for each repetition of the 271 macro, the counter will increase by 2 on each repetition of the macro.
268 macro.
269 272
270 @findex kmacro-insert-counter 273 @findex kmacro-insert-counter
271 @kindex C-x C-k C-i 274 @kindex C-x C-k C-i
272 The command @kbd{C-x C-k C-i} (@code{kmacro-insert-counter}) inserts 275 The command @kbd{C-x C-k C-i} (@code{kmacro-insert-counter}) inserts
273 the current value of the keyboard macro counter and increments the 276 the current value of the keyboard macro counter and increments the
360 @cindex saving keyboard macros 363 @cindex saving keyboard macros
361 @findex name-last-kbd-macro 364 @findex name-last-kbd-macro
362 @kindex C-x C-k n 365 @kindex C-x C-k n
363 If you wish to save a keyboard macro for later use, you can give it 366 If you wish to save a keyboard macro for later use, you can give it
364 a name using @kbd{C-x C-k n} (@code{name-last-kbd-macro}). 367 a name using @kbd{C-x C-k n} (@code{name-last-kbd-macro}).
365 This reads a name as an argument using the minibuffer and defines that name 368 This reads a name as an argument using the minibuffer and defines that
366 to execute the macro. The macro name is a Lisp symbol, and defining it in 369 name to execute the last keyboard macro, in its current form. (If you
367 this way makes it a valid command name for calling with @kbd{M-x} or for 370 later add to the definition of this macro, that does not alter the
368 binding a key to with @code{global-set-key} (@pxref{Keymaps}). If you 371 name's definition as a macro.) The macro name is a Lisp symbol, and
369 specify a name that has a prior definition other than another keyboard 372 defining it in this way makes it a valid command name for calling with
370 macro, an error message is shown and nothing is changed. 373 @kbd{M-x} or for binding a key to with @code{global-set-key}
374 (@pxref{Keymaps}). If you specify a name that has a prior definition
375 other than a keyboard macro, an error message is shown and nothing is
376 changed.
371 377
372 @cindex binding keyboard macros 378 @cindex binding keyboard macros
373 @findex kmacro-bind-to-key 379 @findex kmacro-bind-to-key
374 @kindex C-x C-k b 380 @kindex C-x C-k b
375 Rather than giving a keyboard macro a name, you can bind it to a 381 You can also bind the last keyboard macro to a key, using
376 key using @kbd{C-x C-k b} (@code{kmacro-bind-to-key}) followed by the 382 @kbd{C-x C-k b} (@code{kmacro-bind-to-key}) followed by the
377 key sequence you want the keyboard macro to be bound to. You can 383 key sequence you want the keyboard macro to be bound to. You can
378 bind to any key sequence in the global keymap, but since most key 384 bind to any key sequence in the global keymap, but since most key
379 sequences already have other bindings, you should select the key 385 sequences already have other bindings, you should select the key
380 sequence carefully. If you try to bind to a key sequence with an 386 sequence carefully. If you try to bind to a key sequence with an
381 existing binding (in any keymap), you will be asked if you really 387 existing binding (in any keymap), you will be asked if you really
412 later with @code{load-file} (@pxref{Lisp Libraries}). If the file you 418 later with @code{load-file} (@pxref{Lisp Libraries}). If the file you
413 save in is your init file @file{~/.emacs} (@pxref{Init File}) then the 419 save in is your init file @file{~/.emacs} (@pxref{Init File}) then the
414 macro will be defined each time you run Emacs. 420 macro will be defined each time you run Emacs.
415 421
416 If you give @code{insert-kbd-macro} a numeric argument, it makes 422 If you give @code{insert-kbd-macro} a numeric argument, it makes
417 additional Lisp code to record the keys (if any) that you have bound to the 423 additional Lisp code to record the keys (if any) that you have bound
418 keyboard macro, so that the macro will be reassigned the same keys when you 424 to @var{macroname}, so that the macro will be reassigned the same keys
419 load the file. 425 when you load the file.
420 426
421 @node Edit Keyboard Macro 427 @node Edit Keyboard Macro
422 @section Interactively executing and editing a keyboard macro 428 @section Editing a Keyboard Macro
423 429
424 @findex kmacro-edit-macro 430 @findex kmacro-edit-macro
425 @kindex C-x C-k C-e 431 @kindex C-x C-k C-e
426 @kindex C-x C-k RET 432 @kindex C-x C-k RET
427 You can edit the last keyboard macro by typing @kbd{C-x C-k C-e} or 433 You can edit the last keyboard macro by typing @kbd{C-x C-k C-e} or