[TxMt] Re: Which 'semantic class' to use for opening tm_proj?

Allan Odgaard mailinglist at textmate.org
Thu Dec 15 21:46:37 UTC 2011


On 15 Dec 2011, at 22:28, Brandon M Fryslie wrote:

> This seems like an event thing.  However, in the Avian bundle, all the
> similar commands define themselves as a callback in the semantic class
> field, rather than specifying an event.

If by event you refer to the ‘event specifier’ then this is a legacy thing that I wanted to have removed before the public alpha.

> I'm not understanding the reasoning behind this, since it seems to blur the distinction between 'events' and 'classes'.  Is there any way to determine whether we should be targeting an event or adding a class of 'callback'?

Semantic class is free-form but as a convention when TM itself wants to learn if a command should be interposed in the process it is prefixed with ‘callback’ — no other reason for this than “consistency” (e.g. I can search my sources for ‘callback.’ to find all the places I call upon potential user commands).

> Which semantic class (or other options) do I need to use to target only
> opening tm_proj files by extension?

Most appropriate would be ‘callback.document.binary-import’ — commands with that (semantic) class are called prior to TM doing anything with the file attempted opened.

Furthermore you want to use attr.rev-path.tmproj as the scope selector so that your command is only invoked for *.tmproj files.

This takes care of having your command called and it will get the file content as stdin (or it should be able to reference TM_FILEPATH).

This however being an import filter, TM expects your command to provide the file’s content on stdout, so this isn’t designed to do exactly what you want.

I don’t know if you can take it all the way with the info above, but I figured this info would be useful regardless of this specific situation and it might not require many tweaks to support your desired behavior (e.g. TM could be made to act on an “exit_discard” from your command, and trust your command did the proper thing).



More information about the textmate mailing list