TexShop, BBEdit, Mountain Lion and Applescript

The official TeXShop Support Forum.

TexShop, BBEdit, Mountain Lion and Applescript

Postby dpgoldenberg » Sun Dec 29, 2013 5:11 pm

I have been happily using TexShop and BBEdit together for many years using an Applescript that Jason Davies and Richard Seguin put together in a discussion on the MacOSX-TeX forum. This worked fine until a few days ago when I decided to update my system to Mountain Lion and update TexShop from 2.43 to 3.26.

With help from the notes and applescript library from Michael Sharpe, I was able to fix up the old script so that it *almost* works as I want in TexShop 3.26. The current version is:

set TSLibAlias to alias ((path to home folder as string) & "Library:TeXShop:Scripts:TSLib.scpt")
set TSLib to (load script TSLibAlias)

tell application "BBEdit"
save active document of text window 1
set texFile to file of active document of text window 1
set FILEPATH to POSIX path of texFile as string
end tell
tell TSLib to set {pdir, shortname, displayname} to docName(FILEPATH)

tell application "TeXShop"

tell TSLib to opendoc(FILEPATH)

tell document displayname of application "TeXShop"
end tell
end tell

This works as long as the "use external editor" feature of TexShop is *not* turned on. It will also work with that feature turned on if, the file has not already been opened. But, if the (pdf) file is open in TexShop, the script fails with an error indicating that it can't find the .tex file. It seems as if the file is opened by the script, it is able to find the .tex file, even if the source file isn't actually open in TexShop, but not if the .pdf is not already open.

Interestingly, the script does work with the older TexShop (2.43), irrespective of whether the .pdf is already open. So, I am OK if I use the older TexShop.

Any help with this would be greatly appreciated. Is it possible that something was broken in a more recent TexShop version?

Posts: 1
Joined: Sun Dec 29, 2013 5:04 pm

Re: TexShop, BBEdit, Mountain Lion and Applescript

Postby Herbert Schulz » Sun Dec 29, 2013 6:55 pm


One of the things I dislike about AppleScript is that with each major OS upgrade (e.g., 10.5 -> 10.6) AppleScript changes some way and I, too often, have to get help fixing up the scripts I use. I think your asking on the Mac OS X TeX list, where I first saw the post, will bring you the help you need. sorry I can't addd to the solution.
Good Luck,
Herb Schulz
Herbert Schulz
Posts: 1489
Joined: Thu May 12, 2005 2:31 pm

Return to TeXShop (engl.)

Who is online

Users browsing this forum: RobertKnork, Williejet and 0 guests