[TxMt] Command to reflow JavaDoc comment

Allan Odgaard throw-away-1 at macromates.com
Sun Apr 15 20:16:47 UTC 2007


On 13. Apr 2007, at 02:09, Trevor Harmon wrote:

> Inspired by the customization screencast [1], I decided to write a  
> reflow command for us Java users. It's designed for reflowing  
> JavaDoc comments. Based heavily on Allan's original code, it works  
> well except for one problem: The reflowed text is never indented,  
> even though I've set the output to "Insert as Snippet." Anyone know  
> how to fix this?

Looking at the Java grammar, it will scope all whitespace in front of  
the ‘/**’ marker as comment.block.documentation (when the line is  
otherwise empty).

Try press ⌃⌥B in a doc-comment to “Select Scope” to see what  
your command is given as input. If you remove this block you will see  
that the caret is at column zero, and thus, your scripts output will  
be indented to column zero (i.e. no indent).

So either we need to “fix” the Java grammar to not make the  
whitespace in front of ‘/**’ comment.block.documentation [1] or  
your script just needs to grab the indent from the first line and  
apply that to the result, before returning it to TextMate.


[1] The reason this is done is so that setting the background color  
for comment.block will look nicer even for indented comments -- we  
have long wanted to introduce a special scope though for leading/ 
trailing whitespace for block constructs, which themes would use,  
rather than have the scope of the block extend to the whitespace  
(which is sometimes resulting in incorrect behavior)




More information about the textmate mailing list