[comp.emacs] Saving/Restoring state in GNU Emacs 18.55

naim@uswat.uswest.com (Naim Abdullah) (07/14/90)

I am currently using a machine that sometimes crashes and destroys
my carefully built state in GNU emacs (all the files and buffer
that I am editing). I then have to revisit all the files that
I had been editing. This gets annoying if you are editing a large
source tree.

Is there an elisp function that could save the "state" of Emacs
(say, a list of filename/buffer tuples) so that I can restore Emacs
to its former state with just one function call when I restart it ?

Thanks in advance.

     regards,
     
     Naim
     (naim@uswest.com)

baur@venice.SEDD.TRW.COM (Steven L. Baur) (07/15/90)

From article <9474@uswat.UUCP>, by naim@uswat.uswest.com (Naim Abdullah):
> I am currently using a machine that sometimes crashes and destroys
> my carefully built state in GNU emacs (all the files and buffer
> that I am editing).

What you definitely want to use is saveconf.el, but that is not much
help against system crashes (your state information doesn't get written
out).  Your best hope is to use saveconf, exit emacs periodically, and
restart it. Emacs is a marvelous program, and does many wonderful things,
but it cannot protect you completely against a system crash.  Maybe
someone wants to add code to saveconf.el to periodically write out window
state?

--
steve	baur@venice.SEDD.TRW.COM

briscoe-duke@CS.YALE.EDU (Duke Briscoe) (07/15/90)

In article <668@venice.SEDD.TRW.COM> baur@venice.SEDD.TRW.COM (Steven L. Baur) writes:
>From article <9474@uswat.UUCP>, by naim@uswat.uswest.com (Naim Abdullah):
>> I am currently using a machine that sometimes crashes and destroys
>> my carefully built state in GNU emacs (all the files and buffer
>> that I am editing).
>
>What you definitely want to use is saveconf.el, but that is not much
>help against system crashes (your state information doesn't get written
>out).  Your best hope is to use saveconf, exit emacs periodically, and
                                           ^^^^^^^^^^^^^^^^^^^^^^^
>restart it. Emacs is a marvelous program, and does many wonderful things,
>but it cannot protect you completely against a system crash.  Maybe
>someone wants to add code to saveconf.el to periodically write out window
>state?
>
>--
>steve	baur@venice.SEDD.TRW.COM


You don't have to exit GNU emacs to get the saveconf.el code to save
your buffer configuration.  Just use the command save-context.  This
command writes out a file which tells what files you were looking at,
and what point in the files.  The command recover-context will read in
all the files and put point back where it was.  I've occasionally
found it useful to rename the saved info file as a way of documenting
all the relevant files of some project I'm working on.  This is useful
for a large project, particularly reading someone else's code, when I
might go back to working on that stuff after doing other things for a
few months.

Duke

kjones@talos.pm.com (Kyle Jones) (07/17/90)

Naim Abdullah:
 > I am currently using a machine that sometimes crashes and destroys
 > my carefully built state in GNU emacs (all the files and buffer
 > that I am editing).

Steven L. Baur writes:
 > What you definitely want to use is saveconf.el, but that is not much
 > help against system crashes (your state information doesn't get written
 > out).  Your best hope is to use saveconf, exit emacs periodically, and
 > restart it.

As someone recently posted, you needn't exit, just "M-x save-context".

 > [...] Maybe someone wants to add code to saveconf.el to periodically
 > write out window state?

No need.  Get a copy of my timer package, which consists of:

    timer.el: a library of Lisp functions that implement and
              support general purpose interval timers for GNU
              Emacs;
    timer.c : a small C program that accesses the system clock.

It's probably in the OSU archives and I can send it directly to
those without access.

With the timer package installed you can say

  (start-timer "context-auto-save" 'save-context 300 300)

in your .emacs file to cause window contexts to be saved every five
minutes.  Put:

  (setq save-buffer-context t)

in your .emacs also if you want the contexts of all buffers
saved, otherwise you will just get only those buffers that have
a window.

piet@cs.ruu.nl (Piet van Oostrum) (07/20/90)

It would be nice if emacs could call save-context after auto-saving. Maybe
a next version can have a hook for this.
-- 
Piet* van Oostrum, Dept of Computer Science, Utrecht University,
Padualaan 14, P.O. Box 80.089, 3508 TB Utrecht, The Netherlands.
Telephone: +31-30-531806   Uucp:   uunet!mcsun!ruuinf!piet
Telefax:   +31-30-513791   Internet:  piet@cs.ruu.nl   (*`Pete')

kjones@talos.pm.com (Kyle Jones) (07/23/90)

Piet van Oostrum writes:
 > It would be nice if emacs could call save-context after auto-saving. Maybe
 > a next version can have a hook for this.

A hook into the auto-save code would be a good thing, indeed.
crypt.el could use such a hook to insure that crypted, compressed,
etc. files are auto-saved using their proper encodings.