BBEdit 9.6.3 on Mac OS X 10.6.7

I'm working on a LaTeX project with a fairly stereotyped directory layout. I 
have a "figure" clipping that looks like:

\begin{figure}[htbp]
        \centering
        
\includegraphics[width=4in]{#BASENAME#/Art/#SELSTART#000#SELEND#-#SELECT#.pdf}
        \caption{#SELSTART#caption#SELEND#}
        \label{fig:#SELECT#}
\end{figure}

... in other words, I select the base name of my PDF file, and the clipping 
turns it into a file reference (to be edited) and a label string. Well, I've 
changed things so my figures may be PDFs _or_ PNGs. Wouldn't it be dynamite, I 
said, if the clipping could look in the current .tex file's Art directory, and 
find the actual file with that base name, filling in both the extension and the 
numeric prefix?

So I changed the \includegraphics line to

        \includegraphics[width=4in]{#script FindGraphicsFile.rb#} 

and wrote a script that did the searching. I used Ruby because AppleScript is 
an <inexpressible-by-a-gentleman>ing nightmare for iterating directories and 
manipulating strings.

But:

* I need the directory that contains both the .tex file and the associated Art 
directory.
* I need the selected text.

These are easily pulled from BBEdit through AppleScript. You see where this is 
going. The first executable line in the script is 

FRONT_DOC = `osascript -e 'tell application "BBEdit" to POSIX path of \(file of 
document 1 as string\)'`

and BBEdit hangs as the Apple Event re-enters it. I know this problem was 
solved for worksheets, and I'm disappointed to see it's still there for 
clippings. Especially so, because there appears to be no way to get information 
into scripts called by clippings. I looked for environment variables (none), 
and the manual doesn't document any arguments or standard input. If I'm right, 
and a clipping script has no access whatever to the state of the document it 
will be inserted in, that's a severe limitation.

I tried it as a UNIX filter. Same problem, and this time, the Cancel button 
didn't work, so I had to kill BBEdit.

Can anyone advise me on an alternative? Do I have to spend a few days playing 
guessing games with AppleScript? I'd rather write my book.

        — F

-- 
You received this message because you are subscribed to the 
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
<http://groups.google.com/group/bbedit?hl=en>
If you have a feature request or would like to report a problem, 
please email "[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>

Reply via email to