Can I write a Macro to print a function?

Help with writing and playing macros

Can I write a Macro to print a function?

Postby schmpe » Tue Mar 08, 2005 5:45 am

For example: I have an open c-file with a lot of functions and I want to print, but I do not want to print the whole file, only one function ...
normly I mark the function and than print the selection

Can I do this with a macro?
For example, my cursor is on the functionname and I have a macro that print exactly this and only this function?!

If I go on the first bracket from the function, I can mark the function, by searching for the last bracket ... but than I have only the function-budy and not the name above.

Greetings
Petrusha
User avatar
schmpe
Newbie
 
Posts: 2
Joined: Tue Mar 08, 2005 12:00 am

Re: Can I write a Macro to print a function?

Postby Mofi » Tue Mar 08, 2005 6:29 am

Try this little macro to select the whole function, if you are anywhere inside a function. The macro requires, that the function { and } are at start of line and the function definition line does not start with a non alpha-numerical character. But it is not possible to print the selection directly with a macro. You still have to print the selection manually.

InsertMode
ColumnModeOff
HexOff
UnixReOff
Find RegExp "%}"
Find RegExp Up "%{"
Find RegExp Up "%[0-9a-z]"
Find RegExp Select "%}"
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4042
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Can I write a Macro to print a function?

Postby schmpe » Tue Mar 08, 2005 7:01 am

Works fine :D
Starting the print manualy is ok. My biggest problem was the selection of the whole function.
Thank you for the fast answer.
Petrusha
User avatar
schmpe
Newbie
 
Posts: 2
Joined: Tue Mar 08, 2005 12:00 am


Return to Macros

cron