[OS X TeX] 1) Search source file when preview is active (`front'). 2) Incremental search
Michael Sharpe
msharpe at ucsd.edu
Sun May 25 18:43:00 EDT 2014
On May 25, 2014, at 11:48 AM, Nicolae Garleanu <garleanu at haas.berkeley.edu> wrote:
> Hi Michael,
> Am I right that, if one is content with the ability to call the macro from
> the .pdf and .tex files, then one can just do something like
>
> if win ends with ".pdf" then
> tell application "System Events" to keystroke "1" using command down
> end if
> tell application "System Events" to keystroke "f" using command down
>
> I.e., skip the loop dealing with consoles? Of course it can¹t hurt to have
> it there anyway. In fact, what I had played with was to have cmd-1 be
> executed anyway, since that way the latest .tex would be reactivated,
> unless it was already active, in which case it remains the latest .tex.
> (Code below.) Not meant to work with consoles, of course. For reasons I
> don¹t understand, it doesn¹t always do what I expect it to, in that it
> sometimes searches in the wrong .tex file, and also beeps as if there¹s an
> error. May have to do with the way I change focus to the latest window?
> Anyway, I¹ll implement your latest. As for ``applescript direct¹¹, I was
> afraid that, since I needed to give input through GUI to perform the
> search there may be a problem.
It turns out that the list traversed by Next Source Window and Previous Source Window includes all source files opened since TeXShop's last restart, and can result in opening previously closed files. The following version is simpler and does not have this problem.
tell application "TeXShop"
activate
set win to name of window 1
if win ends with ".pdf" then
tell application "System Events" to keystroke "1" using command down
else if win ends with " console" then
set src to (text 1 thru -9 of win) & ".tex"
try
set index of (first window whose name is src) to 1
end try
end if
tell application "System Events" to keystroke "f" using command down
end tell
Michael
More information about the MacOSX-TeX
mailing list