Emacs Init: Restore Opened Files (desktop-save-mode)
emacs has desktop-save-mode
. When on, it save and restore all previously opened files in last emacs session, and also previous windows configuration (size, position, etc.)
Put this in your Emacs Init File:
;; 2023-09-16 ;; Restore Opened Files (progn (desktop-save-mode 1) ;; save when quit (setq desktop-save t) ;; no ask if crashed (setq desktop-load-locked-desktop t) (setq desktop-restore-frames t) (setq desktop-auto-save-timeout 300) ;; save some global vars (setq desktop-globals-to-save nil) ;; 2023-09-16 default ;; '(desktop-missing-file-warning tags-file-name tags-table-list search-ring regexp-search-ring register-alist file-name-history) )
Starting Emacs Without Opening Last Session's Files
To start emacs without opening last session's files, start it by:
emacs --no-desktop
This is useful when you have a corrupted desktop file.
Desktop File Path Location
By default, the temp file used by emacs to store your “desktop” status is at ~/.emacs.d/.emacs.desktop
.
The desktop file path is controlled by the variable desktop-dirname and desktop-base-file-name.