I would like to use a standard desktop save file when using Emacs as a server (with Emacsclient) and use no desktop save file (or optionally, another desktop save file) when running a regular Emacs instance (no server-start
command).
Is it possible to use a fixed desktop save directory name with desktop-save-mode
?
If I use:
(desktop-save-mode 1)
I have no direct control over where the desktop is saved (though, I think it is saved in ~/.emacs.d/.emacs.desktop
).
I tried to add the following to my Emacs init file:
(require 'desktop)
(defvar my-desktop-dir "~/emacs-server")
(when (file-exists-p (desktop-full-file-name my-desktop-dir))
(desktop-read my-desktop-dir))
(add-hook 'kill-emacs-hook (lambda () (desktop-save my-desktop-dir))))
while this seems to work, I am not sure if desktop auto save will be enabled.. From the manual :
When desktop-save-mode is active and the desktop file exists, Emacs auto-saves it every desktop-auto-save-timeout seconds, if that is non-nil and non-zero.
so in order to make desktop-save-mode
active, I have to run (desktop-save-mode 1)
in my init file. The problem is that this command then will revert to the desktop stored in ~/.emacs.d
, which is not desired.