[ESS] ESS and .Rhistory
Stephen Eglen
S.J.Eglen at damtp.cam.ac.uk
Sun Sep 20 00:15:54 CEST 2009
> I am using ESS 5.4, R 2.9.2, and Emacs 23. I have the following line
> in my .emacs,
>
> (setq inferior-R-args "--no-save --no-restore --quiet")
>
> If I start R from *a terminal* using the above command line, there is
> no .Rhistory file generated when calling q() from R. However, in ESS
> 5.4, I still get a .Rhistory created in the directory that R was
> started in. I have verified the R command line with commandArgs() in
> the *R* buffer in Emacs.
>
> Can anyone else replicate this? I might check a previous version of
> ESS to see if that did the same thing.
Yes I can confirm this behaviour. I guess previous versions of ESS did
this too. What is happening is that ESS creates the file .Rhistory when
the command ess-process-sentinel is run by the command:
(comint-write-input-ring)
This is because earlier, when the R buffer is created, ESS has set:
;; load past history
(setq comint-input-ring-file-name
(expand-file-name ess-history-file ess-directory))
and ess-history-file is .Rhistory; this file is created once the user
starts sending commands into *R*.
So, this counts as a bug I guess - if the user has specified --no-save
as an R command line option, then if that implies no history should be
saved, then ESS ideally should not make a history. Interactions of this
sort are hard to catch though (e.g. also in the dim past I recall
thinking about getting ESS to respect the value of R_HISTFILE but was
not sure robust or widely needed this would be).
> The other issue is that I cannot actually find any documentation in
> the R help files or manual supporting the "--no-save" option not
> writing a .Rhistory file. I thought R might have a "--no-history"
> command line option, but I cannot find any record of that either.
?Startup refers me to the 'R intro' doc, which describes --no-save
at (excuse line-breaking of URL)
http://cran.r-project.org/doc/manuals/R-intro.html
#Invoking-R-from-the-command-line
Closest switch is --no-restore-history for not reading the history file
on the way in. But note even if R had other switches preventing history
being written, as ESS does not look for these switches, the above code
will still write the history file. If these .Rhistory files are a real
pain to you, I can imagine it wouldn't be too difficult to write an ESS hook
that e.g. put the comint-input-ring-file-name to be something like
/tmp/.Rhistory at least so that it was out of the way from your home
directory. (Or even setting it to nil, if possible, so that files are
not written -- but that depends how well comint.el is written.)
Stephen
More information about the ESS-help
mailing list