[OS X TeX] Applescript open_selection

Claus Gerhardt claus.gerhardt at urz.uni-heidelberg.de
Fri Oct 15 14:38:18 CEST 2004


Below is an Applescript open_selection with the help of which one can 
open included files in TeXShop. The equivalent of the script I posted 
yesterday for BBEdit.

However, BBEdit must still be installed and running.

Furthermore, the do_menu.scpt must be installed in its proper place.

Let me also mention that TeXShop didn't understand the command

set theFile to (POSIX file filepath as alias)

I had to pass this command to the Finder.

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. BBEdit must be installed and running.*)


tell application "Finder"
		set scriptPath to (do shell script "dirname " & 
"~/Library/TeXShop/Scripts/ex")
		set scriptPath to scriptPath & "/do_menu.scpt" as string
		set scriptName to POSIX file scriptPath as alias
		set scriptLiB to (load script scriptName)
		tell scriptLiB
			do_menu("TeXShop", "Edit", "Copy")
		end tell
	end tell




tell application "BBEdit"
	activate
	set findName to (contents of current clipboard)
end tell

tell application "TeXShop"
activate

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")
end tell

tell application "Finder"
	set theFile to (POSIX file filepath as alias)
end tell


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





More information about the macostex-archives mailing list