At 9:32 AM -0500 11/16/06, Jacob Rus wrote:
Adam Bell wrote:
Allan Odgaard wrote:
You would need to change that to address
your preferred tool instead of Script Editor.
Thanks, but that's an osascript targeted at the Script Editor.
Unfortunately, Script Debugger 4 (an OS X upgrade) is not yet
scriptable, so it's not on, I guess - the osascript will just bomb (A
failing of SD4, clearly, not TextMate,
Kinda ironic, eh?
It is indeed. In the pre-OS X versions it was extremely
scriptable, but hasn't caught up.
but reduces the value of TextMate to me
and it's around $60 Cdn).
Hmm, I hope this doesn't end up preventing you from using TextMate.
I'm sure we can work around things. I made the applescript
bundle, and personally don't find the "compile in script editor"
command very useful, as Script Editor is kinda limited, and I can just
run all my scripts from within TextMate.
What attracted me to TextMate in the first place was its
extensibility, and the fact that BBEdit is getting a bit long in the
tooth. It seemed to me that I could substantially automate several
things I do with it in a much more direct fashion than is possible
with SD4. I've also been interested in Cameron Hayne's development of
ASH (AppleScriptShell); http://www.hayne.net/MacDev/Ash/
and noting that TextMate uses a lot of bash scripts in its
bundles, there might be a marriage there.
But what makes Script Debugger so powerful is the amount of
information about what's going on that it reveals, and it's very handy
palettes. According to the developer, SD4 is a mixed app -
"Script Debugger 4 is a Cocoa application. It does make use of
many Carbon services, but the user interface and text editor are all
based on Cocoa."
But if you're interested in this, I'm positive we could get it working
in Script Debugger using UI scripting. If you can't figure it
out, I'm willing to lend a hand.
Otherwise, the Edit in TextMate input manager is really nice.
Until TM 2.0, editing applescripts using
TextMate isn't really ideal, because AppleScript is too stupid to
understand UTF-8 *.applescript files. So to actually use the
scripts you make with TM, you either have to dump them into Script
Editor (or SD or whatever) and save a compiled script (recommended for
several reasons, including that AppleScript compiles scripts
incredibly slowly, and needs to open all referenced applications to do
so), or else either convert things to macroman before running them, or
just avoid non-ascii characters (like ¬).
¬ is an acceptable character in the Script Editor and
SD4.
For TextMate 2.0, we should be able to pass things like *.scpt files
through a filter on the way into and out of TextMate, which can
convert compiled scripts °Í text. At that point, Script
Editor can be taken completely out of the workflow.
TextMate isn't very scriptable, but I'll
try to write a copy/paste routine to get there.
Hmm, what exactly is your purpose here? I can't really recommend
trying to use AppleScript from within TM, unless it's for scripting
other apps. You are much better off using a TextMate command,
which also puts any language on the system at your fingertips (python,
ruby, perl, bash, etc.).[^1]
My purpose isn't very clear to me either. TextMate seems very
powerful and flexible and I wanted to explore what it could do. I
didn't even know it supported AppleScript until I first ran it; I was
more interested in formatting a series of articles for the web that
contain embedded AppleScripts (I edit the cover of
http://macscripter.net), and was curious whether I could do a better
job of formatting the AS than the tag engine on the site does
(MacScripter and its forum understand [applescript], [/applescript]
tags and format the script with a link that will download it directly
to the user's default script editor).
Ahh, but I'm an amateur - a retired Dean of Engineering so I
don't know any of those except a smattering of bash. I did teach for a
bunch of years in your neighborhood, though - Just down Mass Ave at
MIT - left to come here in Admin.
Anyway, If you want to make a TextMate
command which runs an applescript, that is quite possible too.
I'm going to make a screencast hopefully soon that shows this in
action.
Look forward to it.
* * *
Anyway, I do hope you'll stick with TextMate. Once you get into
the snippets/commands, and the scopes/scope selectors system, I think
you'll find it's the most ingenious, intuitive, and easily hackable
text editor on the market.
I've got 28 more days to play - hopefully I'll get time to
explore.
If you have suggestions for improvements to the AppleScript bundle,
I'm all ears. I only use AppleScript when I'm forced to (e.g. to
interact with random apps on the system), and though I like to think I
understand the language pretty well from reading all the way through
the docs that Apple has posted online, I'm definitely not a seasoned
expert. TextMate so far hasn't really had too many
AppleScripters using it, as far as I know, and there wasn't any bundle
for it at all for the first year and a half TextMate existed. So
picking up some people who actually know what they're doing can only
be good for the bundle, assuming they're willing to contribute ideas,
and preferably code too.
Haven't studied it, but will.
I tried to take a look at Script Debugger at some point, but I can't
really get into the mental model of the app. But that's true of
AppleScript stuff in general... :) If there are any particular
problems solved by features of Script Debugger which we should try to
solve in TextMate, please speak up.
-Jacob Rus
[^1]: The only downside to TextMate's
lack of scriptability that I can see is that it makes it harder for
other apps to tell TM to do things. But if/when TextMate does become
truly scriptable in this way, I sure hope it's not AppleScript that's
the scripting language used ;).
Thanks for the extended response.
Adam