changeset 2710:54fd042e254c

[xemacs-hg @ 2005-04-03 23:57:36 by youngs] 2005-04-04 Steve Youngs <steve@sxemacs.org> * files.el (backup-buffer): Write "%backup%~" in `auto-save-directory' and fall back to $HOME if for some reason that isn't possible. Suggested By: Jamie Zawinski <jwz@jwz.org>
author youngs
date Sun, 03 Apr 2005 23:57:37 +0000
parents 2af87b0fc2c2
children 879b927c8a9f
files lisp/ChangeLog lisp/files.el
diffstat 2 files changed, 15 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Sun Apr 03 21:51:48 2005 +0000
+++ b/lisp/ChangeLog	Sun Apr 03 23:57:37 2005 +0000
@@ -1,3 +1,10 @@
+2005-04-04  Steve Youngs  <steve@sxemacs.org>
+
+	* files.el (backup-buffer): Write "%backup%~" in
+	`auto-save-directory' and fall back to $HOME if for some reason
+	that isn't possible.
+	Suggested By: Jamie Zawinski <jwz@jwz.org>
+
 2005-03-31  Aidan Kehoe  <kehoea@parhasard.net>
 
 	* faces.el (face-complain-about-font):
--- a/lisp/files.el	Sun Apr 03 21:51:48 2005 +0000
+++ b/lisp/files.el	Sun Apr 03 23:57:37 2005 +0000
@@ -2390,10 +2390,15 @@
 				(rename-file real-file-name backupname t)
 				(setq setmodes (file-modes backupname)))
 			    (file-error
-			     ;; If trouble writing the backup, write it in ~.
+			     ;; If trouble writing the backup, write
+			     ;; it in `auto-save-directory'.  Fall
+			     ;; back to $HOME if that's not possible.
 			     (setq backupname
-				   (expand-file-name
-				    (convert-standard-filename "~/%backup%~")))
+				   (expand-file-name "%backup%~"
+						     (or (when (and auto-save-directory
+								    (file-writable-p auto-save-directory))
+							   auto-save-directory)
+							 (getenv "HOME"))))
 			     (lwarn 'file 'alert "Cannot write backup file; backing up in %s"
 				    (file-name-nondirectory backupname))
 			     (sleep-for 1)