[OS X TeX] BBedit and LaTeX

Richard Seguin riseguin at earthlink.net
Sat Apr 14 00:05:19 EDT 2007

On Apr 13, 2007, at 8:54 AM, Jason Davies wrote:

>> I think in this case the applescript code assumes that TeXShop  
>> already has the document open, although it doesn't matter whether  
>> or not it is the front-most document. (If it isn't the front  
>> document, it is brought to the front after it is compiled.)  
>> Additional code would have to be added in order to tell TeXShop to  
>> open the document before it attempts to compile it. I don't have  
>> time at the moment to figure out how to do that.
> try this
> tell application "BBEdit"
>     activate
>     save active document of text window 1
>     set texdatei to file of active document of text window 1
> end tell
> tell application "TeXShop"
>     activate
>     open texdatei
>     latex document of window 1
> end tell


The one problem with this short applescript is that it always  
compiles the front-most document in TeXShop, which may, or may not,  
correspond to the document saved in BBEdit. The example that I gave  
does compile the correct corresponding document, and, following your  
example, can also be modified to boot up TeXShop and open the  
document if it hasn't already been opened:

tell application "BBEdit"
	set fileName to (file of text window 1) as text
end tell
set unixname to POSIX path of fileName
set oldDelimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to "/"
-- pull the path out as a string and strip off the filename
set pathText to unixname
set pathList to (text items of pathText)
set docName to last item of pathList
set AppleScript's text item delimiters to oldDelimiters
tell application "BBEdit"
	save text document docName
end tell
tell application "TeXShop"
	open fileName
end tell
tell document docName of application "TeXShop"
end tell

> as far as I can see, BBEdit's support for TeX is currently mostly  
> the syntax colouring but I've found them interested (but not  
> expert) in adding stuff for TeX. Eg they just implemented folding  
> for \paragraph and \subparagraph (as they had for chapter etc) when  
> I sent them a detailed report.

They have also implemented a nice function popup for navigating  
sections, subsections, theorems, propositions, etc.

Richard Séguin
------------------------- Helpful Info -------------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
TeX FAQ: http://www.tex.ac.uk/faq
List Archive: http://tug.org/pipermail/macostex-archives/
List Reminders & Etiquette: http://www.esm.psu.edu/mac-tex/list/

More information about the MacOSX-TeX mailing list