views:

52

answers:

1

I love emacs, but something has been nagging me. I can't seem to get emacs to store local backups of files when I am editing them via tramp.

Currently, when I edit a local file a set of old versions is stored in the /tmp/myusername/emacs_backup folder. However, when I am FTPing via tramp, old versions aren't stored there (I assume it is trying to store them remotely?).

Here are my .emacs settings:

(defvar user-temporary-file-directory  
  (concat "/tmp/" user-login-name "/emacs_backup/"))  
(make-directory user-temporary-file-directory t)  
(setq make-backup-files t)  
(setq backup-by-copying t)  
(setq version-control t)  
(setq delete-old-versions t)  
(setq kept-new-versions 10)  
(setq backup-directory-alist `(("." . ,user-temporary-file-directory)))  
(setq tramp-backup-directory-alist backup-directory-alist)  
(setq tramp-auto-save-directory user-temporary-file-directory)  
(setq auto-save-list-file-prefix
      (concat user-temporary-file-directory ".auto-saves-"))  
(setq auto-save-file-name-transforms  
      `((".*" ,user-temporary-file-directory t)))

I don't care if tramp su editing is also stored in the tmp folder - the more the merrier in my opinion. Any help is greatly appreciated!

+1  A: 

The documentation for tramp-backup-directory-alist says

(setq tramp-backup-directory-alist backup-directory-alist)

gives the same backup policy for Tramp files on their hosts like the policy for local files.

Which I would interpret as backing up tramp files on the remote machine ("their host"). Looking at the implementation in tramp.el this is also the default implementation (if tramp-backup-directory-alist isn't set, then backup-directory-alist is).

Tramp assumes that a backup of a remote file should always be remote too, and explicitly prepends the method/user/host bits before doing the backup. If you want to change the behavior I think you'll have to advise tramp-handle-find-backup-file-name to adjust the file name (so it's a valid local one) and to coordinate with an entry in backup-directory-alist.

FWIW: Putting backup in the temporary file directory isn't going to help much in the long run. "Temporary" kind of defeats the purpose of backups.

0x4b