[OS X TeX] Mountain Lion, BBEdit, TexShop and Applescript

David P. Goldenberg goldenberg at biology.utah.edu
Sun Dec 29 18:32:11 CET 2013

  I have been happily using TexShop and BBEdit together for many years using an Applescript that Jason Davies and Richard Seguin put together on this 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? 


More information about the macostex-archives mailing list