Search code examples
emacselispautosaveemacs24

Auto-Saving in Emacs not working properly when directory specified


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.


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.