There have been various times in my programming career that I've wanted an emacs macro with arguments, so that it would do things like concatenate a number in each line. Things like this in C: #define a 0 #define b 1 ... #define l 10 #define m 11 Usually I take that as a sign that I need to write some other program to generate the lines of the C program, but for some tasks that's overkill and I want an automated way…
I don't think it's quite what you're talking about, but I have an Emacs function that runs the current region through Python and replaces it with the stdout from running it. For your example, I write this: vars = list('abcdefghijklm') for v,i in zip(vars, range(len(vars))): print("#define {} {}".format(v, i)) Select it and press Ctrl+Alt+p and have it replaced by: #define a 0 #define b 1 #define c 2 #define d 3 #defi…
M-: (loop for i from ?a
for j below 12
do (insert (format "#define %c %d\n" i j)))