Assume I have the file ~/Documents/bla.org. Now I open a buffer that visits the file ~/Documents/bla.org.

I check the value of the (buffer-local) variable buffer-auto-save-file-name, and it reads /home/berber/Documents/#bla.org#.

Now I run the following code:

(let ((save-files-directory (file-name-concat user-emacs-directory "auto-save")))
  (make-directory save-files-directory :parents)
  (setq auto-save-file-name-transforms
    `((".*" ,save-files-directory t))))

If I now open a buffer that visits the file ~/Documents/bla.org, the value of buffer-auto-save-file-name reads /home/berber/.config/emacs/#!home!berber!Documents!bla.org#. This is the wrong directory, obviously.

When I check the variable auto-save-file-name-transforms, I get ((".*" "~/.config/emacs/auto-save" t)), which sounds right, but as seen above, it doesn't do the right thing... Yes, the directory /home/berber/.config/emacs/auto-save exists, and yes, I have done this with emacs -Q.

What could my problem be?

I am using Emacs 28.2.

1 Answer 1


Make sure that the directory name contains a trailing /:

(let ((save-files-directory
          (file-name-concat user-emacs-directory
                               "auto-save/"))) ;;; <-- add trailing slash 
  (make-directory save-files-directory :parents)
  (setq auto-save-file-name-transforms
    `((".*" ,save-files-directory t))))
  • 1
    ugh thanks. i thought i have tried this a bunch of times. but now it works. hm, maybe there was something else wrong then.
    – Berber
    Nov 13, 2023 at 9:59
  • 1
    I didn't investigate this (I just tried it and it worked), but it feels like a (small) bug to me. If I find some time, I'll see if I can get to the bottom of it and maybe submit a bug report.
    – NickD
    Nov 13, 2023 at 17:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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