[R] calling an editor on MAC and Linux
ripley@stats.ox.ac.uk
ripley at stats.ox.ac.uk
Fri Jun 14 11:33:27 CEST 2002
On 14 Jun 2002, Peter Dalgaard BSA wrote:
> 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?
It's called edit() as used by fix()! file.edit() could just be a
different interface to edit.default, I suppose.
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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