BBEdit Text Factories
Posted January 5th, 2005 @ 12:51pm by Erik J. Barzeski
I've finally gotten the chance to use a Text Factory in BBEdit, and I must say I'm rather disappointed. Unless I've missed something, I cannot simply do what I'd like to do: process text (or even the selected text) with a Text Factory.
I'm moving an old site to a new site, and in the process, I'm having to zap gremlins, straighten quotes, change encodings, and do lots of other actions. However, the new site is being handled by a CMS, so BBEdit is serving a transitory role: paste text, run various text filters and whatnots, and then copy for pasting into the CMS.
Can't Text Factories simply be run on the file I'm looking at right there in front of me, preferably via a keystroke?
Posted 05 Jan 2005 at 1:46pm #
so, i'm not the only one having problems with text factory? that makes me feel a little better. although i do remember using ecto (one point somthing) to do most of that when i moved my blog over to WordPress.
although, i did kind of get text factory to go to the current page by taking the bbedit example apple script:
apply text factory (file reference) to (reference)
and give it a keycomand using quicksilver. i just wiped my hd so i can't find the actual apple script at the momet (sorry). so, it is kind of possible...
Posted 05 Jan 2005 at 2:02pm #
TextMate does exactly what you are desiring.
BTW, nice to see someone being a vocal proponent of the 2nd Amendment. 🙂
Posted 05 Jan 2005 at 2:11pm #
TextMate does too many other things bizarrely to consider it for this kind of thing, but thanks for the suggestion.
Posted 05 Jan 2005 at 7:13pm #
Erik: Use the "Set Menu Keys" command to set a keyboard shortcut for "Apply Text Factory" (note lack of ellipsis). Then apply the text factory once using "Apply Text Factory..." in the Text menu. Now you can apply that same text factory again using the key that you set.
Posted 05 Jan 2005 at 7:36pm #
Michael, yes, that works if you hold down the option key. It does not allow you to easily run different TFs, though.
Posted 05 Jan 2005 at 10:36pm #
As it stands now, text factories are a good way to batch commands together for execution against a batch of files, but they're not easily applied against the contents of the current text window. I agree that it'd be nice to be able to do so in some future version of BBEdit.
In the meantime, however, you should be able to get what you want using the 'apply text factory' scripting command. Here's an example:
tell application "BBEdit"
set tf to alias "Mac HD:Users:gruber:Destop:Foo Factory"
apply text factory tf to document 1 of text window 1 without saving
end tell
Where "Foo Factory" is the name of a text factory file saved on my desktop.
The tricky part about invoking them via AppleScript against the current window is that you need to target the document of the text window, not the contents of the text window. I suppose the idea is that factories are run against files, not against text.
What's nice about using a factory instead of a bunch of disparate commands in an AppleScript is that applying a text factory is atomic -- you only need to invoke undo once to undo to the entire factory. Whereas after running a regular AppleScript that does 10 things, you've just added 10 states to your undo stack.