0

When you run M-x desktop-save, you're prompted with the message and the default option: Directory to save desktop file in: "~/.emacs.d"

How can I change this default path to something else like "~/.emacs1.d" in my init.el, so that I won't have to insert "1" each time I want to save my session, and so that I won't overwrite the desktop file in ~/.emacs.d by mistake?

  • If you normally want to use a non-default path, then you should probably move the files so that the default path is the one you normally want, and anything else is the exception. – phils May 7 '17 at 7:17
  • I think it would help if you detailed the desired workflow (including when you would read and save each of the two desktop files). It's easy enough to write commands which would use custom values for the desktop file or directory, but it's not entirely obvious how you'd want it all to work. – phils May 7 '17 at 7:23
1

You should be able to set desktop-dirname to the directory of your choice and then every time you save using desktop-save-in-desktop-dir it will save in that directory. You can still use desktop-save and it will provide you with the usual home directory prompt.

| improve this answer | |
0

AFAICT, there is no variable that you can set to change it. The code looks like this:

  (interactive (list
            ;; Or should we just use (car desktop-path)?
            (let ((default (if (member "." desktop-path)
                               default-directory
                             user-emacs-directory)))
              (read-directory-name "Directory to save desktop file in: "
                                   default default t))

so you could add "." to desktop-path, but then it would use default-directory which you probably don't want. I would not dare customize user-emacs-directory away from its default value, so the only thing that remains is to change desktop-save to use another directory as default:

  (interactive (list
            ;; Or should we just use (car desktop-path)?
            (let ((default (if (member "." desktop-path)
                               default-directory
                             my-desktop-save-directory)))
              (read-directory-name "Directory to save desktop file in: "
                                   default default t))

where you define my-desktop-save-directory to whatever you want. But why don't you like the user-emacs-directory default?

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.