You can use the Desktop library to save the state of Emacs from one session to another. Saving the state means that Emacs starts up with the same set of buffers, major modes, buffer positions, and so on that the previous Emacs session had.
To use Desktop, you should first add these lines to your `.emacs' file, preferably at or near the end:
(load "desktop") (desktop-load-default) (desktop-read)
Then, to enable state saving in a particular Emacs session, use the command M-x desktop-save. Once you have done this, the state of this Emacs session will be saved when you exit Emacs.
In order for Emacs to recover the state from a previous session, you must start it with the same current directory as you used when you started the previous session.
desktop-files-not-to-save controls which files are
excluded from state saving. Its value is a regular expression that
matches the files to exclude. By default, remote (ftp-accessed) files
are excluded; this is because visiting them again in the subsequent
session would be slow. If you want to include these files in state