I am using
desktop-change-dir to handle multiple desktops. This works fine, except for the case when I have modified some buffers, and then run
desktop-change-dir before having saved the changes.
I thought that
desktop-change-dir would save any buffers before switching desktops, instead I get a question
Buffer <name> modified; kill anyway ? (yes/no). (Note that this question is somewhat different from the question you get when killing emacs, in that it does not ask if you would like to save the buffer or not.)
If I type
yes to the question, the modification to the buffer is lost, if I type
no the buffer is carried on to the next desktop.
(Neither of these options is desired, so I have to press
C-g to abort and save the file manually)
Instead I would like to have the modified buffers saved automatically. Is this possible?
Here is a minimal example:
$ emacs -Q -l init.el &
(defvar my-desktop-dir1 (file-name-as-directory (expand-file-name "desktop1"))) (defvar my-desktop-dir2 (file-name-as-directory (expand-file-name "desktop2"))) (defun my-switch-desktop () (interactive) ;; this line is commented out since `desktop-save' should be ;; called by `desktop-change-dir' ;;(desktop-save my-desktop-dir1 t t) (desktop-change-dir my-desktop-dir2)) (require 'desktop) (setq desktop-path (list my-desktop-dir1)) (setq desktop-save t) (desktop-save-mode 1) (desktop-read)