Skip to content
This repository
Browse code

Check immediately if it's an R file

  • Loading branch information...
commit e9ab8f30937f05478ae958d345827fa903354682 1 parent 8ecf00a
Winston Chang authored April 11, 2012

Showing 1 changed file with 13 additions and 14 deletions. Show diff stats Hide diff stats

  1. 27  Rtools.py
27  Rtools.py
@@ -31,6 +31,10 @@ def cleanString(str):
31 31
         return str
32 32
 
33 33
     def run(self, edit):
  34
+        # Check if it's an R file
  35
+        if "R.tmLanguage" not in self.view.settings().get('syntax'):
  36
+            return
  37
+
34 38
         # get selection
35 39
         selection = ""
36 40
         for region in self.view.sel():
@@ -46,20 +50,15 @@ def run(self, edit):
46 50
         if(selection == ""):
47 51
             return
48 52
 
49  
-        # get name of syntax file
50  
-        lang = self.view.settings().get('syntax')
51  
-
52  
-        # R file
53  
-        if "R.tmLanguage" in lang:
54  
-            # split selection into lines
55  
-            selection = self.cleanString(selection).split("\n")
56  
-            # define osascript arguments
57  
-            args = ['osascript']
58  
-            # add code lines to list of arguments
59  
-            for part in selection:
60  
-                args.extend(['-e', 'tell app "R64" to cmd "' + part + '"\n'])
61  
-            # execute code
62  
-            subprocess.Popen(args)
  53
+        # split selection into lines
  54
+        selection = self.cleanString(selection).split("\n")
  55
+        # define osascript arguments
  56
+        args = ['osascript']
  57
+        # add code lines to list of arguments
  58
+        for part in selection:
  59
+            args.extend(['-e', 'tell app "R64" to cmd "' + part + '"\n'])
  60
+        # execute code
  61
+        subprocess.Popen(args)
63 62
 
64 63
 
65 64
     def advanceCursor(self, region):

0 notes on commit e9ab8f3

Please sign in to comment.
Something went wrong with that request. Please try again.