This page describes two programs for MacOS X that I have written:
Both programs are released under the open source BSD license. See the Bare Bones website for more on the basic ODB Editor Suite of Apple Events. I've tested these programs with both BBEdit and TextMate as editors.
usage: odbedit [-h] [-e editor] [-s saveScript] [-c closeScript] filename [filename ...]
odbedit is a command line app that takes a list of filenames and passes them to an ODB aware editor. As it is a command line app, it requires some modifications to the standard ODB event suite. I've let Bare Bones know about my extension and they're considering if this is something they want. At the moment however no editors support the extended suite, and so until they do you can use ODBForwarder to allow current ODB aware editors to use the new interface. ODBForwarder is the default editor for odbedit. You can set which actual editor is used in the preferences for ODBForwarder.
At the moment this program is a little rough around the edges - I'm releasing early, and we'll see if I have time to release often :).
This section is somewhat technical.
In order for the ODB aware editor to let the calling app know when the file has changed, it needs to have the 'address' of the calling app. In the standard ODB suite, this is achived by the calling app putting a four letter signature in a keyFileSender paramter (FSnd) in the Open Document Apple Event. This style of addressing is a holdover from classic MacOS and while it will work for bundles in MacOS X, it doesn't work for command line applications.
I have extended the ODB suite by adding a new parameter, keyFileSenderDesc (FSfd). Instead of taking a four byte code for the sending app, this takes an Apple Event Address Descriptor. This means that I can tell the ODB editor to send the notifications to a specific process by PID, or by BundleID, or by any future addressing scheme Apple comes up with. I've sent email to Bare Bones describing the system. I'm hoping something like it will be in a new ODB interface soon.
Because no editors actually support the new parameter yet :), I've written a forwarding application. This application understands both addressing styles and is able to route the messages correctly. It allows you to use odbedit with current editors.
ODBForwarder.app is a background application that forwards ODB Apple Events between programs using new and old style ODB Suite addressing (as explained above). At the moment it is fairly simple. There is no user-interface.
In normal use, the ODBForwarder application is started automatically by the client program (e.g. odbedit). It then sits in the background forwarding events in either direction.
The default editor for ODBForwarder is BBEdit. The first time ODBForwarder is run, it will set up a preferences file (~/Library/Preferences/org.dyndns.wuther.ODBforwarder.plist). The easiest way to set the editor to use is to use Apple's 'defaults' mechanism (once this preferences file has been created). You'll need to know the bundle ID of the editor you wish to use (TextMate has a bundle ID of com.macromates.textmate). You can then use the command defaults read org.dyndns.wuther.ODBForwarder ODBEditor to read the current ID being used, and defaults write org.dyndns.wuther.ODBForwarder ODBEditor app.bundle.id to write a different bundle ID. (Another option is to specify the new editor's bundle ID in the preferences file using a .plist editor.)
Once you change the preference, you'll need to restart ODBForwarder. The easiest way to do this is to kill the old process, and then let odbedit start a new one for you. You can kill the old process by finding it with ps auwx | grep ODBForwarder, and then kill pid where pid is the number listed in the first column of the ps output. Yeah - this could really do with a UI.
Hopefully noone but me will ever need to debug ODBForwarder. However, in case it isn't working for you and you want to find out why, ODBForwarder sends all its error messages to the console. If you open Console.app (in the Utilities folder inside the Applications folder) then you can see a message when ODBForwarder starts up, and a message if there are any errors while forwarding AppleEvents.