1
我正在嘗試爲Sublime Text 2創建一個簡單的插件,它允許OS X用戶將選定的文本發送到R64.app進行計算。到目前爲止,我有以下幾點:從sublimeText2發送文本到OS X上的R64.app
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+'''"''')
然而,這似乎當選定文本包含$
字符(經常發生在R
)失敗。我也懷疑我誤解了一些東西,因爲我不知道爲什麼當我刪除run
函數定義的,blah
部分時,爲什麼run
命令失敗(在python中有錯誤)。
你確定它是「$」未獲得通過的錯?在R中使用「$」作爲運算符有幾個缺陷。在R中正確編寫的應用程序代碼不會有很多「$」,因爲它的使用僅供交互使用。我們這些擁有Mac電腦但沒有「崇高」經驗的R用戶將需要看到「選定的文本」。 –
你見過RTools包嗎? https://github.com/karthikram/Rtools – wch