elisp: Desktop Save Mode
22.8 Desktop Save Mode
======================
“Desktop Save Mode” is a feature to save the state of Emacs from one
session to another. The user-level commands for using Desktop Save Mode
are described in the GNU Emacs Manual ((emacs)Saving Emacs
Sessions). Modes whose buffers visit a file, don’t have to do
anything to use this feature.
For buffers not visiting a file to have their state saved, the major
mode must bind the buffer local variable ‘desktop-save-buffer’ to a
non-‘nil’ value.
-- Variable: desktop-save-buffer
If this buffer-local variable is non-‘nil’, the buffer will have
its state saved in the desktop file at desktop save. If the value
is a function, it is called at desktop save with argument
DESKTOP-DIRNAME, and its value is saved in the desktop file along
with the state of the buffer for which it was called. When file
names are returned as part of the auxiliary information, they
should be formatted using the call
(desktop-file-name FILE-NAME DESKTOP-DIRNAME)
For buffers not visiting a file to be restored, the major mode must
define a function to do the job, and that function must be listed in the
alist ‘desktop-buffer-mode-handlers’.
-- Variable: desktop-buffer-mode-handlers
Alist with elements
(MAJOR-MODE . RESTORE-BUFFER-FUNCTION)
The function RESTORE-BUFFER-FUNCTION will be called with argument
list
(BUFFER-FILE-NAME BUFFER-NAME DESKTOP-BUFFER-MISC)
and it should return the restored buffer. Here DESKTOP-BUFFER-MISC
is the value returned by the function optionally bound to
‘desktop-save-buffer’.