Question

I'm trying to set autosave to use a directory in ./emacs.d/autosaves. I previously used the two commented out lines below and currently tried the other function I found on the web. Really all I want is the autosaves to not be stored in the same directory. It does this in

(defvar autosave-dir
 (concat "/home/" (user-login-name) "/.emacs.d/autosaves/"))
(make-directory autosave-dir t)
(defun auto-save-file-name-p (filename)
  (string-match "^#.*#$" (file-name-nondirectory filename)))
(defun make-auto-save-file-name ()
  (concat autosave-dir
   (if buffer-file-name
      (concat "#" (file-name-nondirectory buffer-file-name) "#")
    (expand-file-name
     (concat "#%" (buffer-name) "#")))))
;; (setq auto-save-file-name-transforms
;;       `(("#.*#" ,"~/.emacs.d/backups/" t)))

or can I set autosave to put a #notes.org# at the beginning and end of the file because currently has the format .#notes.org.

Was it helpful?

Solution

It's about locking the file. For more information, read:

(info "(emacs) Interlocking")

Basically no way around it unless perform a minor rewrite and compile your own emacs source from what I had read.

OTHER TIPS

What you need is just (assuming that the directory referred to by autosave-dir exists that is):

(setq auto-save-file-name-transforms
      `((".*" ,autosave-dir t)))

Personally I favour the use the standard tmp directory for autosaves:

(setq auto-save-file-name-transforms
      `((".*" ,temporary-file-directory t)))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top