summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2015-04-07 14:56:54 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2015-04-07 14:56:54 -0400
commitd60dbd81bec6dcb6b78200e07021b9a6ebf861ea (patch)
treeec736d2013451a41a970a133a6bf271cbdfa9bb0
parenta137ff5025bbfe8aa3cd49814726c4b37ee3311d (diff)
downloademacs-d60dbd81bec6dcb6b78200e07021b9a6ebf861ea.tar.gz
Fixes: debbugs:20257
* lisp/files.el (set-visited-file-name): Clear auto-save if nil.
-rw-r--r--lisp/files.el24
1 files changed, 13 insertions, 11 deletions
diff --git a/lisp/files.el b/lisp/files.el
index 0fdf0048ac4..eca52e0ddd3 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -3931,17 +3931,19 @@ the old visited file has been renamed to the new name FILENAME."
(make-local-variable 'backup-inhibited)
(setq backup-inhibited t)))
(let ((oauto buffer-auto-save-file-name))
- ;; If auto-save was not already on, turn it on if appropriate.
- (if (not buffer-auto-save-file-name)
- (and buffer-file-name auto-save-default
- (auto-save-mode t))
- ;; If auto save is on, start using a new name.
- ;; We deliberately don't rename or delete the old auto save
- ;; for the old visited file name. This is because perhaps
- ;; the user wants to save the new state and then compare with the
- ;; previous state from the auto save file.
- (setq buffer-auto-save-file-name
- (make-auto-save-file-name)))
+ (cond ((null filename)
+ (setq buffer-auto-save-file-name nil))
+ ((not buffer-auto-save-file-name)
+ ;; If auto-save was not already on, turn it on if appropriate.
+ (and buffer-file-name auto-save-default (auto-save-mode t)))
+ (t
+ ;; If auto save is on, start using a new name. We
+ ;; deliberately don't rename or delete the old auto save
+ ;; for the old visited file name. This is because
+ ;; perhaps the user wants to save the new state and then
+ ;; compare with the previous state from the auto save
+ ;; file.
+ (setq buffer-auto-save-file-name (make-auto-save-file-name))))
;; Rename the old auto save file if any.
(and oauto buffer-auto-save-file-name
(file-exists-p oauto)