aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1994-09-20 04:27:40 +0000
committerRichard M. Stallman1994-09-20 04:27:40 +0000
commit6782610c408e3220fe2447a144ca4ac42f36fa19 (patch)
treea72b7e8010f4f24ce2f20feec15adb8c30f0691a
parentc56fbd24449cc73394bce8e3b720f918f7ffa2c8 (diff)
downloademacs-6782610c408e3220fe2447a144ca4ac42f36fa19.tar.gz
emacs-6782610c408e3220fe2447a144ca4ac42f36fa19.zip
(basic-save-buffer-1): If writing temp file fails
or a precious file, restore the old visited file modtime.
-rw-r--r--lisp/files.el8
1 files changed, 6 insertions, 2 deletions
diff --git a/lisp/files.el b/lisp/files.el
index bfc4abafa3e..b26da5dde77 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -1668,7 +1668,8 @@ the last real save, but optional arg FORCE non-nil means delete anyway."
1668 ;; This requires write access to the containing dir, 1668 ;; This requires write access to the containing dir,
1669 ;; which is why we don't try it if we don't have that access. 1669 ;; which is why we don't try it if we don't have that access.
1670 (let ((realname buffer-file-name) 1670 (let ((realname buffer-file-name)
1671 tempname temp nogood i succeed) 1671 tempname temp nogood i succeed
1672 (old-modtime (visited-file-modtime)))
1672 (setq i 0) 1673 (setq i 0)
1673 (setq nogood t) 1674 (setq nogood t)
1674 ;; Find the temporary name to write under. 1675 ;; Find the temporary name to write under.
@@ -1683,7 +1684,10 @@ the last real save, but optional arg FORCE non-nil means delete anyway."
1683 (setq succeed t)) 1684 (setq succeed t))
1684 ;; If writing the temp file fails, 1685 ;; If writing the temp file fails,
1685 ;; delete the temp file. 1686 ;; delete the temp file.
1686 (or succeed (delete-file tempname))) 1687 (or succeed
1688 (progn
1689 (delete-file tempname)
1690 (set-visited-file-modtime old-modtime))))
1687 ;; Since we have created an entirely new file 1691 ;; Since we have created an entirely new file
1688 ;; and renamed it, make sure it gets the 1692 ;; and renamed it, make sure it gets the
1689 ;; right permission bits set. 1693 ;; right permission bits set.