I’m working on a project in emacs where I’d like to use a keyboard macro that changes slightly with each iteration. When I saw the keyboard macro counter in the manual, that looked like exactly what I needed – but as far as I can tell, that inserts an incrementing number into the current buffer. I want to use an incrementing number as a prefix to another command.
For example, instead of inserting 3 into the buffer on the third execution of the macro, I’d like to be able to execute C-u 3 M-x my-command, followed by C-u 4 M-x my-command on the next iteration.
Is there way to create a keyboard macro that does this? My specific task is “zipping” two blocks of text in the same buffer together, but even if there’s an alternative way to do that specific thing, it’d be good to know the answer to the general question.
In response to @phils’ comment:
An example of what I’m trying to do would be to turn
<<<<< mine
foo
bar
wimble
gleet
=====
gimble
gyre
wade
foobarbaz
>>>>> r345
into
<<<<< mine
foo
gimble
bar
gyre
wimble
wade
gleet
foobarbaz
=====
>>>>> r345
But again, I’m more interested in “is there a facility for this?” than “how do I solve this specific problem”?
So experimentally (albeit briefly; YMMV), it appears that setting
prefix-argis effective. So you can have a macro like this (which inserts an increasing number of the letterqon each line).