[TxMt] R bundle: Execute Document In R - Update plots
Hans-Joerg Bibiko
bibiko at eva.mpg.de
Fri Jan 5 09:06:24 UTC 2007
Hi,
I just thought about a tiny improvement regarding to display plots in
Preview.
If I want to plot something, Preview opens it. Fine. After doing that
I want to change the plot for instance. The new plot will be
calculated but Preview still displays the old one. I have to 'Revert'
it or close it before running the R script.
To make a quasi-update automatically here's a suggestion:
________________
defaults write /Applications/Preview.app/Contents/Info
NSAppleScriptEnabled -bool YES
P=$(osascript -e 'tell application "System Events" to (name of
processes) contains "Preview"')
if [ "$P" == "true" ]; then
osascript <<-AS2 &>/dev/null
tell application "Preview"
close every window
end tell
AS2
fi
"$TM_BUNDLE_SUPPORT/tmR.rb"
________________
Explanation:
'default write' has to execute only once to enable AppleScript in
Preview. So you can comment it out if set.
The next line checks whether Preview runs or not.
If Preview is running I close every window in Preview. This is a kind
of a small hack because AppleScript returns a warning 'missing
value', so I send it to the nirvana.
Both AppleScripts could be replaced by changing tmR.rb directly.
I.e., if tmp_dir is not empty and Preview is running (system(ps -aux
| grep Preview)) then call an AppleScript to close every window.
On the other hand it would be nice to have an easy way to set pdf()'s
'onefile' argument in order to be able to print all plots in one pdf.
Maybe solvable by using a TM variable?
Any comments?
All the best,
Hans
More information about the textmate
mailing list