John Gruber wrote a Select Word script for BBEdit. Here's a Mac::Glue version.
use Mac::Glue ':glue';
$b = new Mac::Glue 'BBEdit';
$w = $b->obj(window => 1);
$o = $w->prop(offset => of => 'selection')->get;
$w->obj(word => gLast, words => whose(offset => l_e => $o))->select;
This script is pretty straightforward, apart from the odd "property => of => property" syntax. It's my most hated thing about the Mac::Glue syntax. In obj(), you normally have key/value pairs for class/value. With prop(), it's the same, except that there is a property first (prop(foo) it is just a shortcut for obj(property => foo)).
However, when you are taking a property of a property, you can't just do prop(foo => bar), because then Mac::Glue thinks foo is a class and bar is its value.
Suggestions on how to fix this syntax, as always, are welcome.
Anyway, another little oddity -- not a big problem, but something to get used to -- is that where the AppleScript version says "last word whose
Updating the above script to John's final version is an exercise left to the reader.
Stupid Mac OS X Tricks: Select Word 0 Comments More | Login | Reply /