[Rd] "utils::file.edit" does not understand "editor" with additional arguments
Prof Brian Ripley
ripley @ending from @t@t@@ox@@c@uk
Thu Aug 30 08:14:23 CEST 2018
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, ripley using stats.ox.ac.uk
Emeritus Professor of Applied Statistics, University of Oxford
More information about the R-devel
mailing list