Can I use the emacs keyboard macro counter as a command prefix?

Posted by Sean M on Stack Overflow See other posts from Stack Overflow or by Sean M
Published on 2012-04-02T23:25:01Z Indexed on 2012/04/02 23:30 UTC
Read the original article Hit count: 163

Filed under:
|

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.

© Stack Overflow or respective owner

Related posts about emacs

Related posts about elisp