Not sure if this needs to be a command or macro or what but I can't seem to figure this out.
I need the ability to output parameters of functions so if I have the following code (actionscript):
GenericList_prototype.name = function (param1,param2) { statement; }
I want to be able to click anywhere within the function, hit a key (command T) and have the text changed to:
GenericList_prototype.name = function (param1,param2) { trace("GenericList.name > param1 = " + param1 + " > param2 = " + param2); statement; }
This is so I can output parameters to functions. Any ideas? Not even sure where to start.
Ketan Anjaria fire@kidbombay.com www.kidbombay.com
On Mar 9, 2005, at 17:16, Ketan Anjaria wrote:
Not sure if this needs to be a command or macro or what but I can't seem to figure this out.
Making it a command makes it possible to change it later, but since a command needs to work on the selection or entire buffer, you'd have to select e.g. the first line of your function first, or have a macro do that, and run the command.
A macro OTOH requires no real knowledge of programming, although in this case probably does require regular expression knowledge. I did your stuff as a macro, I don't know how much of your function example is variable -- I made it take a variable number of parameters.
The outline of the macro is: 1) search backwards for { 2) select the entire line 3) duplicate the selection (on a new line) 4) make the changes to the copy (using a regex to change the parameter stuff, so that a variable number of parameters are supported)
Step 4 is what you may instead want to do as a command, so that you can make changes and/or use a real language, if doing the necessary steps in recording mode gets to complex.
I attached my macro, I made it ctrl-shift-T since cmd-T is the file chooser! :)
Also, I actually made a step 0 which is “move to end of line”, that way, the macro works even when you're in front of the { on the first line.