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

Michael Sharpe msharpe at ucsd.edu
Sun Dec 29 16:34:06 EST 2013


On Dec 29, 2013, at 9:32 AM, David P.Goldenberg <goldenberg at biology.utah.edu> wrote:

> Hi, 
>  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" 
>       activate 
> 
>       tell TSLib to opendoc(FILEPATH) 
> 
>       tell document displayname of application "TeXShop" 
>               latexinteractive 
>       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? 
> 
> Thanks, 
> David 
> 

I found it worked if I added 

delay 1

immediately after the line

tell TSLib to opendoc(FILEPATH)

You might need to increase the delay a bit with an older machine.

My setup is not quite the same as yours---I'm using TeXShop 3.26 with Mavericks (10.9.1) with "configure for external editor" turned off. I tried the modified script from both the AppleScript Editor and as a TeXShop macro. In both cases, it worked whether or not the associated pdf was open in TeXShop.

Michael


More information about the MacOSX-TeX mailing list