aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman2002-05-14 05:36:44 +0000
committerRichard M. Stallman2002-05-14 05:36:44 +0000
commitff5c7181b083d1372ba5915166caba7b4f0d5cfb (patch)
tree666a4793a908ddca6465eaedb0cf90c538fcd294
parent31bea176a601dbd6a6ed3756057e5b78a791f5be (diff)
downloademacs-ff5c7181b083d1372ba5915166caba7b4f0d5cfb.tar.gz
emacs-ff5c7181b083d1372ba5915166caba7b4f0d5cfb.zip
(make-auto-save-file-name):
Delete the auto-save file after make-temp-file creates it.
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/files.el52
2 files changed, 35 insertions, 22 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index ff91b5e6248..2415b2e2f8a 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
12002-05-14 Richard M. Stallman <rms@gnu.org>
2
3 * files.el (make-auto-save-file-name):
4 Delete the auto-save file after make-temp-file creates it.
5
12002-05-13 Kim F. Storm <storm@cua.dk> 62002-05-13 Kim F. Storm <storm@cua.dk>
2 7
3 * emulation/cua-base.el (cua-enable-cursor-indications): Default off. 8 * emulation/cua-base.el (cua-enable-cursor-indications): Default off.
diff --git a/lisp/files.el b/lisp/files.el
index 7a33267789a..3cde660a4b4 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -3439,7 +3439,8 @@ See also `auto-save-file-name-p'."
3439 ;; mode tends to create a good number of these.) 3439 ;; mode tends to create a good number of these.)
3440 3440
3441 (let ((buffer-name (buffer-name)) 3441 (let ((buffer-name (buffer-name))
3442 (limit 0)) 3442 (limit 0)
3443 filename)
3443 ;; Eliminate all slashes and backslashes by 3444 ;; Eliminate all slashes and backslashes by
3444 ;; replacing them with sequences that start with %. 3445 ;; replacing them with sequences that start with %.
3445 ;; Quote % also, to keep distinct names distinct. 3446 ;; Quote % also, to keep distinct names distinct.
@@ -3452,27 +3453,34 @@ See also `auto-save-file-name-p'."
3452 (setq buffer-name (replace-match replacement t t buffer-name)) 3453 (setq buffer-name (replace-match replacement t t buffer-name))
3453 (setq limit (1+ (match-end 0))))) 3454 (setq limit (1+ (match-end 0)))))
3454 ;; Generate the file name. 3455 ;; Generate the file name.
3455 (make-temp-file 3456 (setq file-name
3456 (let ((fname 3457 (make-temp-file
3457 (expand-file-name 3458 (let ((fname
3458 (format "#%s#" buffer-name) 3459 (expand-file-name
3459 ;; Try a few alternative directories, to get one we can 3460 (format "#%s#" buffer-name)
3460 ;; write it. 3461 ;; Try a few alternative directories, to get one we can
3461 (cond 3462 ;; write it.
3462 ((file-writable-p default-directory) default-directory) 3463 (cond
3463 ((file-writable-p "/var/tmp/") "/var/tmp/") 3464 ((file-writable-p default-directory) default-directory)
3464 ("~/"))))) 3465 ((file-writable-p "/var/tmp/") "/var/tmp/")
3465 (if (and (memq system-type '(ms-dos windows-nt)) 3466 ("~/")))))
3466 ;; Don't modify remote (ange-ftp) filenames 3467 (if (and (memq system-type '(ms-dos windows-nt))
3467 (not (string-match "^/\\w+@[-A-Za-z0-9._]+:" fname))) 3468 ;; Don't modify remote (ange-ftp) filenames
3468 ;; The call to convert-standard-filename is in case 3469 (not (string-match "^/\\w+@[-A-Za-z0-9._]+:" fname)))
3469 ;; buffer-name includes characters not allowed by the 3470 ;; The call to convert-standard-filename is in case
3470 ;; DOS/Windows filesystems. make-temp-file writes to the 3471 ;; buffer-name includes characters not allowed by the
3471 ;; file it creates, so we must fix the file name _before_ 3472 ;; DOS/Windows filesystems. make-temp-file writes to the
3472 ;; make-temp-file is called. 3473 ;; file it creates, so we must fix the file name _before_
3473 (convert-standard-filename fname) 3474 ;; make-temp-file is called.
3474 fname)) 3475 (convert-standard-filename fname)
3475 nil "#")))) 3476 fname))
3477 nil "#"))
3478 ;; make-temp-file creates the file,
3479 ;; but we don't want it to exist until we do an auto-save.
3480 (condition-case ()
3481 (delete-file file-name)
3482 (file-error nil))
3483 file-name)))
3476 3484
3477(defun auto-save-file-name-p (filename) 3485(defun auto-save-file-name-p (filename)
3478 "Return non-nil if FILENAME can be yielded by `make-auto-save-file-name'. 3486 "Return non-nil if FILENAME can be yielded by `make-auto-save-file-name'.