[OS X TeX] latexdiff Applescript

Claus Gerhardt gerhardt at math.uni-heidelberg.de
Sat May 6 21:22:32 CEST 2006


I have written an Applescript based on the perl script latexdiff- 
fast.pl. Copy the script below either as a macro in TeXShop or run it  
as a separate Applescript.

Read the commented lines of the Applescript for instructions. The  
required shell script pdflatexc is part of my TeX-Scripts and maybe  
even available in the TeXShop distribution.

Claus


-- Applescript
-- Apply only to an already saved file.
-- Claus Gerhardt, May 2006

(* The script is based on the perl script latexdiff-fast.pl, which  
has to be stored in ~/Library/TeXShop/bin/
The newer tex file, myFile.tex, has to be the frontmost document in  
TeXShop, while the old tex file has to be named old-myFile.tex  
residing in the same directory as myFile.tex. Differences will be  
saved in a file named diff-myFile.tex.
Run the script latexdiff.script either from within TeXShop's macros  
or as an external Applescript. The Applescript will run the perl  
script, two pdflatex runs and will ask TeXShop to open the file and  
the corresonding pdf file displaying the changes.

Important: The pdflatex runs require the presence of the shell script  
pdflatexc in ~/Library/TeXShop/bin/

If want do not want pdflatex runs, change the corresonding shell script.
*)

tell application "TeXShop"
	get path of document of window 1
	set fileName to result
end tell
set scriptPath to (do shell script "dirname " & "~/Library/TeXShop/ 
Scripts/ex")
set scriptPath to scriptPath & "/setnamets.scpt"
set scriptName to POSIX file scriptPath as alias
set scriptLiB to (load script scriptName)
tell scriptLiB
	set {baseName, texName, pdfName, namePath, dirName, dirNameunquoted,  
logName, logPath, rtfName} to setnamets(fileName)
end tell



set shellScript to "cd " & dirName & ";"
set shellScript to shellScript & "perl ~/Library/TeXShop/bin/ 
latexdiff-fast.pl  " & "old-" & texName & " " & texName & ">" &  
"diff-" & texName
do shell script shellScript



set shellScript to "cd " & dirName & ";"
set shellScript to shellScript & "~/Library/TeXShop/bin/pdflatexc  "  
& "diff-" & texName
do shell script shellScript

set shellScript to "cd " & dirName & ";"
set shellScript to shellScript & "~/Library/TeXShop/bin/pdflatexc  "  
& "diff-" & texName
do shell script shellScript



set fileDiff to dirNameunquoted & "/" & "diff-" & texName
set theFile to alias (POSIX file fileDiff)



tell application "TeXShop"
	open theFile
end tell


------------------------- Info --------------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
          & FAQ: http://latex.yauh.de/faq/
TeX FAQ: http://www.tex.ac.uk/faq
List Archive: http://tug.org/pipermail/macostex-archives/




More information about the macostex-archives mailing list