I really, really can’t decide between TextMate and BBEdit, the majority of reasons of which I should leave for another post. But anyway, one of the most annoying things that I thought was left out of BBEdit was the ability to save the contents of the Documents Drawer for easy retrieval. I like to keep my work logically separated by window, and it’s a pain to drag all the documents I need where I want them every time.
Thanks to BBEdit being very Applescript-able, I wrote these scripts. Stick ‘em in your scripts folder and they’ll get some use.
Save Project
tell application "BBEdit"
set w to first text window
set theFiles to the file of every item¬
of text documents of w
set f to choose file name with prompt¬
"Select a project file."
try
set fSpec to open for access f¬
with write permission
on error what
display alert¬
"Could not save project." message what
close access f
return
end try
set eof of fSpec to 0
try
write theFiles to fSpec as list
on error what
close access f
display alert¬
"Could not write project file." message what
return
end try
close access fSpec
end tell
Load Project
tell application "BBEdit"
set f to choose file
open for access f
set fs to read f as list
close access f
set w to make new text window
set show documents drawer of w to true
set doc to ID of first text document of w
set i to 1
open fs opening in w
close document id doc
end tell
It’s not gorgeous code, but it works. And it’s one less thing I have to worry about in BBEdit. Interestingly enough, I would have written these in Ruby with RubyOSA, but the darn thing won’t load BBEdit’s sdef because it uses non ASCII characters.
And for what it’s worth, I like to save the documents with a .bbdd extension.