Skip to content

Commit

Permalink
Check immediately if it's an R file
Browse files Browse the repository at this point in the history
  • Loading branch information
wch committed Apr 11, 2012
1 parent 8ecf00a commit e9ab8f3
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions Rtools.py
Expand Up @@ -31,6 +31,10 @@ def cleanString(str):
return str

def run(self, edit):
# Check if it's an R file
if "R.tmLanguage" not in self.view.settings().get('syntax'):
return

# get selection
selection = ""
for region in self.view.sel():
Expand All @@ -46,20 +50,15 @@ def run(self, edit):
if(selection == ""):
return

# get name of syntax file
lang = self.view.settings().get('syntax')

# R file
if "R.tmLanguage" in lang:
# split selection into lines
selection = self.cleanString(selection).split("\n")
# define osascript arguments
args = ['osascript']
# add code lines to list of arguments
for part in selection:
args.extend(['-e', 'tell app "R64" to cmd "' + part + '"\n'])
# execute code
subprocess.Popen(args)
# split selection into lines
selection = self.cleanString(selection).split("\n")
# define osascript arguments
args = ['osascript']
# add code lines to list of arguments
for part in selection:
args.extend(['-e', 'tell app "R64" to cmd "' + part + '"\n'])
# execute code
subprocess.Popen(args)


def advanceCursor(self, region):
Expand Down

0 comments on commit e9ab8f3

Please sign in to comment.