Dear Steve,
thank you for your answer. I tried the following: (1) I went to "Bundles" => "Bundle Editor" => "Show Bundle Editor" (2) navigated to "R Console (R.app)" => "Send Document / Selection to R.app" (3) created a copy and called it "Send all before cursor to R.app" (4) for this new command, I went to "Command(s)" and replace the line saying: rawText="`cat`" by: rawText = "`head -$(($TM_LINE_NUMBER-1))`" as you suggested (5) I used the "Key Equivalent" "shift + apple-key + R"
Now when I executed the command, a lot of weird things happened [I work with Version 1.5.8 (1505) on Mac OS X 10.6.7]: 1) A window pops up, saying "Sending task to Rdaemon.." and then "Rdaemon is busy..." and it seems that every line of the file is sent ... 2) A new file named "console.Rcon -- Rsession" popped up. It had two tabs: The first one is labelled "console.Rcon" and contains the sign ">", the second one is called "r_res" and is empty. 3) nothing is executed in R [R is also not opened etc].
Do you know what's going wrong?
Cheers,
Marius
On 21 Apr 2011, at 20:35, Marius Hofert wrote:
(1) I went to "Bundles" => "Bundle Editor" => "Show Bundle Editor" (2) navigated to "R Console (R.app)" => "Send Document / Selection to R.app" (3) created a copy and called it "Send all before cursor to R.app" (4) for this new command, I went to "Command(s)" and replace the line saying: rawText="`cat`" by: rawText = "`head -$(($TM_LINE_NUMBER-1))`" as you suggested (5) I used the "Key Equivalent" "shift + apple-key + R"
⇧⌘R is the keyboard shortcut for "Send Selection/Document to Rdaemon" inside the bundle 'R'. Try first to use your new command without keyboard shortcut to see if it works. You can look for given keyboard shortcuts via Bundles > Select Bundle Item - then click at the magnifier and check 'Key Equivalent' and press you desired key combination.
Best, --Hans
On 2011-04-21 14:35, Marius Hofert wrote:
Now when I executed the command, a lot of weird things happened
First a caveat. I know nothing about R. I'd never even heard of it before your question. I only installed the bundle briefly to see what it was doing, then deleted it. So I can't help you with the specifics there.
But, there were a couple things wrong with what I sent. Serves me right for not posting exactly what I tested... First, I had spaces around the equals sign in the assignment, which is a no-no in shell syntax. Second, at least in my test script, I had failed to quote the the $rawText variable in the echo command, which ended up stripping the newlines. Here's my full test script cut'n'pasted straight from the bundle editor, and a screen shot of the output.
#! /bin/sh rawText="`head -$(($TM_LINE_NUMBER-1))`" echo "<pre>" "$rawText" "</pre>" | cat
The "<pre>" wrapper is to get the newlines to show up in the HTML output window; you'll want to eliminate that. The '| cat' here is a placeholder for the 'osascript' command the R bundle script is calling. You'll need to keep the echo command as it is in the bundle (perhaps adding quotes around "$rawText" if they're not already there.) In the screen shot the cursor is in the middle of the word "dolore" on line 11. I added some punctuation to the text to make sure that special characters came through okay. The HTML output window shows what would be passed on to the command in the R bundle if I still had that installed.
I hope it works for you this time around!