Less known facts about SubEthaEdit Modes
Posted by dom on Fri Jul 08 13:55:51 +0200 2005As 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 ### 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.
Will look like this:
And how it’s done in the RegexSymbols.xml:
<regex>//- mark[\t ]*(?:-(?=[\n\r]))?([^\n\r]*)</regex>
</symbol>
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.


