view lisp/packages/session.el @ 9:6f2bbbbbe05a

Added tag r19-15b5 for changeset 4b173ad71786
author cvs
date Mon, 13 Aug 2007 08:47:36 +0200
parents 376386a54a3c
children
line wrap: on
line source

;;; Synched up with: Not in FSF.
;;; #### Chuck -- I think we should remove this.  It's dumb and stupid
;;; and there are at least two other packages we provide that do the
;;; same thing.

(setq kill-emacs-hook
      '(save-session))

;; Record in `/.emacs-session' a command to re-visit the last file
;; that was being looked at.
(defun save-session ()
  (and buffer-file-name
       (write-region
	(concat "(" (if (eq major-mode 'rmail-mode)
			"rmail"
		      "find-file")
		" " (if (string= (concat (getenv "HOME") "/RMAIL")
				 buffer-file-name)
			;; Omit the file name if it is the primary rmail file
			;; to cause the default inboxes to be used.
			""
		      (prin1-to-string buffer-file-name))
		")\n"
		"(goto-char " (prin1-to-string (window-start)) ")\n"
		"(beginning-of-line)\n"
		"(set-window-start (selected-window) (point))\n"
		"(goto-line "
		(prin1-to-string (1+ (count-lines 1 (point))))
		")\n")
	nil (expand-file-name "~/.emacs-session")
	;; Don't print a message.
	nil 'lambda)))

;; Restore previous saved session, if there is one.
(load "~/.emacs-session" t t)