[OS X TeX] 1) Search source file when preview is active (`front'). 2) Incremental search

Michael Sharpe msharpe at ucsd.edu
Sat May 24 19:13:47 CEST 2014


On May 23, 2014, at 11:49 PM, Nicolae Garleanu <garleanu at haas.berkeley.edu> wrote:

> Thanks, Michael, I¹ll try it out. In the meantime, a quick question: Why
> is the first loop necessary? (Or is it just to give me another
> idea/example?)
> 
> One thought I had had, working under the assumption of being already in a
> file associated with the source I wanted (i.e., pdf/console) was to first
> execute the cmd-F2 and then shft-cmd-F2. Since I left for later figuring
> out how to code that in applescript (now I know!), I didn¹t try it.

Here's a more efficient procedure. Works when the original focus is {.pfd,.tex, console}.

tell application "TeXShop"
	activate
	set p to (path of document 1)
	try
		open p as POSIX file
	on error errmsg number errnum
		if not (errnum = -1712) then
			display dialog "Error: '" & errmsg & "' trying to open document"
		end if
	end try
	tell application "System Events" to keystroke "f" using command down
end tell

Oddly, cmd-F2 doesn't do anything unless the focus is already on a .tex file, but shift-cmd-F2 does if the focus is a .tex or .pdf, but not a console window. The first loop in my first example was to get to the beginning of TeXShop's internal list of documents, as [shift-]cmd-F2 doesn't cycle.

Michael


More information about the macostex-archives mailing list