News for hackers. Stuff that matters.
Re:Learn Emacs: Keyboard Macros by jlarocco on Thursday November 10, 2011 @12:46PM (#3220961)
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
    #define e 4
    #define f 5
    #define g 6
    #define h 7
    #define i 8
    #define j 9
    #define k 10
    #define l 11
    #define m 12
https://gist.github.com/1355548
Re:Learn Emacs: Keyboard Macros by yuan on Thursday November 10, 2011 @01:59PM (#3221302)
Or just learn a little bit of Elisp, and do this:

    M-: (loop for i from ?a 
              for j below 12 
              do (insert (format "#define %c %d\n" i j)))
Re:Learn Emacs: Keyboard Macros by jlarocco on Thursday November 10, 2011 @02:35PM (#3221472)
Yeah, I considered that, but the situation comes up so infrequently I'd never remember the syntax. I use Python everyday anyway, so it almost comes naturally.