I'm trying to create a simple plugin for Sublime Text 2 that will permit OS X users to send the selected text to R64.app for computation. So far I have the following:
import sublime, sublime_plugin, os
class send2rCommand(sublime_plugin.TextCommand):
def run(self,blah):
os.system("""osascript -e 'tell application "R64" to activate'""")
for sel in self.view.sel():
sel_text = self.view.substr(sel)
os.system('''osascript -e 'on run(args)' -e 'tell application "R64" to cmd (item 1 of args)' -e 'end run' -- "'''+sel_text+'''"''')
However, this seems to fail when the selected text contains the $
character (a frequent occurrence in R
). I also suspect that I've misunderstood something as I'm not sure why the run
command fails (with an error in python) when I remove the ,blah
part of the run
function definition.