From ripley @ending from @t@t@@ox@@c@uk  Thu Aug 30 08:14:23 2018
From: ripley @ending from @t@t@@ox@@c@uk (Prof Brian Ripley)
Date: Thu, 30 Aug 2018 07:14:23 +0100
Subject: [Rd] "utils::file.edit" does not understand "editor" with
 additional arguments
In-Reply-To: <6EF551C0-AC7B-412F-965C-36EECBDFBFEA@gmail.com>
References: <6EF551C0-AC7B-412F-965C-36EECBDFBFEA@gmail.com>
Message-ID: <5a8ac853-17c2-4f6e-9d8e-23d3804b3aa0@stats.ox.ac.uk>

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 at stats.ox.ac.uk
Emeritus Professor of Applied Statistics, University of Oxford



[Rd] "utils::file.edit" does not understand "editor" with additional arguments
Prof Brian Ripley