Giter Club home page Giter Club logo

atom-r-exec's Introduction

r-exec

Send R code from Atom to be executed in R.app, Terminal, iTerm, or a web browser running RStudio Server on Mac OS X. The current selection is sent or in the case of no selection the current line is sent.

Installation

apm install r-exec

or

Search for r-exec within package search in the Settings View.

Configuration

Keybindings

While cmd-enter is bound to sending code in the package, it is also annoyingly bound to entering a new line by default in atom. In order to make it work, you must add the following binding in ~/.atom/keymap.cson:

'atom-workspace atom-text-editor:not([mini])':
  'cmd-enter': 'r-exec:send-command'

Behavior

All configuration can be done in the settings panel. Alternatively, you can edit your configuration file as noted below.

In your global configuration file (~/.atom/init.coffee), you may set the following variables:

  • r-exec.whichApp which R application to use. Valid applications are:
    • R.app: the default (the R GUI).
    • RStudio: the RStudio console.
    • iTerm or Terminal: Assumes the currently active terminal has R running.
    • Safari or Google Chrome: assumes the currently active tab has an active RStudio session running or only one session is open. If the session is not in the active tab, r-exec should be able to find it and still send the code. This is helpful if you are viewing plots full screen.
  • r-exec.advancePosition
    • if true, go to the next line/paragraph after running the current line/paragraph.
    • if false, leave the cursor where it currently is
  • r-exec.focusWindow.
    • if true, focus the window before sending code.
    • if false, send the code in the background and stay focused on Atom. This is not possible when sending code to a browser.
  • r-exec.notifications
    • if true, notifications via NotificationManager when a paragraph or function is not identified.
  • r-exec.smartInsertOperator
    • if true when inserting operators, only insert whitespace to the left or right of the operator if there is no existing whitespace.
  • r-exec.skipComments
    • if true along with r-exec.advancePosition, skip comments after a command is run.

The default configuration looks like this:

atom.config.set('r-exec.whichApp', 'R.app')
atom.config.set('r-exec.advancePosition', false)
atom.config.set('r-exec.skipComments', true)
atom.config.set('r-exec.focusWindow', true)
atom.config.set('r-exec.notifications', true)
atom.config.set('r-exec.smartInsertOperator', true)

Inserting operators

r-exec currently supports inserting the assignment (<-) and pipe (%>%) operators. It tries to be smart by looking if there is whitespace to the left or the right of the cursor. If there is already whitespace it will not insert additional whitespace. Otherwise, it will insert whitespace. This can be disabled in the settings tab (Smart Insert Operator).

Notes about iTerm

The iTerm2 Applescript API recently changed as of version 3.0.0. Older versions of iTerm2 (< 3.0.0) are supported using mode iTerm. Newer versions of iTerm2 (>= 3.0.0) are supported using mode iTerm2.

Usage

Sending code

  • cmd-enter: send code to configured application (r-exec:whichApp).
  • shift-cmd-e: change to current working directory of current file.
  • shift-cmd-k: send code between a knitr block (currently only RMarkdown supported).
  • shift-cmd-u: send function under current cursor. Currently, only functions that begin of the first column in and on the first column of a line are sent. An example:
myFunction <- function(x) {
  # my code goes here
}
  • shift-cmd-m: send paragraph under current cursor. A paragraph is a region enclosed by whitespace.
  • shift-alt-p: send the previous command.

Inserting operators

  • alt--: insert the assignment operator <-
  • shift-alt-m: insert the pipe operator %>%

Notes

It is currently Mac-only because these things are easy to do with AppleScript. Any help on the Windows or Linux side would be great.

TODO

  • Error reporting.
  • Support for Windows and Linux.

atom-r-exec's People

Contributors

hafen avatar pimentel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

atom-r-exec's Issues

incorrect escaping when in paragraph mode

There is an issue when sending code to RStudio server (chrome) when sending a paragraph. For example, the following code fails (inserts additional \):

source("gene_common.R")

but does not fail when sending only the line

write test suite

Really need to write some specs:

  • test regular expressions
  • test sending of different modes
  • test inserting operators
  • test conversion strings with different types of quotes

extend support to Hyper (terminal)

I've been using this Atom package for quite a while, and while there have been many enhancements to the range of tools that it supports, I thought it might be worth requesting an extension to the Hyper terminal emulator.

I'm not quite familiar enough with the structure of the package to necessarily be useful, but I would gladly contribute toward a pull request that might make this happen in the near future. Sorry about any potential overlap with previous enhancement requests of this nature.

Uncaught Error: Undefined screen line when clipping screen position

Steps to reproduce:

  1. Open a file called test.R
  2. Click on "Packages" in the menu bar
  3. Click R-exec > Send line/selection

I get this error reliably, regardless of the content of the line. The line is sent to the terminal and evaluated by R, but a red box pops up telling me to file an issue.

Atom Version: 1.4.3
System: Mac OS X 10.11.3
Thrown From: r-exec package, v0.3.3

Stack Trace

Uncaught Error: Undefined screen line when clipping screen position

At /Applications/Atom.app/Contents/Resources/app.asar/src/display-buffer.js:886

Error: Undefined screen line when clipping screen position
    at DisplayBuffer.module.exports.DisplayBuffer.clipScreenPosition (/Applications/Atom.app/Contents/Resources/app.asar/src/display-buffer.js:874:15)
    at DisplayBuffer.module.exports.DisplayBuffer.bufferPositionForScreenPosition (/Applications/Atom.app/Contents/Resources/app.asar/src/display-buffer.js:826:20)
    at TextEditorMarker.module.exports.TextEditorMarker.setHeadScreenPosition (/Applications/Atom.app/Contents/Resources/app.asar/src/text-editor-marker.js:185:60)
    at /Applications/Atom.app/Contents/Resources/app.asar/src/cursor.js:67:31
    at Cursor.module.exports.Cursor.changePosition (/Applications/Atom.app/Contents/Resources/app.asar/src/cursor.js:673:7)
    at Cursor.module.exports.Cursor.setScreenPosition (/Applications/Atom.app/Contents/Resources/app.asar/src/cursor.js:65:19)
    at /Applications/Atom.app/Contents/Resources/app.asar/src/text-editor.js:1448:23
    at TextEditor.module.exports.TextEditor.moveCursors (/Applications/Atom.app/Contents/Resources/app.asar/src/text-editor.js:1652:9)
    at TextEditor.module.exports.TextEditor.setCursorScreenPosition (/Applications/Atom.app/Contents/Resources/app.asar/src/text-editor.js:1447:19)
    at Object.module.exports.sendCommand (/Users/davidharris/.atom/packages/r-exec/lib/r-exec.coffee:98:14)
    at atom-workspace.<anonymous> (/Users/davidharris/.atom/packages/r-exec/lib/r-exec.coffee:40:34)
    at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/Applications/Atom.app/Contents/Resources/app.asar/src/command-registry.js:260:29)
    at CommandRegistry.handleCommandEvent (/Applications/Atom.app/Contents/Resources/app.asar/src/command-registry.js:3:61)
    at CommandRegistry.module.exports.CommandRegistry.dispatch (/Applications/Atom.app/Contents/Resources/app.asar/src/command-registry.js:160:19)
    at AtomEnvironment.module.exports.AtomEnvironment.dispatchApplicationMenuCommand (/Applications/Atom.app/Contents/Resources/app.asar/src/atom-environment.js:1013:28)
    at emitOne (events.js:77:13)
    at EventEmitter.emit (events.js:169:7)

Commands

     -0:21.2.0 pane:reopen-closed-item (atom-text-editor.editor.is-focused)
     -0:11.9.0 editor:newline-below (atom-text-editor.editor.is-focused)
     -0:11.2.0 core:move-up (atom-text-editor.editor.is-focused)
     -0:10.8.0 editor:select-to-end-of-line (atom-text-editor.editor.is-focused)
     -0:10.5.0 editor:newline-below (atom-text-editor.editor.is-focused)
     -0:09.8.0 core:move-up (atom-text-editor.editor.is-focused)
     -0:02.2.0 r-exec:send-command (atom-text-editor.editor.is-focused)

Config

{
  "core": {
    "themes": [
      "one-light-ui",
      "one-light-syntax"
    ]
  },
  "r-exec": {
    "advancePosition": true,
    "whichApp": "Terminal"
  }
}

Installed Packages

# User
language-r, v0.4.0
r-exec, v0.3.3

# Dev
No dev packages

Support for Windows. Uncaught Error: write EPIPE

[Enter steps to reproduce below:]

  1. ...
  2. ...

Atom Version: 1.7.3
System: Unknown Windows Version
Thrown From: r-exec package, v0.3.4

Stack Trace

Uncaught Error: write EPIPE

At events.js:141

Error: write EPIPE
    at exports._errnoException (util.js:856:11)
    at Socket._writeGeneric (net.js:675:26)
    at Socket._write (net.js:694:8)
    at doWrite (_stream_writable.js:292:12)
    at writeOrBuffer (_stream_writable.js:278:5)
    at Socket.Writable.write (_stream_writable.js:207:11)
    at Socket.write (net.js:618:40)
    at execute (C:\Users\wjsbean\.atom\packages\r-exec\node_modules\node-osascript\lib\index.js:56:12)
    at Object.module.exports.execute (C:\Users\wjsbean\.atom\packages\r-exec\node_modules\node-osascript\lib\index.js:64:5)
    at Object.module.exports.terminal (file:///C:/Users/wjsbean/.atom/packages/r-exec/lib/r-exec.coffee:450:15)
    at Object.module.exports.sendCode (file:///C:/Users/wjsbean/.atom/packages/r-exec/lib/r-exec.coffee:109:32)
    at Object.module.exports.sendCommand (file:///C:/Users/wjsbean/.atom/packages/r-exec/lib/r-exec.coffee:91:6)
    at atom-workspace.<anonymous> (file:///C:/Users/wjsbean/.atom/packages/r-exec/lib/r-exec.coffee:40:34)
    at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (C:\Users\wjsbean\AppData\Local\atom\app-1.7.3\resources\app.asar\src\command-registry.js:260:29)
    at CommandRegistry.handleCommandEvent (C:\Users\wjsbean\AppData\Local\atom\app-1.7.3\resources\app.asar\src\command-registry.js:3:61)
    at CommandRegistry.module.exports.CommandRegistry.dispatch (C:\Users\wjsbean\AppData\Local\atom\app-1.7.3\resources\app.asar\src\command-registry.js:160:19)
    at AtomEnvironment.module.exports.AtomEnvironment.dispatchApplicationMenuCommand (C:\Users\wjsbean\AppData\Local\atom\app-1.7.3\resources\app.asar\src\atom-environment.js:1100:28)
    at EventEmitter.outerCallback (C:\Users\wjsbean\AppData\Local\atom\app-1.7.3\resources\app.asar\src\application-delegate.js:314:25)
    at emitTwo (events.js:87:13)
    at EventEmitter.emit (events.js:172:7)

Commands

     -1:03.4.0 command-palette:toggle (atom-text-editor.editor.is-focused)
     -0:49.4.0 core:confirm (atom-text-editor.editor.mini.is-focused)
     -0:12.9.0 r-exec:send-knitr (atom-text-editor.editor.is-focused)
     -0:07.1.0 r-exec:send-command (atom-text-editor.editor.is-focused)

Config

{
  "core": {
    "disabledPackages": [
      "language-gfm"
    ]
  },
  "r-exec": {
    "whichApp": "Terminal"
  }
}

Installed Packages

# User
atom-python-test, v0.1.7
autocomplete-python, v1.7.2
language-markdown, v0.13.0
language-r, v0.4.1
linter, v1.11.4
linter-lintr, v1.0.4
linter-python-pep8, v0.2.0
minimap, v4.23.5
python-autopep8, v0.1.3
python-debugger, v0.1.0
python-indent, v0.4.3
python-jedi, v0.3.6
r-exec, v0.3.4

# Dev
No dev packages

path.dirname is deprecated.

Argument to path.dirname must be a string

path.dirname (/Applications/Atom.app/Contents/Resources/app.asar/src/electron-shims.js:9:10)
execute (/Users/hjp/.atom/packages/r-exec/node_modules/node-osascript/lib/index.js:24:52)
Object.execute (/Users/hjp/.atom/packages/r-exec/node_modules/node-osascript/lib/index.js:64:5)
Object.getBrowserTitle (/Users/hjp/.atom/packages/r-exec/lib/r-exec.coffee:614:24)
Object.browser (/Users/hjp/.atom/packages/r-exec/lib/r-exec.coffee:634:19)
Object.sendCode (/Users/hjp/.atom/packages/r-exec/lib/r-exec.coffee:200:23)

r-exec ctrl+return command not working

I'm working with an iMac OS Sierra 10.12.16 and atom version 1.18.0 x64 and the command to send code to other platforms is just not working . I tried sending it to R.app, Rstudio and iTerm. It won't work with any of them.

advancePosition skips over some blocks

For some reason, cmd-return skipped over the line models(so) in the following block:

so <- sleuth_fit(so)

models(so)

so <- sleuth_wt(so, 'conditionB')

switch to command line when sending to browser

sometimes if the focus isn't on the command line prompt when sending to browser (RStudio server) code is not sent correctly.

this is a simple fix: send the keystrokes ctrl-2 before pasting code

add external commands to send to specific program

I haven't decided how to do this yet, but allow users to behind specific programs to specific keys.

Thus, essentially have a command that look something like this:

`r-exec:send-line-iterm2`

which will always send the line to iterm2.

(suggested in #38)

iTerm

Hi, fantastic package. I was trying to get my scripts sent over to iTerm, but couldn't get it to work. Any thoughts?

How to insert the pipe operator?

Hi, I just cant figure out how to insert the pipe %>% via some key binding. I have tried the usual suspect shift+command+M. But that is already taken. After disabling the default key bindings of the r-exec I still could not use that binding (I suppose I have to define it explicitly somehow.) Nevertheless, I have loaded dplyr and pasted %>% which however returned "unknown function". DO I miss something here?
Appreciate your help!

Not working with iTerm 2.9

Works with Terminal. Tried closing iTerm fully, then opening again, going to project dir, opening file with atom, starting R, then cmd+enter. Only one iTerm window, and its running R. Where to start looking?

For the time being its fine, I'll just have to use terminal lol

Send knitr blocks

When in Rmd or Rnw blocks, write a command which allows sending the entire block to R. For example, send code in between the following types of blocks when the cursor is in on the block:

    ```r
    # code goes here
    ```

or

<<<myBlock>>>
# code goes here
@

Uncaught TypeError: Cannot read property 'getBuffer' of undefined

[Enter steps to reproduce below:]

  1. ...
  2. ...

Atom Version: 1.4.3
System: Mac OS X 10.11.3
Thrown From: r-exec package, v0.3.3

Stack Trace

Uncaught TypeError: Cannot read property 'getBuffer' of undefined

At /Users/wolfemd/.atom/packages/r-exec/lib/r-exec.coffee:81

TypeError: Cannot read property 'getBuffer' of undefined
    at Object.module.exports._getEditorAndBuffer (/Users/wolfemd/.atom/packages/r-exec/lib/r-exec.coffee:81:20)
    at Object.module.exports.sendCommand (/Users/wolfemd/.atom/packages/r-exec/lib/r-exec.coffee:86:25)
    at atom-workspace.<anonymous> (/Users/wolfemd/.atom/packages/r-exec/lib/r-exec.coffee:40:34)
    at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/Applications/Atom.app/Contents/Resources/app.asar/src/command-registry.js:260:29)
    at /Applications/Atom.app/Contents/Resources/app.asar/src/command-registry.js:3:61
    at KeymapManager.module.exports.KeymapManager.dispatchCommandEvent (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:536:16)
    at KeymapManager.module.exports.KeymapManager.handleKeyboardEvent (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:359:22)
    at WindowEventHandler.module.exports.WindowEventHandler.handleDocumentKeydown (/Applications/Atom.app/Contents/Resources/app.asar/src/window-event-handler.js:97:36)
    at HTMLDocument.<anonymous> (/Applications/Atom.app/Contents/Resources/app.asar/src/window-event-handler.js:3:61)

Commands

     -2:22.8.0 r-exec:send-paragraph (atom-text-editor.editor.is-focused)
     -2:19 core:move-left (atom-text-editor.editor.is-focused)
     -2:17.7.0 r-exec:send-paragraph (atom-text-editor.editor.is-focused)
     -2:12.6.0 core:select-down (atom-text-editor.editor.is-focused)
     -2:09.8.0 editor:newline-above (atom-text-editor.editor.is-focused)
     -2:08.9.0 core:move-up (atom-text-editor.editor.is-focused)
     -2:08.3.0 editor:newline-below (atom-text-editor.editor.is-focused)
     -2:07.6.0 core:move-up (atom-text-editor.editor.is-focused)
     -2:06.7.0 core:move-right (atom-text-editor.editor.is-focused)
     -2:06.3.0 editor:newline-below (atom-text-editor.editor.is-focused)
     -2:04.5.0 core:undo (atom-text-editor.editor.is-focused)
     -2:03.6.0 core:move-left (atom-text-editor.editor.is-focused)
     -2:03.2.0 core:select-down (atom-text-editor.editor.is-focused)
     -2:02.7.0 editor:newline-below (atom-text-editor.editor.is-focused)
  2x -1:59.3.0 core:move-up (atom-text-editor.editor.is-focused)
  3x -0:16.9.0 r-exec:send-command (atom-text-editor.editor.mini.is-focused)

Config

{
  "core": {},
  "r-exec": {
    "whichApp": "Terminal"
  }
}

Installed Packages

# User
language-r, v0.4.0
minimap, v4.19.0
r-exec, v0.3.3

# Dev
No dev packages

Package.getStylesheetsPath is deprecated.

Store package style sheets in the styles/ directory instead of stylesheets/ in the r-exec package

Package.getStylesheetsPath (c:\Users\ahendrickson\AppData\Local\atom\app-0.200.0\resources\app.asar\src\package.js:460:9)
Package.getStylesheetPaths (c:\Users\ahendrickson\AppData\Local\atom\app-0.200.0\resources\app.asar\src\package.js:471:32)
Package.loadStylesheets (c:\Users\ahendrickson\AppData\Local\atom\app-0.200.0\resources\app.asar\src\package.js:453:38)
<unknown> (c:\Users\ahendrickson\AppData\Local\atom\app-0.200.0\resources\app.asar\src\package.js:183:19)
Package.measure (c:\Users\ahendrickson\AppData\Local\atom\app-0.200.0\resources\app.asar\src\package.js:163:15)
Package.load (c:\Users\ahendrickson\AppData\Local\atom\app-0.200.0\resources\app.asar\src\package.js:177:12)

Package.getActivationCommands is deprecated.

Use activationCommands instead of activationEvents in your package.json
Commands should be grouped by selector as follows:

  "activationCommands": {
    "atom-workspace": ["foo:bar", "foo:baz"],
    "atom-text-editor": ["foo:quux"]
  }
Package.getActivationCommands (c:\Users\ahendrickson\AppData\Local\atom\app-0.200.0\resources\app.asar\src\package.js:808:9)
Package.hasActivationCommands (c:\Users\ahendrickson\AppData\Local\atom\app-0.200.0\resources\app.asar\src\package.js:733:20)
<unknown> (c:\Users\ahendrickson\AppData\Local\atom\app-0.200.0\resources\app.asar\src\package.js:185:24)
Package.measure (c:\Users\ahendrickson\AppData\Local\atom\app-0.200.0\resources\app.asar\src\package.js:163:15)
Package.load (c:\Users\ahendrickson\AppData\Local\atom\app-0.200.0\resources\app.asar\src\package.js:177:12)
PackageManager.loadPackage (c:\Users\ahendrickson\AppData\Local\atom\app-0.200.0\resources\app.asar\src\package-manager.js:355:14)

New version & sending setwd every time

Hi,

I was trying to avoid sending the working directory every time some code is sent to the R console, and I saw that in the new version (0.3.0) there's an option for that, besides some other changes. Yet, I couldn't install or update the new version, is there any way to do that? And in case it is not, where could I find the line of code to change the setwd feature?

By the way, thanks a lot for this package!!

general support for any language/text?

While I do develop in R, I also develop in other languages.
Sending text from atom to the terminal (or other user-designated app) is very useful in general, not only with R. Sublime Text has SendText a general-purpose plugin for sending any kind of text to the terminal.

Is there any reason why atom-r-exec could not be used with any language (or even plain text)? If so I would suggest the name and documentation change to reflect its general purpose nature.

Also perhaps some features could be generalized, for example the "advancing past comments" could take into account the different comment symbols in different languages.

Using the Alt+letter key for bindings breaks Mac keyboards

I would be grateful if you could consider removing bindings with Alt+Letter from the package's Mac key bindings.

Using the alt-modifier alone without any other modifier (Cmd, Ctrl) โ€“ shift does not count! โ€“ shadows additional symbols available on the keyboard. E.g., on a German or even US keyboard, I now cannot type the en-dash (Alt+Minus) anymore due to the r-exec keybinding, which is also active in Markdown mode, where it is quite useless. I would be grateful if the default configuration would not break keyboard behaviour; such grave changes should be opt-in in my opinion.

Cannot send a large chunk of R code to iTerm2 on Mac OS X

If I send (cmd-enter) a large chunk of R code to iTerm2, iTerm2 does not recognize the original code.

For example, R is supposed to recognize test as a function (although the function itself is meaningless),

test <- function(){
  rnorm(100)
  rnorm(100)
  rnorm(100)
# ...(please repeat these 100 times)...#
  rnorm(100)
  rnorm(100)
}

but this will return something like below.

+   rnorm(100)
+   rnorm(100)
+   rnorm(100)
+   rnorm(100)
+   rnorm(100)
+   r  r  r  r  r  r  r10  r  r  r  10  r  r  r  10  r  r  r  10  r  r  r  10  r  rnorm(100)
Error: unexpected symbol in:
"  rnorm(100)
  r  r"
>   rnorm(10  rnorm(10(100)
Error: unexpected symbol in "  rnorm(10  rnorm"
>   rnorm(10  rnorm(10 10  rnorm(10 10  rnorm(10 10  rnorm(1m(10  rnorm(10(10  rnorm(rm(100)
Error: unexpected symbol in "  rnorm(10  rnorm"

It does not happen when I use R.app or Terminal. I'm not sure if it's just me or bug of iTerm2 or r-exec. Thanks.

Atom: 1.12.9
r-exec: 0.4.1
iTerm2: Build 3.0.13
R version 3.3.2 (2016-10-31)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: macOS Sierra 10.12.2

Failed to load the r-exec package

[Enter steps to reproduce below:]

  1. ...
  2. ...

Atom Version: 0.190.0
System: Mac OS X 10.10.2
Thrown From: r-exec package, v0.1.0

Stack Trace

Failed to load the r-exec package

At Cannot read property 'getPath' of null

TypeError: Cannot read property 'getPath' of null
  at Object.<anonymous> (/Users/indu/.atom/packages/r-exec/lib/r-exec.coffee:58:13)
  at Object.<anonymous> (/Users/indu/.atom/packages/r-exec/lib/r-exec.coffee:1:1)
  at Module._compile (module.js:452:26)
  at Object.requireCoffeeScript (/Applications/Atom.app/Contents/Resources/app/node_modules/coffee-cash/lib/coffee-cash.js:85:19)
  at Module.load (module.js:347:32)
  at Function.Module._load (module.js:302:12)
  at Module.require (module.js:357:17)
  at require (module.js:376:17)
  at Package.module.exports.Package.requireMainModule (/Applications/Atom.app/Contents/Resources/app/src/package.js:665:34)
  at /Applications/Atom.app/Contents/Resources/app/src/package.js:174:28
  at Package.module.exports.Package.measure (/Applications/Atom.app/Contents/Resources/app/src/package.js:152:15)
  at Package.module.exports.Package.load (/Applications/Atom.app/Contents/Resources/app/src/package.js:166:12)
  at PackageManager.module.exports.PackageManager.loadPackage (/Applications/Atom.app/Contents/Resources/app/src/package-manager.js:355:14)
  at PackageManager.module.exports.PackageManager.loadPackages (/Applications/Atom.app/Contents/Resources/app/src/package-manager.js:325:14)
  at Atom.module.exports.Atom.startEditorWindow (/Applications/Atom.app/Contents/Resources/app/src/atom.js:631:21)
  at Object.<anonymous> (/Applications/Atom.app/Contents/Resources/app/src/window-bootstrap.js:12:8)
  at Object.<anonymous> (/Applications/Atom.app/Contents/Resources/app/src/window-bootstrap.js:23:4)
  at Module._compile (module.js:452:26)
  at Object.loadFile [as .js] (/Applications/Atom.app/Contents/Resources/app/src/babel.js:162:21)
  at Module.load (module.js:347:32)
  at Function.Module._load (module.js:302:12)
  at Module.require (module.js:357:17)
  at require (module.js:376:17)
  at window.onload (file:///Applications/Atom.app/Contents/Resources/app/static/index.js:54:25)

Commands

Config

{
  "core": {
    "themes": [
      "atom-dark-ui",
      "atom-dark-syntax"
    ],
    "disabledPackages": [
      "vim-mode"
    ]
  }
}

Installed Packages

# User
color-picker, v1.4.4
linter, v0.11.1
merge-conflicts, v1.2.10
r-exec, v0.1.0
run-command, v0.1.1

# Dev
No dev packages

How to move the cursor to next line after hitting some code?

Hello Harold,

thx again for putting your time into a deeper R & Atom integration.

Im not 100% sure whether that is something one can adjust quickly, but how do you advance to next line after hitting cmd enter ? I expect (at least from the Rstudio behaviour) that after hitting cmd enter one should advancing to the next line of code. Currently, after hitting that keys the cursor just disappears forcing the user to set it one new line manually.

Additionally, I was wondering whether you had some time to move further with #32 #36 and your opinion on autocompletion of external packages. Do you have some recommendation on how to do that? Im looking forward to finally move from Rstudio to Atom :)

Thx
Eugene

Send code to console within atom

Instead of sending the R code outside of Atom, is it possible to use a built-in console (as in Juno) to send the code to? A workspace with all the variables and a plotting area, which are also features in Juno (and that hopefully you can leverage!) would be awesome. Indeed, this would put Atom on par with (or really, beyond) RStudio. Thanks for the great package.

Problems sending selection/whole file from Atom to R.app (Mac)

[Enter steps to reproduce below:]

  1. Install R Package in Atom but then keybinding doesnt work (they work sometimes, but not everytime)
  2. download github code from here and replace all files in /lib with the new files.

Atom Version: 1.0.19
System: Mac OS X 10.11.1
Thrown From: r-exec package, v0.2.0

Stack Trace

Uncaught Error: Cannot find module 'node-osascript'

At module.js:336

Error: Cannot find module 'node-osascript'
  at Module._resolveFilename (module.js:334:15)
  at Function.Module._resolveFilename (/Applications/Atom.app/Contents/Resources/app.asar/src/module-cache.js:383:52)
  at Function.Module._load (module.js:284:25)
  at Module.require (module.js:363:17)
  at require (module.js:382:17)
  at Object.module.exports.rapp (/Users/stoelzle/.atom/packages/r-exec/lib/r-exec.coffee:108:17)
  at Object.module.exports.sendCode (/Users/stoelzle/.atom/packages/r-exec/lib/r-exec.coffee:52:28)
  at Object.module.exports.sendCommand (/Users/stoelzle/.atom/packages/r-exec/lib/r-exec.coffee:38:6)
  at atom-workspace.<anonymous> (/Users/stoelzle/.atom/packages/r-exec/lib/r-exec.coffee:29:34)
  at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/Applications/Atom.app/Contents/Resources/app.asar/src/command-registry.js:245:29)
  at CommandRegistry.handleCommandEvent (/Applications/Atom.app/Contents/Resources/app.asar/src/command-registry.js:3:61)
  at CommandRegistry.module.exports.CommandRegistry.dispatch (/Applications/Atom.app/Contents/Resources/app.asar/src/command-registry.js:145:19)
  at EventEmitter.<anonymous> (/Applications/Atom.app/Contents/Resources/app.asar/src/window-event-handler.js:70:30)
  at emitOne (events.js:77:13)
  at EventEmitter.emit (events.js:169:7)

Commands

     -0:22.2.0 r-exec:send-command (atom-text-editor.editor.is-focused)
     -0:09.0 editor:consolidate-selections (atom-text-editor.editor.is-focused)
     -0:09.0 core:cancel (atom-text-editor.editor.is-focused)
     -0:05.6.0 symbols-view:toggle-project-symbols (atom-text-editor.editor.is-focused)
     -0:04.7.0 editor:consolidate-selections (atom-text-editor.editor.mini.is-focused)
     -0:04.7.0 core:cancel (atom-text-editor.editor.mini.is-focused)
     -0:00.5.0 r-exec:send-command (atom-text-editor.editor.is-focused)

Config

{
  "core": {
    "themes": [
      "atom-dark-ui",
      "base16-tomorrow-dark-theme"
    ],
    "packagesWithKeymapsDisabled": [
      "r-exec"
    ]
  },
  "r-exec": {
    "whichApp": "R.app",
    "advancePosition": true,
    "focusWindow": true
  }
}

Installed Packages

# User
gtk-dark-theme, v0.1.4
language-r, v0.3.0
r-exec, v0.2.0

# Dev
No dev packages

How to pass r -exec to R.app or Term3?

Hello,

thank you for bridging R to atom! I'm new to atom and hence apologize for the triviality of my question.
While using atom I could r-execand pass the code to r-studio server via chrome and to itermas well as toterminal. However, I could't pass code to R.app

I installed R.app via brew install R.
Do I have to consider to determine the path to R.app explicitly?
How could I pass r-exec of R-code to Atom Term 3 ,for example, to keep everything in Atom?

Thank you!
Eugene
OSX El Capitan 10.11.4 Atom 1.6.2

Deprecated Atom APIs will be removed June 1st

Atom will no longer load this package after June 1st without changes. There are a couple deprecations on the latest version (0.1.0) of this package:

  1. Store package style sheets in the styles/ directory instead of stylesheets/ in the <pack-name> package
  2. Use activationCommands instead of activationEvents in your package.json Commands should be grouped by selector as follows: json "activationCommands": { "atom-workspace": ["foo:bar", "foo:baz"], "atom-text-editor": ["foo:quux"] }
  3. Use ::getPaths instead
  4. atom.workspaceView is no longer available. In most cases you will not need the view. See the Workspace docs for alternatives: https://atom.io/docs/api/latest/Workspace. If you do need the view, please use atom.views.getView(atom.workspace), which returns an HTMLElement.
  5. Call ::getActiveTextEditor instead
  6. Use TextEditor::getLastSelection() instead
  7. Use TextEditor::selectLinesContainingCursors instead

Visit https://gist.github.com/benogle/6d09e295c84b717ef9b4 and search for your package name to see up-to-date deprecations.

If this package has been replaced by another package or functionality in core, please reply with this information.

See atom/atom#6867 for more info. Thanks!

Uncaught TypeError: Cannot read property 'getSelection' of undefined

[Enter steps to reproduce below:]

  1. ...
  2. ...

Atom Version: 0.165.0
System: Mac OS X 10.10.1
Thrown From: r-exec package, v0.1.0

Stack Trace

Uncaught TypeError: Cannot read property 'getSelection' of undefined

At /Users/therimalaya/.atom/packages/r-exec/lib/r-exec.coffee:45

TypeError: Cannot read property 'getSelection' of undefined
  at Object.module.exports.rstudioserver (/Users/therimalaya/.atom/packages/r-exec/lib/r-exec.coffee:45:49)
  at atom-workspace.<anonymous> (/Users/therimalaya/.atom/packages/r-exec/lib/r-exec.coffee:8:69)
  at atom-workspace.handler (/Applications/Atom.app/Contents/Resources/app/src/space-pen-extensions.js:115:32)
  at atom-workspace.jQuery.event.dispatch (/Applications/Atom.app/Contents/Resources/app/node_modules/space-pen/vendor/jquery.js:4681:9)
  at atom-workspace.elemData.handle (/Applications/Atom.app/Contents/Resources/app/node_modules/space-pen/vendor/jquery.js:4359:46)
  at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/Applications/Atom.app/Contents/Resources/app/src/command-registry.js:243:29)
  at /Applications/Atom.app/Contents/Resources/app/src/command-registry.js:3:61
  at KeymapManager.module.exports.KeymapManager.dispatchCommandEvent (/Applications/Atom.app/Contents/Resources/app/node_modules/atom-keymap/lib/keymap-manager.js:549:16)
  at KeymapManager.module.exports.KeymapManager.handleKeyboardEvent (/Applications/Atom.app/Contents/Resources/app/node_modules/atom-keymap/lib/keymap-manager.js:391:22)
  at HTMLDocument.module.exports.WindowEventHandler.onKeydown (/Applications/Atom.app/Contents/Resources/app/src/window-event-handler.js:167:20)

Commands

     -0:27.6 emmet:expand-abbreviation (input.hidden-input)
     -0:26.3 core:undo (input.hidden-input)
     -0:24.5 grammar-selector:show (atom-text-editor.editor.editor-colors)
  2x -0:21.2 core:backspace (input.hidden-input)
     -0:19.9 core:confirm (input.hidden-input)
     -0:18.7 emmet:expand-abbreviation (input.hidden-input)
     -0:17.8 core:undo (input.hidden-input)
     -0:15.9 emmet:expand-abbreviation (input.hidden-input)
     -0:14.8 core:undo (input.hidden-input)
     -0:00.0 r-exec:send-to-rstudio-server (input.hidden-input)

Config

{
  "core": {}
}

Installed Packages

# User
atom-beautify, v0.17.3
autocomplete-bibtex, v0.4.1
autocomplete-paths, v0.9.1
autocomplete-plus, v1.1.0
autocomplete-snippets, v0.3.2
color-picker, v1.2.6
emmet, v2.3.0
language-knitr, v0.1.0
language-latex, v0.4.1
language-r, v0.1.1
linter, v0.9.0
minimap, v3.4.9
project-manager, v1.14.1
sassbeautify, v0.2.0
wordpress, v0.2.0
wordpress-api, v1.0.0

# Dev
No dev packages

/cc @atom/core

Atom.Object.defineProperty.get is deprecated.

atom.workspaceView is no longer available.
In most cases you will not need the view. See the Workspace docs for
alternatives: https://atom.io/docs/api/latest/Workspace.
If you do need the view, please use atom.views.getView(atom.workspace),
which returns an HTMLElement.

Atom.Object.defineProperty.get (/Applications/Atom.app/Contents/Resources/app/src/atom.js:54:11)
Object.activate (/Users/trevi/Dropbox/Data/.atom/packages/r-exec/lib/r-exec.coffee:6:9)

when sending to browser, find the appropriate tab

currently, only the name of the current tab is checked and code is rejected if doesn't match "RStudio". If only 1 tab is open with the title "RStudio", then it should automatically send it there.

Uncaught TypeError: Cannot read property 'substring' of undefined

[Enter steps to reproduce below:]

  1. ...
  2. ...

Atom Version: 1.2.4
System: Mac OS X 10.10.5
Thrown From: r-exec package, v0.3.0

Stack Trace

Uncaught TypeError: Cannot read property 'substring' of undefined

At /Users/xiangxiangzeng/.atom/packages/r-exec/lib/r-exec.coffee:79

TypeError: Cannot read property 'substring' of undefined
    at Object.module.exports.setWorkingDirectory (/Users/xiangxiangzeng/.atom/packages/r-exec/lib/r-exec.coffee:79:14)
    at atom-workspace.<anonymous> (/Users/xiangxiangzeng/.atom/packages/r-exec/lib/r-exec.coffee:31:27)
    at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/Applications/Atom.app/Contents/Resources/app.asar/src/command-registry.js:260:29)
    at CommandRegistry.handleCommandEvent (/Applications/Atom.app/Contents/Resources/app.asar/src/command-registry.js:3:61)
    at CommandRegistry.module.exports.CommandRegistry.dispatch (/Applications/Atom.app/Contents/Resources/app.asar/src/command-registry.js:160:19)
    at AtomEnvironment.module.exports.AtomEnvironment.dispatchApplicationMenuCommand (/Applications/Atom.app/Contents/Resources/app.asar/src/atom-environment.js:987:28)
    at emitOne (events.js:77:13)
    at EventEmitter.emit (events.js:169:7)

Commands

     -2:59.7.0 core:select-up (atom-text-editor.editor.is-focused)
     -2:57.9.0 editor:newline-below (atom-text-editor.editor.is-focused)
     -2:56.9.0 core:move-down (atom-text-editor.editor.is-focused)
     -2:55.4.0 core:select-up (atom-text-editor.editor.is-focused)
     -2:54.9.0 editor:newline-below (atom-text-editor.editor.is-focused)
  7x -2:54.1.0 core:backspace (atom-text-editor.editor.is-focused)
  2x -2:50.7.0 core:select-down (atom-text-editor.editor.is-focused)
     -2:47.9.0 core:backspace (atom-text-editor.editor.is-focused)
     -2:41.9.0 tree-view:add-folder (span.name.icon.icon-file-directory)
     -2:40.8.0 core:cancel (atom-text-editor.editor.mini.is-focused)
     -2:40.3.0 tool-panel:unfocus (ol.tree-view.full-menu.list-tree.has-collapsable-children.focusable-panel)
  2x -1:47.6.0 core:cancel (atom-workspace.workspace.scrollbars-visible-when-scrolling.theme-one-dark-syntax.theme-one-dark-ui)
     -1:07.6.0 r-exec:send-command (ul.list-inline.tab-bar.inset-panel)
     -1:03.5.0 core:select-up (atom-text-editor.editor.is-focused)
     -1:01.8.0 editor:newline-below (atom-text-editor.editor.is-focused)
     -0:00.4.0 r-exec:setwd (atom-text-editor.editor.is-focused)

Config

{
  "core": {}
}

Installed Packages

# User
language-r, v0.4.0
r-exec, v0.3.0

# Dev
No dev packages

Advance position skips lines that end with # comments

head(inertial_signals_test[[1]])
nrow(inertial_signals_test[[1]])   # 2947 samples
ncol(inertial_signals_test[[1]])   # 128 cols

table(y_test)

In the above code, if the Cursor is on the first line, and Advance Position == TRUE, then it skips over line 2,3 to line 5.

Some more general name or description may attract more users

Thanks for the great package. I am very happy to find the way to send a selected text to iTerm.

Now that iTerm and Terminal.app can receive the command, non-R users will also be able to enjoy the advantage of this package. I think that the package should get more attention (or search hits) by more general name like send-to-console or exec-in-console, or by short description that contains the relevant words like "terminal".

resend same command

Nice work on this. reminds me of r-box from Sublime. it's super useful in my case because I have to run a lot of things on a cluster and can't stand being handcuffed by emacs/vim etc.

i've slowly added some keymappings to resemble rstudio but one feature I'd love to see is "resend last command", e.g. when you're working on a block of code and need to constantly rerun something. Thanks!

keep focus on terminal

Hi, am using atom-r-exec for mac, running on iterm. have been trying to keep the cursor focused on the terminal, but this doesn't seem to work. have tried to setings page as well as adding 'atom.config.set('r-exec.focusWindow', false)' to init.coffee

any thoughts? thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.