manpagez: man pages & more
info emacs
Home | html | info | man
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

22.3 The Keyboard Macro Counter

C-x C-k C-i

Insert the keyboard macro counter value in the buffer (kmacro-insert-counter).

C-x C-k C-c

Set the keyboard macro counter (kmacro-set-counter).

C-x C-k C-a

Add the prefix arg to the keyboard macro counter (kmacro-add-counter).

C-x C-k C-f

Specify the format for inserting the keyboard macro counter (kmacro-set-format).

Each keyboard macro has an associated counter. Normally, the macro counter is initialized to 0 when you start defining the macro, and incremented by 1 after each insertion of the counter value; that is, if you insert the macro counter twice while defining the macro, the counter will increase by 2 on each repetition of the macro.

The command C-x C-k C-i (kmacro-insert-counter) inserts the current value of the current keyboard macro's counter, and increments the counter by 1. You can use a numeric prefix argument to specify a different increment. If you just specify a C-u prefix, then the increment is zero, so it repeats the last inserted counter value. For example, if you enter the following sequence while defining a macro

 
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

it inserts ‘0112’ in the buffer. The next two iterations of the macro will insert ‘3445’ and ‘6778’.

This command usually only makes sense while defining a keyboard macro. But its behavior when no keyboard macro is being defined or executed is predictable: it inserts and increments the counter of the macro at the head of the keyboard macro ring.

The command C-x C-k C-c (kmacro-set-counter) sets the current macro counter to the value of the numeric argument. If you use it inside the macro, it operates on each repetition of the macro. If you specify just C-u as the prefix, while executing the macro, that resets the counter to the value it had at the beginning of the current repetition of the macro (undoing any increments so far in this repetition).

The command C-x C-k C-a (kmacro-add-counter) adds the prefix argument to the current macro counter. With just C-u as argument, it resets the counter to the last value inserted by any keyboard macro. (Normally, when you use this, the last insertion will be in the same macro and it will be the same counter.)

The command C-x C-k C-f (kmacro-set-format) prompts for the format to use when inserting the macro counter. The default format is ‘%d’, which means to insert the number in decimal without any padding. You can exit with empty minibuffer to reset the format to this default. You can specify any format string that the format function accepts and that makes sense with a single integer extra argument (see (elisp)Formatting Strings section `Formatting Strings' in The Emacs Lisp Reference Manual). Do not put the format string inside double quotes when you insert it in the minibuffer.

If you use this command while no keyboard macro is being defined or executed, the new format affects all subsequent macro definitions. Existing macros continue to use the format in effect when they were defined. If you set the format while defining a keyboard macro, this affects the macro being defined from that point on, but it does not affect subsequent macros. Execution of the macro will, at each step, use the format in effect at that step during its definition. Changes to the macro format during execution of a macro, like the corresponding changes during its definition, have no effect on subsequent macros.

The format set by C-x C-k C-f does not affect insertion of numbers stored in registers.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]
© manpagez.com 2000-2017
Individual documents may contain additional copyright information.