[comp.emacs] concerning gnu emacs backup files

ramsey@PURDUE.EDU (Ed Ramsey) (01/04/87)

I would like to create a directory /usr/ramsey/.gnubackup and have
gnu emacs store all tilde and #*# files there.

It is becomming very tiresome to have to delete all of the tilde and
pound files everytime I leave a source directory.

In an environment I once worked in, you could specify a  backup directory
that the editor would use to store all backups.  This would be a nice idea 
for gnu emacs.

I realize that If you edit several different Makefiles that only the last
one would be backed up, but generally that is all the longevity that is of
interest (at least for me), especially if a shop uses RCS or SCCS and isn't
trying to use the backups as a revision information tool.

I read the manual and saw no easy hooks for doing this.  Is this do-able
in a reasonably straightforward fashion?  Has someone solved this problem
in a different way? (perhaps not a problem, but an irritation).

-Ed

jkf@ucbarpa.berkeley.edu@ficl.UUCP (John Foderaro) (01/04/87)

 As an alternative to putting backup files in a ~/.gnubackup
directory, I'd like to suggest that you try these two ideas:
 1. make the backup filenames begin with '.#' and the checkpoint
    filenames begin with '.##'.   This makes these files invisible
    unless you use 'ls -a' and thus they aren't as bothersome to keep
    around.

 2. add a line to /usr/lib/crontab (or else use 'at' if you aren't a 
    superuser) which daily checks for out of date backup and
    checkpoint files and removes them.  The crontab entry
    I use looks like this:
			this is the clause that looks for gnumacs backups
							    |
							    v
40 4 * * * find / '(' -name '#*' -o -name '*.CKP' -o -name '.#*' ')' -a -atime +3 -a -exec rm -f {} ';'
  
 

-john foderaro

rms@PREP.AI.MIT.EDU (Richard M. Stallman) (01/05/87)

The purpose of backup files is to stay around for a while so you can
back out of mistakes.  Backup files are not out of date until months
have gone by and it is no longer likely you will come across a bug.

If you don't like this feature, just turn it off.  Set
make-backup-files to nil.

Making find delete everyone's backup files is horrible!  Even if you
don't want backup files, someone else on the system probably does.
Just delete your own.

roy@phri.UUCP (Roy Smith) (01/05/87)

rms@PREP.AI.MIT.EDU (Richard M. Stallman) writes:
> Backup files are not out of date until months have gone by and it is no
> longer likely you will come across a bug. [...] Making find delete
> everyone's backup files is horrible!  Even if you don't want backup
> files, someone else on the system probably does.  Just delete your own.

	From a purely theoretical standpoint, I agree.  On the other hand,
I'm the guy who buys the disk drives, and I'm the guy people complain to
when we run out of space.  Because of this, I'm also the guy who runs "du"
every few days and chases after disk hogs, and who runs "find" every night
to delete backup files more than 2 weeks old (access time).

	Our 2 Sun file servers happen to have a lot of free space so I
don't delete backup files on them.  I just found (finded?) all the backup
files on those systems and came up with:

    Size   Used         Total Backups       Old Backups (atime > 14 days)

    97 Mb  76%    390 files = 2.8 Mb (2.9%)   338 files = 2.5 Mb (2.6%)
    89 Mb  52%    579 files = 3.9 Mb (4.4%)   425 files = 3.9 Mb (3.7%)

	Actually, I'm surprised that the numbers are that low -- I expected
more like 25% wastage (by which I mean space devoted to backup files; maybe
"wastage" is too biased a word).  What that really says is that most of the
files on disk don't get used very often, something I knew already.  At any
rate, Our Vax typically has its 200 Mbyte user partition 95% full, so the
3-4% I save by trashing old backup files really helps.  I hate to think how
much space is wasted on TOPS-20 systems that save 3-4 versions of every
file (I know, I know, you can make emacs do this on unix as well (and not
save them on TOPS-20), but it's not the default so most people don't).

	For what it's worth, since backup files get deleted only after 2
weeks, they are guaranteed to make it onto a weekly dump tape which gets
kept for at least a month.  Thus, a backup file is really available for
something like 6 weeks.  For longer-term recovery of past versions, we rely
on our daily/weekly/monthly/quarterly tape dump schedule.  Disk space is
still too valuable to waste keeping extra copies of every file around for
eternity.  Maybe when dollar-a-megabyte, Gbyte capacity, fast R/W disks
become available I'll change my mind.
-- 
Roy Smith, {allegra,cmcl2,philabs}!phri!roy
System Administrator, Public Health Research Institute
455 First Avenue, New York, NY 10016

"you can't spell deoxyribonucleic without unix!"

king@KESTREL.ARPA (Dick King) (01/05/87)

   Date: Sun, 04 Jan 87 09:50:05 EST
   From: Ed Ramsey <ramsey@purdue.edu>

   I would like to create a directory /usr/ramsey/.gnubackup and have
   gnu emacs store all tilde and #*# files there.

   It is becomming very tiresome to have to delete all of the tilde and
   pound files everytime I leave a source directory.

   In an environment I once worked in, you could specify a  backup directory
   that the editor would use to store all backups.  This would be a nice idea 
   for gnu emacs.

   I realize that If you edit several different Makefiles that only the last
   one would be backed up, but generally that is all the longevity that is of
   interest (at least for me), especially if a shop uses RCS or SCCS and isn't
   trying to use the backups as a revision information tool.

   I read the manual and saw no easy hooks for doing this.  Is this do-able
   in a reasonably straightforward fashion?  Has someone solved this problem
   in a different way? (perhaps not a problem, but an irritation).

   -Ed


   From: franz!ficl!jkf@ucbarpa.berkeley.edu (John Foderaro)
   Date: Sun, 04 Jan 87 11:28:08 PST

    As an alternative to putting backup files in a ~/.gnubackup
   directory, I'd like to suggest that you try these two ideas:
    1. make the backup filenames begin with '.#' and the checkpoint
       filenames begin with '.##'.   This makes these files invisible
       unless you use 'ls -a' and thus they aren't as bothersome to keep
       around.

    2. add a line to /usr/lib/crontab (or else use 'at' if you aren't a 
       superuser) which daily checks for out of date backup and
       checkpoint files and removes them.  The crontab entry
       I use looks like this:
			   this is the clause that looks for gnumacs backups
							       |
							       v
   40 4 * * * find / '(' -name '#*' -o -name '*.CKP' -o -name '.#*' ')' -a -atime +3 -a -exec rm -f {} ';'



   -john foderaro



(setq delete-auto-save-files t) should clean your #*# files.  If it
doesn't, report a bug.

The *.~*~ files are serious business, and should not be deleted as a
matter of routine.  I have used backup files as much as a year later.
If a particular file is not serious business, you can set
buffer-backed-up to t for that file['s buffer] in its local variables.
(-: we have a file-precious flag -- perhaps we need a file-worthless
flag :-) You can also reduce the number of *.~*~ files [and make them
just *~ files] by setting version-control to never.  [I actually
recommend a value of nil, if you really resent multiple backups,
because this will cause files that already have numeric backups to
continue to have them, allowing you a file-by-file choice.]



I for one would be VERY UPSET if i worked at a site where the
superuser made such a serious decision for me as "you can't count on
backups being around for more than three days".  I would probably
change the format of my backups to avoid the automatic deletion,
although i would tolerate [and even recommend, perhaps] automatic
compression. 

-dick

shaddock@mcnc.org@rti-sel.UUCP (Mike Shaddock) (01/05/87)

	From @prep.ai.mit.edu:king@KESTREL.ARPA Mon Jan  5 14:35:36 1987
	Received: from mcnc.mcnc.org (mcnc) by rti-sel (4.12/4.7)
		id AA07127; Mon, 5 Jan 87 14:34:38 est
	Received: from RELAY.CS.NET by mcnc.mcnc.org (5.54/MCNC/1-2-87)
		id AA22961; Mon, 5 Jan 87 14:24:20 EST
	Received: from prep.ai.mit.edu by RELAY.CS.NET id aa03853; 5 Jan 87 14:05 EST
	Received: by prep.ai.mit.edu; Mon, 5 Jan 87 13:58:01 EST
	Received: by kestrel.ARPA (4.12/4.9)
		id AA21042; Mon, 5 Jan 87 10:56:40 pst
	Date: Mon, 5 Jan 87 10:56:40 pst
	From: Dick King <king@kestrel.arpa>
	Message-Id: <8701051856.AA21042@kestrel.ARPA>
	To: ramsey@purdue.edu
	Cc: info-gnu-emacs@prep.ai.mit.edu
	In-Reply-To: Ed Ramsey's message of Sun, 04 Jan 87 09:50:05 EST <8701041450.AA08983@arthur.cs.purdue.edu>
	Subject: concerning Gnu Emacs backup files
	
	
	   Date: Sun, 04 Jan 87 09:50:05 EST
	   From: Ed Ramsey <ramsey@purdue.edu>
	
	   I would like to create a directory /usr/ramsey/.gnubackup and have
	   gnu emacs store all tilde and #*# files there.
	   <rest of letter deleted for compactness>
	
	   From: franz!ficl!jkf@ucbarpa.berkeley.edu (John Foderaro)
	   Date: Sun, 04 Jan 87 11:28:08 PST
	
	    As an alternative to putting backup files in a ~/.gnubackup
	   directory, I'd like to suggest that you try these two ideas:
	   <rest of letter deleted for compactness>
	
	
	(setq delete-auto-save-files t) should clean your #*# files.  If it
	doesn't, report a bug.

	.
	.
	.
	
	I for one would be VERY UPSET if i worked at a site where the
	superuser made such a serious decision for me as "you can't count on
	backups being around for more than three days".  I would probably
	change the format of my backups to avoid the automatic deletion,
	although i would tolerate [and even recommend, perhaps] automatic
	compression. 
	
	-dick
	
I am planning on automagically deleting backup files at my site simply
because we, like most sites, have only X amount of disk storage.
However, we do daily backups, so any file more than three days old
would be on two or three backup tapes before it was deleted.

jkf@ucbarpa.berkeley.edu@ficl.UUCP (John Foderaro) (01/06/87)

 I'd suggest that anyone concerned with keeping backups of files use
one of the source code control systems (I like 'rcs' but 'sccs' will
do).   These allow you to keep multiple backups (with little additional
cost per backup).  But more importantly, they allow you to decide when
a backup should be done.    Emacs does one backup of a file per
editing session (plus one checkpoint file), thus if your editing
session lasts over a week or so (it is not uncommon to keep a single
emacs running for a week), then you end up with very little history of
the changes you made.  Or, if you are the type that starts up emacs
each time you want to make a single change to a file, then you either
have hundreds of backup files for a single file or else you have just
a few backup files which show only very recent history.

 [I'm not trying to start a discussion on this topic on this mailing
  list since it is the wrong place for it and most people probably don't
  care one way or the other.   I promise to not to write anything more
  about this topic to info-gnu-emacs]

-john foderaro

king@KESTREL.ARPA (Dick King) (01/06/87)

   Date: Mon, 5 Jan 87 15:54:42 est
   From: Mike Shaddock <rti-sel!shaddock@mcnc.org>

   I am planning on automagically deleting backup files at my site simply
   because we, like most sites, have only X amount of disk storage.
   However, we do daily backups, so any file more than three days old
   would be on two or three backup tapes before it was deleted.

Suggest you at least leave a little stub telling what tape(s) it's on.

I would hate to have to ask my sysop "could you pull the most recent
foo.baz.~x~ off the tape?  I don't know what x is, but i think it's in
June or July."

-dick

wohler@SPAM.ISTC.SRI.COM (Bill Wohler) (01/06/87)

folks,

  i'm afraid this discussion is getting a bit too religious for this
  alias.

  i believe that emacs, as it is, does the right thing.  it is
  flexible enough to let you have one backup, numbered backups, or no
  backups at all.  the removal of backups should be, and is (except
  for outdated numbered backups), left up to the user or system
  manager (with the concurrence of his users).

  may i recommend RCS to those of you that use numbered backups.  RCS
  keeps all of your versions in one tidy place, complete with
  descriptions of the changes.  using RCS allows you to eliminate
  superfluous numbered backups and ChangeLogs which results in faster
  directory listings and less disk usage.

  i have not told you what i do with backup files--it is not relevant
  to this discussion or alias.

						--bw

peck@SUN.COM (Jeff Peck) (01/06/87)

another misunderstanding of the distinction between Backup and Archive:

Backups are created to protect against system crashes, they rightfully
 should be routinely deleted.

Archives (versions) are created to protect against changing our mind.
 Any sysop that attempts to maintain or destroy archives automatically
 is looking for an ulcer or lawsuit respectively.

inc@tc.fluke.COM (Gary Benson) (01/06/87)

I also hated cleaning up behind emacs, (this is a Gosling, not a Gnu). In
this rendition, the backup files are created after a certain number of
keystrokes, which is able to be preset in the .emacs_pro file. Here's what
mine looks like:


(setq-default checkpoint-frequency 50000)  ; create a #C* file every 50K


If 50,000 keystrokes is *still* too many, tyr 90,000. You'll NEVER see an
automatically created file again.

If Gnu does not use "checkpoint-frequency" or a .emacs_pro, there is still
another way to skin this particular cat. You can use the unix programs "cron"
and "find" to search out the offending files on a regular basis (like
nightly) and zap 'em. Hope that helps.














-- 
 Gary Benson  *  John Fluke Mfg. Co.  *  PO Box C9090  *  Everett WA  *  98206
   MS/232-E  = =   {allegra} {uw-beaver} !fluke!inc   = =   (206)356-5367
 _-_-_-_-_-_-_-_-ascii is our god and unix is his profit-_-_-_-_-_-_-_-_-_-_-_ 

rms@PREP.AI.MIT.EDU (Richard M. Stallman) (01/06/87)

GNU Emacs backups are not for protection against system crashes.
Auto save files are what serve that purpose in GNU Emacs.
Backup files are for protection against making a change
that causes trouble at a later date.  RCS is also used
for that purpose.

ron@brl-sem.ARPA (Ron Natalie <ron>) (01/06/87)

In article <8701052223.AA10276@denali.sun.com>, peck@SUN.COM (Jeff Peck) writes:
>  Any sysop that attempts to maintain or destroy archives automatically
>  is looking for an ulcer or lawsuit respectively.
                              ???????

Give me a break.  I am more and more convinced that EMACS atrophies the
mind.

-Ron

greg@nosc.arpa@vis.UUCP (01/09/87)

	Date: Sun, 4 Jan 87 22:07:48 EST
	From: nosc!rms@prep.ai.mit.edu (Richard M. Stallman)
	To: info-gnu-emacs@prep.ai.mit.edu
	In-Reply-To: John Foderaro's message of Sun, 04 Jan 87 11:28:08 PST
	Subject: concerning Gnu Emacs backup files 

	The purpose of backup files is to stay around for a while so you can
	back out of mistakes.  Backup files are not out of date until months
	have gone by and it is no longer likely you will come across a bug.

How can this be?  If I make major changes to a file, then go back and put
in a missing semicolon, the interesting backup is lost.  Only a backup
system with version numbers or an RCS-like change file can really give
you the kind of capability you describe.  Unfortunately, numbered backups
use too much storage and running RCS takes too much time.

I'm not familiar with the code for undoing, but would it be difficult to
write (or append) the changes to a file, as an alternative to the current
arrangement of keeping the changes in memory and a single backup file
on disk?


_Greg


J. Greg Davidson			  Virtual Infinity Systems
+1 (619) 452-8059        6231 Branting St; San Diego, CA 92122 USA
 
greg@vis.uucp				ucbvax--| telesoft--|
vis!greg@nosc.arpa			decvax--+--sdcsvax--+--vis
vis!greg@sdcsvax.ucsd.edu		 ihnp4--|  noscvax--|

king@KESTREL.ARPA (Dick King) (01/10/87)

   From: vis!greg@nosc.arpa
   Return-Receipt-To: vis!greg@nosc.arpa
   Date: 09 Jan 87 12:38:42 PST (Fri)


	   Date: Sun, 4 Jan 87 22:07:48 EST
	   From: nosc!rms@prep.ai.mit.edu (Richard M. Stallman)
	   To: info-gnu-emacs@prep.ai.mit.edu
	   In-Reply-To: John Foderaro's message of Sun, 04 Jan 87 11:28:08 PST
	   Subject: concerning Gnu Emacs backup files 

	   The purpose of backup files is to stay around for a while so you can
	   back out of mistakes.  Backup files are not out of date until months
	   have gone by and it is no longer likely you will come across a bug.

   How can this be?  If I make major changes to a file, then go back and put
   in a missing semicolon, the interesting backup is lost.  

That's why i put in kept-new-versions as well as kept-old-versions.
When you develop affection for a version you delete enough old
versions so the treasured version is one of the kept-old-version
oldest ones.  If you decide you want to keep a third version [assuming
kept-old-versions is 2, the default] you either must throw out one or
change kept-old-versions [possibly for versions of that file only, in
a local variable].

   _Greg

-dick

ramsey@PURDUE.EDU.UUCP (04/04/87)

Several months ago I started (unintentionally) a rather long
discussion concerning gnu emacs backups.

My intent was to discover a reliable way of placing all of my backup
files into a single dedicated backup directory.  This would allow me
to use the gnu emacs backup capabilities, without running afoul of my
systems administrator, who frowns on backup files in the systems
directories (Dan, smile!).

The most useful response to my query was from Neil Smithline, and it
solved my problem (Thanks, Neil!). 

I am enclosing his code, and a few other items that might be useful:

	* simple file name completion for the shell
	* routines that save and restore the screen environment
	* a routine for mh-rmail that toggles in and out of mh-rmail
	  by saving and restoring the screen environment, so that I
	  can read mail at anytime, without having to re-build my
	  screen when I exit mail.
	* keymap translation table routine to support xon/xoff

This code runs under Mt. Xinu 4.3 NFS on Vaxen, and Sun 3.2 on Suns.
I use Gnu Emacs Version 18.38.2. I haven't tried it on anything else.

-Ed

Ed Ramsey                      ramsey@cs.purdue.edu                  ARPA
Computer Science Department    ramsey%purdue.edu@relay.cs.net        CSNET
Purdue University              {ucbvax,decvax,ihnp4}!purdue!ramsey   UUCP
West Lafayette, IN 47907       (317) 494-6002                        PHONE


;; .emacs  last modified: Sat Apr  4 11:39:21 EST 1987
;;                        (to add comments :-)
;;
;; I use a wyse 60 at 19200 baud from an encore annex.  The wyse 60 is
;; a mixed blessing.  It allows 43 lines on the screen (which is a
;; real win), but is slow enough to require flow control above 4800
;; baud.  Hardware flow control doesn't work (at least for us) on the
;; annex, so I use xon/xoff (about which RMS has made many choice
;; comments :-).  If encore ever make hardware flow control work, then
;; the xon/xoff can go away, and I can run at 38400!
;;
;; set up to work with xon/xoff flow control.
;; 1) enable xon/xoff
(set-input-mode nil t)
;; 2) set up translate table to remap C-s and C-q (also C-h and DEL)
(let ((the-table (make-string 128 0)))
  (let ((i 0))
    (while (< i 128)
      (aset the-table i i)
      (setq i (1+ i))))
;; Swap C-h with DEL (personal preference). This makes DEL the help key.
;; the next two lines can be commented out if you like to use DEL for delete
  (aset the-table ?\177 ?\^h)
  (aset the-table ?\^h ?\177)
;; Swap ^S with ^\
  (aset the-table ?\^\\ ?\^s)
  (aset the-table ?\^s ?\^\\)
;; Swap ^Q with ^^
  (aset the-table ?\^^ ?\^q)
  (aset the-table ?\^q ?\^^)
  (setq keyboard-translate-table the-table))
;;
;; miscellaneous
(setq inhibit-startup-message t)
(setq text-mode-hook 'turn-on-auto-fill)
(setq list-directory-verbose-switches "-Flag")
(setq c-auto-newline t)
(setq c-indent-level 4)
(setq c-continued-statement-offset 4)
(setq display-time-interval 10)
(display-time)
(defvar TeX-dvi-print-command "dvipr -r")
;;
;; keys
(global-set-key "\C-x\C-e" 'compile)
(global-set-key "\C-x\C-m" 'set-mark-command)
(global-set-key "\eg" 'goto-line)
(global-set-key "\C-xn" 'rnews)
;;
;; backups
;;
;; backup-by-copying is needed so that system files aren't changed to
;; be owned by me.
(setq backup-by-copying t)
;;
;; From: Neil Gordon Smithline <neil%buffalo.csnet@relay.cs.net>
;; Date: Tue, 20 Jan 87 14:41:16 EST
;; modified by ramsey@purdue.edu to fit my requirements :-)
;; this code causes *all* backups to be stored in my backup directory.  The
;; advantage of this is that I have the security of backups, without leaving
;; backup files all over the system.
;;
;; ** this is the only line that needs to be changed **
(defvar backup-file-prefix "/usr/ramsey/.gnubackups/"
  "*Prefix to prepend to all backup filenames and auto-save filenames.")
;;
(defun make-backup-file-name (file)
  "Create the non-numeric backup file name for FILE.
This function differs from the standard version in that it includes the
`backup-file-prefix'."
  (concat (file-name-directory file)
	  backup-file-prefix
	  (file-name-nondirectory file)
	  "~"))
;;
(defun make-auto-save-file-name ()
  "Return file name to use for auto-saves of current buffer.
Does not consider auto-save-visited-file-name; that is checked
before calling this function.
You can redefine this for customization.
See also auto-save-file-name-p."
  (if buffer-file-name
      (concat (file-name-directory buffer-file-name)
	      backup-file-prefix
	      "#"
	      (file-name-nondirectory buffer-file-name)
	      "#")
    (expand-file-name (concat "#%" (buffer-name) "#"))))
;;
(defun auto-save-file-name-p (filename)
  "Return t if FILENAME can be yielded by make-auto-save-file-name.
FILENAME should lack slashes.
You can redefine this for customization."
  (string-match (concat "^" backup-file-prefix "#.*#$") filename))
;;
(defun find-backup-file-name (fn)
  "Find a file name for a backup file, and suggestions for deletions.
Value is a list whose car is the name for the backup file
 and whose cdr is a list of old versions to consider deleting now."
  (if (eq version-control 'never)
      (list (make-backup-file-name fn))
    (let* ((base-versions (file-name-nondirectory (make-backup-file-name fn)))
	   (bv-length (length base-versions))
	   (possibilities (file-name-all-completions
			   base-versions
			   (file-name-directory fn)))
	   (versions (sort (mapcar 'backup-extract-version possibilities)
			   '<))
	   (high-water-mark (apply 'max (cons 0 versions)))
	   (deserve-versions-p
	    (or version-control
		(> high-water-mark 0)))
	   (number-to-delete (- (length versions)
				kept-old-versions kept-new-versions -1)))
      (if (not deserve-versions-p)
	  (list (make-backup-file-name fn))
	(cons (concat (make-backup-file-name fn) (int-to-string (1+ high-water-mark)) "~")
	      (if (> number-to-delete 0)
		  (mapcar (function (lambda (n)
			      (concat (make-backup-file-name fn) (int-to-string n) "~")))
			  (let ((v (nthcdr kept-old-versions versions)))
			    (rplacd (nthcdr (1- number-to-delete) v) ())
			    v))))))))
;;
;; set up a shell
(shell)
;; rename it now (so I don't have to rename it later if I want two shells)
(rename-buffer "sh1")
;; (regexp must have changed because "popd|po" doesn't work anymore)
(defvar shell-popd-regexp "po")
(defvar shell-pushd-regexp "pu")
;;
;; set up file name completion (not bsd, but useful and simple)
;; (I don't remember the name of the person who sent this to me)
(define-key shell-mode-map "\C-c\C-f" 'insert-file-name-with-completion)
(defun insert-file-name-with-completion (name)
  "Prompts for a file or directory name and inserts that name after point.
The name may be non-existent.  Useful in Shell mode."
  (interactive "FInsert file name: ")
  (insert  name))
;;
;; date function (useful for logging times in job notes, etc ...)
(defun current-date-and-time ()
  "Insert the current date and time (as given by UNIX date) at dot."
  (interactive)
  (call-process "date" nil t nil))
(global-set-key "\C-xt" 'current-date-and-time)
;;
;; functions to save/restore current screen environment
;; *real* useful if you have 40 to 80 line screens with a lot of windows
;; and you want to jump into a package (like mh) that doesn't save your
;; current layout.  One of these days (:-) I will implement ring buffers.
(setq screen-saved nil)
(defun screen-config-save ()
  "Save the current screen configuration."
  (interactive)
  (setq screen-config (current-window-configuration))
  (message "Current Screen Configuration Saved")
  (setq screen-saved t))
;;
(defun screen-config-restore ()
  "Restore the screen configuration last saved."
 (interactive)
 (message "Last Saved Screen Configuration Restored")
 (if (eq screen-saved 't)
     (set-window-configuration screen-config)
   (message "Unable to Restore Screen Configuration"))
 (setq screen-saved nil))
;;
(global-set-key "\C-cS" 'screen-config-save)
(global-set-key "\C-cR" 'screen-config-restore)
;;
;; mh mail
(setq mh-summary-height 5)
(setq mh-ins-buf-prefix "  >> ")
;; screen save/restore tied to mh-rmail
;; I set this up so that C-x m toggled the mh environment.  the first C-x m
;; saves the current configuration and drops you into mh-rmail.  The second
;; C-x m restores the last saved state of the screen.  A sentinel of
;; some kind is needed, because if you try to restore before you save,
;; gnu emacs dumps core, and trashes your shell!
(setq screen-saved-mh nil)
(defun screen-config-save-mh ()
  "Save the current screen configuration."
  (interactive)
  (setq screen-config-mh (current-window-configuration))
  (setq screen-saved-mh t))
;;
(defun screen-config-restore-mh ()
  "Restore the screen configuration last saved."
 (interactive)
 (if (eq screen-saved-mh 't)
     (set-window-configuration screen-config-mh))
 (setq screen-saved-mh nil))
;;
(global-set-key "\C-xm" 'mh-frontend-rmail)
(defun mh-frontend-rmail ()
  "Save screen and go to mh."
  (interactive)
  (screen-config-save-mh)
  (global-set-key "\C-xm" 'mh-exit-rmail)
  (mh-rmail))
;;
(defun mh-exit-rmail ()
  "restore screen and exit mh."
  (interactive)
  (screen-config-restore-mh)
  (global-set-key "\C-xm" 'mh-frontend-rmail))
;;
;;
;; end