Practically Macro: Writing editor scripts

Editor scripts are written in beanshell.
The context variables passed in are: Return Boolean.TRUE to indicate that the script finished normally, or Boolean.FALSE to indicate abnormal termination and that further macro commands should not be executed. If you return nothing, that is considered "TRUE".
Here's an example script that removes the XML comments from a block including the cursor.
//Scripts are beanshell format (see http://www.beanshell.org/) 
//variable               type
//styledText             the org.eclipse.swt.custom.StyledText instance for the current editor
//console                write output to the macro console via console.write(String), .writeln(String), .write(Exception)
//findTarget             the instance of org.eclipse.jface.text.IFindReplaceTarget
import org.eclipse.swt.custom.StyledText;
import org.eclipse.jface.text.IFindReplaceTarget;

int caretOffset=styledText.getCaretOffset();
int startComment=findTarget.findAndSelect(caretOffset, "<!--", false, true, false);
int endComment=findTarget.findAndSelect(caretOffset, "-->", true, true, false);
int possibleStartComment=findTarget.findAndSelect(caretOffset, "<!--", true, true, false);
int possibleEndComment=findTarget.findAndSelect(caretOffset, "-->", false, true, false);
if (startComment>=0 && endComment>=0 && (possibleEndComment<0 || startComment>=possibleEndComment) && (possibleStartComment<0 || endComment<possibleStartComment))
{
     styledText.replaceTextRange(endComment, 3, "");
     styledText.replaceTextRange(startComment, 4, "");
     styledText.setSelection(caretOffset-4, caretOffset-4);
}
else
{
     //regardless, set position back to original
    styledText.setSelection(caretOffset, caretOffset);
}