As for how to go about this, I attached a bundle with a macro and a script, the macro does:
- replace all in selection, adding 0xFFFC as the first/last
character (this is the unicode object replacement character, so I’d be surprised if your script already have such characters) 2) select all 3) call transform.rb with input set to document and output to insert as snippet
The transform.rb script then reads stdin, does a split on 0xFFFC (resulting in an array with the before/selection/after), snippet- escapes each of the 3 parts, and then inserts a snippet which puts
and <<< around the selection, but leaves those added characters
unselected, when replacing the document.
Nice!! +2 for Allan :D
On Apr 15, 2006, at 7:06 PM, Benjamin Jackson wrote:
As for how to go about this, I attached a bundle with a macro and a script, the macro does:
- replace all in selection, adding 0xFFFC as the first/last
character (this is the unicode object replacement character, so I’d be surprised if your script already have such characters) 2) select all 3) call transform.rb with input set to document and output to insert as snippet
The transform.rb script then reads stdin, does a split on 0xFFFC (resulting in an array with the before/selection/after), snippet- escapes each of the 3 parts, and then inserts a snippet which puts
and <<< around the selection, but leaves those added characters
unselected, when replacing the document.
Nice!! +2 for Allan :D
One thing I noticed... in the bundle you attached, the code is in a file named transform.1.rb, and transform.rb is blank.
Also, I updated the post with Allan's solution:
http://www.unfitforprint.com/articles/2006/04/15/pimping-my-editor- refactoring-take-1