[TxMt Plugins] plugin beginner questions

Ciarán Walsh ciawal at gmail.com
Tue Nov 27 20:37:22 UTC 2007


While what you want to do is likely possible, there is currently no  
API for plug-ins (aside from the facility to load them) so anything  
you want to do must essentially be done through reverse-engineering/ 
hacking TextMate.
I believe at some point TextMate 2.0 will offer a plug-in API, and  
TextMate 2.0 itself will be mostly a complete rewrite, so plug-ins  
written for the current version are unlikely to work.

That said:

The clock plug-in includes some code for observing the currently  
edited document (I believe it’s commented out at the top of Clock.mm,  
the NSWindow subclass and poseAsClass: call below).
At its simplest this would allow you to observe when the current  
document changes to one with an extension you are interested in and  
then run your code.

To hook into file saving I think you’d want to swizzle[1] - 
[OakDocumentController saveDocument:], but an easier method would be  
to change the target of the “Save” menu item to call a method in your  
plug-in class and then call saveDocument: from there, before doing  
your custom operations.

[1]: http://www.cocoadev.com/index.pl?MethodSwizzling

On 27 Nov 2007, at 13:58, Roberto Saccon wrote:

> I am struggling with plugins, and I am at the very first begin, just
> played with the clock demo.
>
> I posted about this on normal textmate list, and now I discovered that
> there is a specific plugin mailing list. I want to do better Erlang /
> textmate integration, see details here:
> http://www.rsaccon.com/2007/11/faster-interaction-between-erlang-and.html
>
> What I want to do is subscribe to events when a textmate starts and
> stops (or even  when a specific language grammar gets activated or
> deactivated if that is possible) and when a document gets saved. And
> in case of such events I want to run my custom code in C for starting
> a Erlang VM in the background, Erlang compiling and other stuff. I am
> not familiar with Objective C, nor with Cocoa, but I am familiar with
> C, so I guess I  an figure out things ..
>
> Is this possible at all ? Somebody can point me in the right
> direction, for me figuring out how to do it ?
>
> Does it make sense at all ? If with upcoming TextMate 2.0 things will
> look completely different, just say "no".
>
> regards
> -- 
> Roberto Saccon
> http://rsaccon.com
> _______________________________________________
> textmate-plugins mailing list
> textmate-plugins at lists.macromates.com
> http://lists.macromates.com/mailman/listinfo/textmate-plugins




More information about the textmate-plugins mailing list