[TxMt] Run command on Event and other stuff

Allan Odgaard allan at macromates.com
Fri Aug 5 08:55:28 UTC 2005


On 04/08/2005, at 8.47, Tim Shadel wrote:

> [...] I want to write a sensor to collect these metrics from  
> TextMate.  The basics would be: 1) log when a new file is opened,  
> 2) log when a file is closed, and 3) every so often (30 seconds)  
> log which file is in the active window.  Pretty simple.

Currently there are no hooks for these things, but it could happen  
through a plugin. Something which is soon to debut -- are you  
familiar with writing Objective-C? if so, I'd suggest subscribing to  
textmate-plugins [1] (and there should soon be the required  
notifications by means of a plugin).

> [...] I've seen several items about launching command-line programs  
> from TM, but can I keep one open in the background?

If your command launches a new process, that process will continue to  
run after control is returned to TextMate.

If you want to provide an interface to control the process then you  
can make use of the ability for JavaScript in the HTML output to  
control shell commands. I added an example command to the  
experimental bundle [2] which opens a window with the time (updated  
each second) that you can start/stop.

> Can I intercept the File | Open actions and then record my metrics?  I
> haven't seen how to do this in other posts.

No, that's currently not possible, but as implied above, I don't mind  
providing the necessary notifications (as NSNotification's that an  
Objective-C plugin can observe).



[1] http://lists.macromates.com/mailman/listinfo/textmate-plugins
[2] http://anon:anon@macromates.com/svn/Bundles/trunk/Bundles/ 
Experimental.tmbundle/




More information about the textmate mailing list