« see and the subversion command line |  main  | Presentation links »

Less known facts about SubEthaEdit Modes

Posted by dom on Fri Jul 08 13:55:51 +0200 2005

As I’m going over the PHP-HTML.mode to add PHP 5 Keywords and compatibility, I’ve seen a feature again, which probably no-one except me is using.

Everyone using Xcode knows about a nice little code organisation feature: pragma marks.

#pragma mark -
#pragma mark ### accessors ###

Putting this nice little lines in your code adds them to the function pop-up. #pragma mark - creates a separator, #pragma mark some text creates an entry in bold with “some text” in it. Very nice.

In SubEthaEdit we support this too. And since we have no special mode recognizers, this can be put in any mode. You just have to add a symbol to the RegexSymbols.xml file in the mode . The problem is, that other than the C pragma mark convention I don’t know any for the other languagues, so we haven’t build in anything in these modes. Except for PHP-HTML. There I have put in a regex that recognise this kind of comment as a symbol that comes up in the function pop-up.

//- mark -
//- mark Cloning
//- mark
Will look like this:
Symbols in the PHP function popup

And how it’s done in the RegexSymbols.xml:

<symbol id="Comment Marks" font-weight="bold" indentation="0" ignoreblocks="yes">
   <regex>//- mark[\t ]*(?:-(?=[\n\r]))?([^\n\r]*)</regex>
</symbol>
This regex looks a bit complicated but actually it just finds the characters that follow a //- mark up to a return. Interestingly enough since I added it to a special kind of comment, it also works after some code in the same line. The seemingly complicated bit in the middle : (?:-(?=[\n\r]))? just consumes any "-" if it is followed by a return.

SubEthaEdit displays the text found for the first group in the function popup. If the found string is empty, it displays a Separator.

This can be done in any mode, and if you know of any conventions in any of the SubEthaEdit modes we ship, please let me know. If you use SubEthaEdit for your PHP then use this kind of comment to orgranise your code. It’s really helpful.

no responses to 'Less known facts about SubEthaEdit Modes'

write a comment.... (textile enabled)
author
email
url
Body