[SVN] Programmatically add snippets?
Allan Odgaard
throw-away-1 at macromates.com
Thu Jun 15 14:31:20 UTC 2006
On 15/6/2006, at 14:49, Stephen Skubik-Peplaski wrote:
> Is there a way to add snippets programmatically? [...]
The easiest is to generate the snippet files in the bundle’s Snippets
folder and then ask TM to reload bundles (be sure to ‘touch’ the
Snippets folder itself, or ask TM to flush cache when reloading by
holding down option while selecting to reload.)
The snippet file itself is a property list file and can thus be
binary, XML, or the old-style ASCII format.
If your (scripting) language of choice has no support for writing
property lists [1], it’s probably easiest to generate the old-style
ASCII output [2], here’s a snippet shown in that format:
{ name = "NSAutoreleasePool";
content = "NSAutoreleasePool* pool = [NSAutoreleasePool new];
\n$0\n[pool release];";
scope = "source.objc, source.objc++";
tabTrigger = "pool";
uuid = "D402B10A-149B-414D-9961-110880389A8E";
}
I think the fields should be self-explanatory. Use uuidgen [2] to get
a unique identifier per snippet.
To speedup initial loading of the snippets, you can use plutil [4] to
convert them to the binary format -- but if you’re using cutting edge
build, TM will cache the snippets after initial load.
[1] TextMate itself ships with a plist extension to ruby that allows
writing out a hash as a property list.
[2] http://developer.apple.com/documentation/Cocoa/Conceptual/
PropertyLists/Concepts/OldStylePListsConcept.html
[3] http://developer.apple.com/documentation/Darwin/Reference/
ManPages/man1/uuidgen.1.html
[4] http://developer.apple.com/documentation/Darwin/Reference/
ManPages/man1/plutil.1.html
More information about the textmate-dev
mailing list