[R-SIG-Mac] project request: TextWrangler plugin

Jean Thioulouse jtnews1 at biomserv.univ-lyon1.fr
Mon Nov 10 13:09:52 CET 2008


At 18:07 -0500 8/11/08, Carl Witthoft wrote:
>I know :-), I should just learn AquaMacs w/ ESS,  but I am 
>comfortable w/ TextWrangler.  So, just thought I'd put a shout out 
>to see if anyone would like to write a plugin that would let the 
>user execute code (in R.app) from a TextWrangler window.

Here is a small script that does the job. You can put it in Textwrangler
Scripts folder and assign it a key (like Cmd-R) in the Scripts palette.
Of course you need a working R.app but then it is very handy. You can
get the source file here: http://pbil.univ-lyon1.fr/JTHome/SendSelToR.txt

--
-- This script can be used to make TextWrangler execute commands in R.
-- It executes the current selection. If no text is selected it executes the current line.
-- Jean Thioulouse - Nov. 2008 - Jean.Thioulouse at univ-lyon1.fr
--
tell application "TextWrangler"
  set the_selection to (selection of front window as string)
  if (the_selection) is "" then
    set the_selection to line (get startLine of selection) of front window as string
  end if
end tell
tell application "R"
  cmd the_selection
end tell

-- 
Jean Thioulouse - Labo Biometrie et Biologie Evolutive,  UMR CNRS 5558
Universite Lyon 1, Batiment Mendel,   43 Boulevard du 11 Novembre 1918
                  69622 Villeurbanne Cedex - France                   
Tel : (33) (0)4 72 43 27 56                Fax : (33) (0)4 72 43 13 88
http://pbil.univ-lyon1.fr/JTHome/    http://www.sauvonslarecherche.fr/



More information about the R-SIG-Mac mailing list