Permalink
Browse files

Check immediately if it's an R file

  • Loading branch information...
1 parent 8ecf00a commit e9ab8f30937f05478ae958d345827fa903354682 @wch wch committed Apr 11, 2012
Showing with 13 additions and 14 deletions.
  1. +13 −14 Rtools.py
View
27 Rtools.py
@@ -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():
@@ -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):

0 comments on commit e9ab8f3

Please sign in to comment.