Code Monkey home page Code Monkey logo

Comments (7)

vspinu avatar vspinu commented on June 17, 2024

Torbjørn Lindahl [email protected]
on Fri, 12 Apr 2013 01:46:50 -0700 wrote:

Before I worked with R from emacs, I had a function save.work("some tag") # that
would save history and save image and create two files with timestamp and "some
tag" in their filename in a dedicated projcet sub directory.

This allowed me to load both data and history from a compiled list of
work sessions, and was a fast way to set my mental context back to
where I were when I left off.

From emacs unfurtunately savehistory is not available, what other
ways is there to achieve this?

What do you mean? All what is available from plain R is also available
from emacs R session. I am not sure I understand what you mean by
"savehistory". All the commands are recorded in local .Rhistory file and
are available for next session. See also ess-history-file variable for
other options.

It would be nice to have some simple functionality that would:

  • save a valid R-history

This is done by default by R, at least for me it happening.

  • save.image

This is achieved automatically on R's exit if you add --save argument to
R arguments. See R --help. You can a string of arguments to
inferior-R-args.

  • save the R buffer with all its content
  • label and timestamp it in a meaningful way

This is not implemented because most of the people never need it. R
buffer is just a dirty amalgamation of output/input that could (and
should) be easily reproduced from scripts. The order of commands in R
buffer is chronological and almost never match any logical flow. Most of
the time you send the same code again and again from you scripts with
different variations.

Really, R session is not important. Scripts are important. And for
those you have marvelous "timestamping" tools which are called version
control systems. If you are not using git for your projects, I highly
recommend you to do so.

In emacs you can save and restore arbitrary sessions. Just M-x
desktop-save to save the configuration in some directory. When you need
to restore it do M-x desktop-change-dir to point to the directory where
configuration was saved. This will not restore process buffers (like
R). You still have to start R manually. But once you do that, R
history should be loaded by default.

from ess.

torbjorn avatar torbjorn commented on June 17, 2024

On Fri, Apr 12, 2013 at 11:30 AM, Vitalie Spinu [email protected]:

Torbjørn Lindahl [email protected]
on Fri, 12 Apr 2013 01:46:50 -0700 wrote:

Before I worked with R from emacs, I had a function save.work("some
tag") # that
would save history and save image and create two files with timestamp
and "some
tag" in their filename in a dedicated projcet sub directory.

This allowed me to load both data and history from a compiled list of
work sessions, and was a fast way to set my mental context back to
where I were when I left off.

From emacs unfurtunately savehistory is not available, what other
ways is there to achieve this?

What do you mean? All what is available from plain R is also available
from emacs R session. I am not sure I understand what you mean by
"savehistory". All the commands are recorded in local .Rhistory file and
are available for next session. See also ess-history-file variable for
other options.

"savehistory" is a function in R, it saves command line history to a text
fila.

However from ESS:

savehistory()
Error in savehistory(file) : no history available to save

Currently I see no way in inferior R to dump command history to a text file.

It would be nice to have some simple functionality that would:

  • save a valid R-history

This is done by default by R, at least for me it happening.

Sure, me too.

  • save.image

This is achieved automatically on R's exit if you add --save argument to
R arguments. See R --help. You can a string of arguments to
inferior-R-args.

Yep, me too.

  • save the R buffer with all its content
  • label and timestamp it in a meaningful way

This is not implemented because most of the people never need it. R
buffer is just a dirty amalgamation of output/input that could (and
should) be easily reproduced from scripts. The order of commands in R
buffer is chronological and almost never match any logical flow. Most of
the time you send the same code again and again from you scripts with
different variations.

Really, R session is not important. Scripts are important. And for
those you have marvelous "timestamping" tools which are called version
control systems. If you are not using git for your projects, I highly
recommend you to do so.

Sure, ready-made R code belongs in scripts or libraries.

My question addresses those times where you have to laeve your work in the
middle of a process.

Restoring R variables and R command history makes it easy to switch back
into context when you get back, or when you ssh in from somewhere else.

Also having the same R session with output looking like when you left off,
would be great.

My point with the list was that I want a single action item (a function in
R or emacs) that will do all that. I don't want to have to assign file
names, directory names, time stamp file names, and making sure the RData
and the Rhistory file have the same name, I want the computer to do all
that.

basically something like:
M-x save-a-snapshot-of-my-brain-and-label-it
and then later:
M-x restore-from-where-i-left-off-or-let-me-chose-some-other-earlier-session

Currently I have functionality to do this in R as I explained, but I'm now
missing the savehistory possibility, that seems to be available from emacs
only in inferior R, so I will have to rewrite in lisp I suppose unless this
is easily available or someone already solved this (which is what im
fishing for).

In general, context switching is costly, it would be nice to make that
easier.

Also if I knew that I had tools to easily save "my state of mind" so to
speak, I would be more ready to dive into complex problems on a regular
basis because I would know that I wouldn't have to worry if I have an hour
of peace and quiet ahead of me or not. If interrupted for something
importand I could easily save all and later load all.

Ofcourse better discipline always help, but there is always a limit. This
functionality would for sure help me at least.

It's not important to restore the view of the R buffer too, but it would be
nice.

T

In emacs you can save and restore arbitrary sessions. Just M-x
desktop-save to save the configuration in some directory. When you need
to restore it do M-x desktop-change-dir to point to the directory where
configuration was saved. This will not restore process buffers (like
R). You still have to start R manually. But once you do that, R
history should be loaded by default.

mvh
Torbjørn Lindahl

from ess.

vspinu avatar vspinu commented on June 17, 2024

Ok I see. I was not aware of savehistory problem. Indeed, the history is
managed by ESS and comint this is why you get that error.

History is saved in local .Rhistory (by default) so you can replace
"savehistory" in your R code with something like file.copy(".Rhistory",
log_location).

And indeed, you can achieve an exact session + all buffers restoration
with appropriate elisp. Unfortunately it is not an one liner and is
quite a rare user pattern so I am afraid you will have to look into it
yourself, at least for now.

from ess.

torbjorn avatar torbjorn commented on June 17, 2024

Thanks for reply, ill come up with something

On Fri, Apr 12, 2013 at 6:49 PM, Vitalie Spinu [email protected]:

Ok I see. I was not aware of savehistory problem. Indeed, the history is
managed by ESS and comint this is why you get that error.

History is saved in local .Rhistory (by default) so you can replace
"savehistory" in your R code with something like file.copy(".Rhistory",
log_location).

And indeed, you can achieve an exact session + all buffers restoration
with appropriate elisp. Unfortunately it is not an one liner and is
quite a rare user pattern so I am afraid you will have to look into it
yourself, at least for now.


Reply to this email directly or view it on GitHubhttps://github.com//issues/38#issuecomment-16303807
.

mvh
Torbjørn Lindahl

from ess.

hwinkler avatar hwinkler commented on June 17, 2024

Another motivation for making savehistory() work from within ESS is that after crashes of Emacs, the next session has an out-of-date .Rhistory, missing the commands from the crashed session. This problem @torbjorn reported still exists.

from ess.

vspinu avatar vspinu commented on June 17, 2024

the next session has an out-of-date .Rhistory,

That's an annoying problem but it's not quite related to this pull. .Rhistory is handles by comint and not by R. Feel free to open a new issue. This should be addressed in a better way than it is now implemented.

from ess.

dwisehart avatar dwisehart commented on June 17, 2024

I agree that having savehistory() work from ESS would be a big advantage. If no one else has, I can open a new issue.

from ess.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.