[TxMt] Configuring syntax highlighting programmatically
throw-away-2 at macromates.com
Thu Apr 10 15:51:47 UTC 2008
On 7 Apr 2008, at 20:09, Daniel Sadilek wrote:
> [...] is there any way to programmatically configure syntax
> What I want to achieve is that a user can configure pairs of string
> and color. All occurences of the string should be highlighted in the
> given color.
Are your grammar already assigning different scopes to these different
If so, I assume what you want is to augment the current theme with
custom colors that the user sets up in your editor!?!
If you look e.g. in the Diff bundle you will see that among its
preferences it has some to define colors for added and removed text.
I think conceptually it is the same you want to do. So while the
following does break a few “rules” what I would suggest is to have the
color editor placed in a custom bundle which also contains color
preferences for your additional elements.
Then when the editor is launched (from within TextMate) it can use the
TM_BUNDLE_PATH environment variable to get the path for these
preferences, edit them, and issue a ‘tell app "TextMate" to reload
bundles’ AppleScript command to have TextMate re-read modifications
You may want to “touch” the Preferences folder in the bundle, to
ensure TextMate sees the changes (when it (re)loads bundles it favors
the cache if a folder date hasn’t been updated since last read).
More information about the textmate