wch / SendText

A Sublime Text plugin to send text to a terminal or other program
70 stars 13 forks source link

sending to R-gui - tried but failed #11

Closed vnijs closed 9 years ago

vnijs commented 9 years ago

I used the section below in vim at somepoint and that work find to send code to the R-gui. So I tried adding something similar to sendtext (see below). However, it had no effect. Is there a way to have R-code (from an R or Rmd file) sent to the R-gui but code in an sh file sent to iterm?

let cmd = substitute(cmd, "\", '\', 'g') let cmd = substitute(cmd, '"', '\"', "g") let cmd = substitute(cmd, "'", "\'", "g") call system("osascript -e 'tell application \"R\" to cmd \"" .cmd. "\"'")

    if prog == "R":
        # Remove trailing newline
        # selection = selection.rstrip('\n')
        selection = SendSelectionCommand.escapeString(selection)
vnijs commented 9 years ago

Alternatively, is there a way to only activate sendtext only for a particular file type?

wch commented 9 years ago

I think it would be possible to send to different programs based on the file type, or activate only for one type of file. If you want to take a stab at it, the API reference should be helpful: https://www.sublimetext.com/docs/3/api_reference.html