Hi,
I have taken a stab at trying to make this work. Here is an
AppleScript I am writing to get this to work. This is based on another
script and contains probably lots of unnecessary code.
##############
(* Find out which editor is running. If both are running, it probably
depends on which one was launched first (i.e. seemingly random) *)
tell application "System Events"
try
set callingEditor to 1st process whose name is "BBEdit"
on error
tell me to quit
end try
set appName to the name of callingEditor
end tell
(* Since BBEdit and TextWrangler use the same AppleEvents, we can get
away with this. Of course AppleScript still needs to know what to
emit. *)
tell application appName
using terms from application "BBEdit"
set numdocs to the number of every text document
repeat with ii from 1 to numdocs
if (modified of text document ii) then
save text document ii
end if
end repeat
end using terms from
end tell
(* If there are open documents, then "do your thing" *)
if numdocs > 0 then
tell application appName
using terms from application "BBEdit"
set mypath to get file of active document of window 1
end using terms from
end tell
set myHome to do shell script "echo $HOME"
set cmd to do shell script "/Users/chris/Library/TeXShop/bin/
Sweave.sh" & " -old=/Applications/Skim.app/Contents/MacOS/Skim " &
(the quoted form of POSIX path of mypath)
tell application "Terminal"
set numterms to count windows
if numterms > 0 then
do script cmd in window 1
else
do script cmd
end if
end tell
end if
##########
However, that gives me the following output:
##########
tell application "System Events"
get process 1 whose name = "BBEdit"
--> application process "BBEdit"
get name of application process "BBEdit"
--> "BBEdit"
end tell
tell application "BBEdit"
count every text document of current application
--> 6
get modified of text document 1
--> false
get modified of text document 2
--> false
get modified of text document 3
--> false
get modified of text document 4
--> false
get modified of text document 5
--> false
get modified of text document 6
--> false
get file of active document of window 1
--> file "Macintosh
HD:Users:chris:Dropbox:Documents:university:classes:
2011_2012:spring2012:stat5201:hw:hw5:stat5201_hw5.Rnw"
end tell
tell current application
do shell script "echo $HOME"
--> "/Users/chris"
do shell script "/Users/chris/Library/TeXShop/bin/Sweave.sh -old=/
Applications/Skim.app/Contents/MacOS/Skim '/Users/chris/Dropbox/
Documents/university/classes/2011_2012/spring2012/stat5201/hw/hw5/
stat5201_hw5.Rnw'"
--> error "Error in file(output, open = \"w\", encoding =
encoding) :
cannot open the connection
Calls: Sweave -> <Anonymous> -> file
In addition: Warning message:
In file(output, open = \"w\", encoding = encoding) :
cannot open file 'stat5201_hw5.tex': Permission denied
Execution halted" number 1
Result:
error "Error in file(output, open = \"w\", encoding = encoding) :
cannot open the connection
Calls: Sweave -> <Anonymous> -> file
In addition: Warning message:
In file(output, open = \"w\", encoding = encoding) :
cannot open file 'stat5201_hw5.tex': Permission denied
Execution halted" number 1
##########
Any ideas? I'd be happy to share the .Rnw file if someone knows why
this isn't working. I am new to AppleScripting and am just trying to
automate this. I know that:
/Users/chris/Library/TeXShop/bin/Sweave.sh -old=/Applications/Skim.app/
Contents/MacOS/Skim '/Users/chris/Dropbox/Documents/university/classes/
2011_2012/spring2012/stat5201/hw/hw5/stat5201_hw5.Rnw'
Works as expected from the terminal. Is it that I need to tell
AppleScript to use the BBEdit's directory to run Sweave and then
LaTeX?
Thanks,
Chris
--
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>