[OS X TeX] Applescript open_selection

Claus Gerhardt claus.gerhardt at urz.uni-heidelberg.de
Sun Oct 17 12:28:49 CEST 2004


I downloaded Matthew's open selection script, but it doesn't run on my 
machine. However, looking at it, I learnt how to tell TeXShop to 
recognize a selection and could thus simplify my own open selection 
script, which applies only to .tex files. BBEdit isn't needed any 
longer.

Claus

-- Applescript
-- open selection
-- Apply only to an already saved file.
-- Claus Gerhardt, Oct. 2004

(* Select the name or the path of an included file,  which is supposed 
to be a  .tex file,  then the script will tell  TeXShop to open the 
file.*)


tell application "TeXShop"
set findName to the «class CONT» of the «class SELE» of the front 
document
				(* Note:  <<class CONT>> is the content class of the selection 
(«class SELE») from the TeXShop Text dictionary...*)
				set selection_index to the «class LOC » of the «class SELE» of the 
front document
				(*Note:  <<class LOC >> is the index of the selection («class 
SELE») from the TeXShop Text dictionary...*)



set fileName to  #TEXPATH#
set n to (number of characters of contents of fileName)
set fileNamequoted to quoted form of fileName
set baseName to do shell script "basename " & fileNamequoted
set m to (number of characters of contents of baseName)
set dirNameunquoted to  (characters 1 thru (n - m - 1) of fileName as 
string)
set filePath to  (dirNameunquoted & "/"& findName &".tex") as string

set theFile to (filePath as POSIX file)

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 Post: <mailto:MacOSX-TeX at email.esm.psu.edu>





More information about the macostex-archives mailing list