[R] calling an editor on MAC and Linux

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Fri Jun 14 11:22:45 CEST 2002


Ott Toomet <siim at obs.ee> writes:

> If there is something like default editor, it is "vi" on UNIX (but there may
> be 10-20 different editors with a full linux installation).  It is a general
> tradition to let the user to define his own favourite using EDITOR
> environment variable.  So, to be polite, you should check the presence of
> the variable first, and thereafter run either vi or whatever was defined as
> EDITOR.
> 
> This can be done pretty easily as (ignoring paste):
> 
> system("${EDITOR:-vi} outFile")
> 
> Unfortunately, this is not the whole story.  The previous example works with
> bash shell (which is default command interpreter on Linux).  With tcsh,
> another quite popular shell, I am afraid you need a different approach (this
> again is controlled with environment variable SHELL).  In addition, many
> editors in Unix are terminal-based (like vi) i.e., they do not open a new
> window.  This may cause problems when R is runned from a GUI or from Emacs
> (Emacs cannot interpret vi diplay-control strings correctly).  If runned as
> usual process on a terimal, it is just fine.
> 
> Perhaps it is the best to try the example above, but warn the user and
> suggest to customise the editor command.

Actually options("editor") would be in keeping with the rest of the
system conventions (and carefully avoids the shell complications). We
do already invoke the editor in a system-transparent way for
fix(code), e.g. and we also have transparent file viewers with
file.show, so maybe we should also define a file.edit function?

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list