6 May
2011
Coda has a bookmarks feature that allows for arbitrary text to show up in the Code Navigator pane. Bookmarks are a convenient way to organize and label sections of code.
Recently, I've been working with Objective-J and wanted to use the bookmarks feature. If you are familiar with XCode and Objective-C, you know that #pragma mark is super helpful.
However Objective-J is not listed and is truly not supported. I decided to fix that.
Bookmarks are supported in the JavaScript syntax, leveraging the two common comment conventions:
/* !bookmark */ or // !bookmark
Since Objective-J is an extension of JavaScript, it should support JavaScript's bookmark convention with no problem. I just needed to find where the bookmark pattern is defined for JavaScript.
I opened the Coda bundle and found the Javascipt.mode bundle. It is located here: /Applications/Coda.app/Contents/Resources/Modes/Javascript.mode. I opened the resources folder of the Javascript.mode bundle in TextMate so that I could browse and search the entire directory. I made sure Coda was not running during this change.
I performed a mult-file search for one of the documented bookmark patterns "// !" and located the definitions in the RegexSymbols.xml file within Javascript.mode.
The code is as follows:
<!-- STUDIO -->
<symbol id="Pragma marks" font-weight="normal" font-style="normal" image="SymbolMark" indentation="0" ignoreblocks="no" show-in-comments="yes">
<regex>/\*\s*!(.+) \*/</regex>
</symbol>
<symbol id="Pragma marks" font-weight="normal" font-style="normal" image="SymbolMark" indentation="0" ignoreblocks="no" show-in-comments="yes">
<regex>// !([^\n\r]+)</regex>
</symbol>
<!-- END -->
Now, all that is needed is to copy the two regexes to the corresponding RegexSymbols.xml file within Objective-J.mode, located here: /Applications/Coda.app/Contents/Resources/Modes/Objective-J.mode/Contents/Resources/RegexSymbols.xml.
When that is done, Coda will now recognize /* !bookmark */ and // !bookmark in the Code Navigator!