]> git.eshelyaron.com Git - emacs.git/commitdiff
(make-auto-save-file-name): Try a few directories
authorRichard M. Stallman <rms@gnu.org>
Sun, 1 Sep 1996 00:20:33 +0000 (00:20 +0000)
committerRichard M. Stallman <rms@gnu.org>
Sun, 1 Sep 1996 00:20:33 +0000 (00:20 +0000)
to get one we can write in.

lisp/files.el

index 84dd9391846f1b5c83a927d3b4465c8b27caa70e..35c430c19426d2cba6b1286360e9c7e2ec7e8bbe 100644 (file)
@@ -2471,8 +2471,14 @@ See also `auto-save-file-name-p'."
                          "\\\\")
                        (substring buffer-name (match-end 0))))
        (setq limit (1+ (match-end 0))))
-
-      (expand-file-name (format "#%s#%s#" buffer-name (make-temp-name ""))))))
+      ;; Generate the file name.
+      (expand-file-name
+       (format "#%s#%s#" buffer-name (make-temp-name ""))
+       ;; Try a few alternative directories, to get one we can write it.
+       (cond
+       ((file-writable-p default-directory) default-directory)
+       ((file-writable-p "/var/tmp/") "/var/tmp/")
+       ("~/"))))))
 
 (defun auto-save-file-name-p (filename)
   "Return non-nil if FILENAME can be yielded by `make-auto-save-file-name'.