savehistory directories and quitting R (PR#2038)

ripley@stats.ox.ac.uk ripley@stats.ox.ac.uk
Mon, 14 Oct 2002 14:30:35 +0100 (BST)


This is not a bug. If you override a system function, you can't expect it
to be used by R internals.  Indeed, as from 1.6.0 you can't even expect it
to be used by R's base functions, due to namespaces.

There are very good reasons for the internal quit code not to call user's
R code, the main one being that R errors will not be handled then.
.Last is made available as a hook to enable you to do what you want:
as the help page says.

Doesn't setting R_HISTFILE do this for you automatically? Just set
R_HISTFILE="D:/R50/.Rhistory" and the history should be loaded and saved
to the specified place.  Works under Unix, at least.



On Thu, 19 Sep 2002 Mark.Bravington@csiro.au wrote:

> #
> #       r-bugs@r-project.org
> #
> ######################################################
>
> Because I work in different directories, but always want to save my
> .Rhistory in the same place, I have changed the system function savehistory
> to this:
>
> function (file = "D:/R50/.Rhistory")
> invisible(.Internal(savehistory(file)))
>
> When I use q() to quit R, and it asks me whether I want to "save current
> workspace", a response of YES means that the .Rhistory is saved in the
> current working directory, rather than D:/R50/.Rhistory. I take this to mean
> that the quit-on-prompt sequence makes a direct call to .Internal(
> savehistory...) rather than going via the actual savehistory() function. It
> would be nicer if prompt-on-quit would honour the user's definition of
> savehistory.

Actually it talks directly to the GUI-specific history mechanism.

> (Responding NO to the "save current..." prompt means that .Rhistory isn't
> saved at all, which is reasonable.)
>
> I admit that this is a very minor bug, because I can set .Last to call
> savehistory directly. But I just thought you should know...
>
> cheers
> Mark
>
>
> *******************************
>
> Mark Bravington
> CSIRO (CMIS)
> PO Box 1538
> Castray Esplanade
> Hobart
> TAS 7001
>
> phone (61) 3 6232 5118
> fax (61) 3 6232 5012
> Mark.Bravington@csiro.au
>
>
> --please do not edit the information below--
>
> Version:
>  platform = i386-pc-mingw32
>  arch = i386
>  os = mingw32
>  system = i386, mingw32
>  status =
>  major = 1
>  minor = 5.0
>  year = 2002
>  month = 04
>  day = 29
>  language = R
>
> Windows 2000 Professional (build 2195) Service Pack 2.0
>
> Search Path:
>  .GlobalEnv, package:handy, package:debug, mvb.session.info,
> package:mvbutils, package:tcltk, Autoloads, package:base
>
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-devel 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-devel-request@stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>

-- 
Brian D. Ripley,                  ripley@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-devel 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-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._