emacsido-mode

Change location of .ido.last history file in Emacs on Windows


Using Emacs with ido mode enabled on Windows, Emacs tries to save a history file .ido.last when exiting. The file is located in C:/.ido.last, but it fails with a permission denied message. This is strange since I actually have access to that folder. However:

Is there a command to change the directory where the .ido.last file gets saved?


Solution

  • Short answer: (setq ido-save-directory-list-file "/some/file/name").

    Long answer:

    I keep all the little files that remember Emacs's state in a single directory under the user-emacs-directory. I'm not sure what this is on Windows, but I think it's C:\Users\<username>\Application Data\.emacs.d\. On Unix, it's ~/.emacs.d/. The variable user-emacs-directory should be defined by Emacs, no need to set it.

    (setq emacs-persistence-directory (concat user-emacs-directory "persistence/"))
    (unless (file-exists-p emacs-persistence-directory)
        (make-directory emacs-persistence-directory t))
    (setq ido-save-directory-list-file (concat emacs-persistence-directory
                                               "ido-last"))
    

    You may want to look at the no-littering package, which sets better default locations for files like this.