c++ - How to create an emacs macro for text templates -


i new lisp , having trouble figuring out how create macro in emacs following functionality: tired of writing out pattern in c++ for loop:

for (int = 0; < n; i++) {  } 

call macro "forloop" following: when type "m-x forloop" macro prints out

for (int  

in buffer , waits input. type "i" , hit return after macro continues , prints

for (int = 0; <  

and again waits input. after type "n" , hit return macro finishes printing rest:

for (int = 0; < n; i++) {  } 

after extensive reading , testing, able write simple lisp functions, create own macros, save them , call them , on... still can't quite figure out how make macro have described above. thoughts appreciated! in advance!

macros nice speeding coding in language. prefer macro dynamic in way described don't have remember how many arguments needs , in order go when calling it.

i use yasnippet (http://www.emacswiki.org/emacs/yasnippet) this, there lot of other solution.

in yasnippet type keyword snippet (say for) yasnippet key shortcut, have field fill, using tab go 1 field next.

every snippet define in own file in easy learn dsl.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -