Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add an Rapp switcher in command palette

  • Loading branch information...
commit 0293c7a85029b575a02574d6b478956eedc9fe46 1 parent a0788ab
@randy3k randy3k authored
Showing with 31 additions and 5 deletions.
  1. +6 −0 Default.sublime-commands
  2. +10 −5 README.md
  3. +15 −0 Rsublime.py
View
6 Default.sublime-commands
@@ -0,0 +1,6 @@
+[
+ {
+ "caption": "R: Rapp Switcher",
+ "command": "rapp_switcher"
+ }
+]
View
15 README.md
@@ -26,11 +26,13 @@ Useful Commands
* Send the selection to R
* If no syntax is selected, it sends the whole line where the cursor stays at.
+* See settings to choose default R application to send to.
### Sending Code to Terminal ###
**Keybinding:** `Cmd-Alt-Enter`
-* Send the selection to R
+* Send the selection to R session in terminal
+* An R session needs to be running on terminal.
* If no syntax is selected, it sends the whole line where the cursor stays at.
* Useful for people working on server
@@ -44,10 +46,13 @@ Useful Commands
* Tell R to source the working script
+Kepmaps are changable by editing `Default (OSX).sublime-keymap`.
+
Settings
---------
-Edit `Rsublime.sublime-settings` to change settings
+### Rapp ###
+**Default application:** `R64`
-### Rapp ####
-**Options:** `"R64"`, `"R32"` or `"R"`
-* Set the version of R the above commands are effective on
+* Type ``Rapp Switcher`` in Command Palette to switcher between `R`, `R64` and `Terminal`.<br>
+It maps `Cmd-Enter` to the corresponding application.
+* Or edit Rsublime.sublime-settings to change settings
View
15 Rsublime.py
@@ -31,6 +31,11 @@ def rcmd(self, cmd, Rapp=None):
args.extend(['-e', 'tell app "Terminal" to do script "' + cmd + '" in front window\n'])
subprocess.Popen(args)
+ def set_Rapp(self, Rapp):
+ RCommon.Rapp = Rapp
+ RCommon.settings.set("Rapp", RCommon.Rapp)
+ sublime.save_settings('Rsublime.sublime-settings')
+
##################################
#### change working directory ####
##################################
@@ -69,3 +74,13 @@ def run(self, edit):
path = self.view.file_name()
cmd = "source(\"" + string.replace(path, '"', '\\"') + "\")"
self.rcmd(cmd)
+
+# Rapp switcher
+class RappSwitcher(sublime_plugin.WindowCommand, RCommon):
+ app_list = ["R64", "R", "Terminal"]
+ def run(self):
+ self.window.show_quick_panel(self.app_list, self.on_done)
+
+ def on_done(self, action):
+ if action>=0:
+ self.set_Rapp(self.app_list[action])
Please sign in to comment.
Something went wrong with that request. Please try again.