home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / lucid / lemacs-19.6 / lisp / packages / session.el < prev    next >
Encoding:
Text File  |  1992-06-29  |  900 b   |  31 lines

  1. (setq kill-emacs-hook
  2.       '(save-session))
  3.  
  4. ;; Record in `/.emacs-session' a command to re-visit the last file
  5. ;; that was being looked at.
  6. (defun save-session ()
  7.   (and buffer-file-name
  8.        (write-region
  9.     (concat "(" (if (eq major-mode 'rmail-mode)
  10.             "rmail"
  11.               "find-file")
  12.         " " (if (string= (concat (getenv "HOME") "/RMAIL")
  13.                  buffer-file-name)
  14.             ;; Omit the file name if it is the primary rmail file
  15.             ;; to cause the default inboxes to be used.
  16.             ""
  17.               (prin1-to-string buffer-file-name))
  18.         ")\n"
  19.         "(goto-char " (prin1-to-string (window-start)) ")\n"
  20.         "(beginning-of-line)\n"
  21.         "(set-window-start (selected-window) (point))\n"
  22.         "(goto-line "
  23.         (prin1-to-string (1+ (count-lines 1 (point))))
  24.         ")\n")
  25.     nil (expand-file-name "~/.emacs-session")
  26.     ;; Don't print a message.
  27.     nil 'lambda)))
  28.  
  29. ;; Restore previous saved session, if there is one.
  30. (load "~/.emacs-session" t t)
  31.