"utils::file.edit" does not understand "editor" with additional arguments

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

"utils::file.edit" does not understand "editor" with additional arguments

randy3k
I am using Sublime Text as my editor. If I run `subl -n .Rprofile` in bash, a file would be opened in a new window.

Back in R, if I run this

> file.edit(".Rprofile", editor="'subl -n'")
sh: 'subl -n': command not found
Warning message:
error in running command

However, the interesting bit happens when I run

edit(1:10, editor="'subl -n’")

It does open Sublime Text. It seems that `file.edit` and `edit` are behaving differently when “editor” has additional arguments.

Randy

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

signature.asc (499 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: "utils::file.edit" does not understand "editor" with additional arguments

Brian Ripley
We do not have the 'at a minimum' information requested by the posting
guide, and I cannot reproduce anything like this on a Unix-alike.  Both
file.edit and edit.default call the same underlying C code, and that
single-quotes the 'editor' argument to allow for spaces in its path/name
so I would not expect this to work.

Two workarounds:

1) Set an alias in your shell (e.g. in .bashrc) for 'subl -n'.  This is
something widely needed on macOS where many editors are invoked by 'open
-a', and I also use it for 'emacsclient -n'.

2) Make use of the ability to specify editor as an R function, invoking
the external program by system2() etc.


On 28/08/2018 20:07, Randy Lai wrote:

> I am using Sublime Text as my editor. If I run `subl -n .Rprofile` in bash, a file would be opened in a new window.
>
> Back in R, if I run this
>
>> file.edit(".Rprofile", editor="'subl -n'")
> sh: 'subl -n': command not found
> Warning message:
> error in running command
>
> However, the interesting bit happens when I run
>
> edit(1:10, editor="'subl -n’")
>
> It does open Sublime Text. It seems that `file.edit` and `edit` are behaving differently when “editor” has additional arguments.
>
> Randy

--
Brian D. Ripley,                  [hidden email]
Emeritus Professor of Applied Statistics, University of Oxford

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel