Subject: bug#20257: closed (Re: bug#20257: [PATCH] 24.4.90; set-visited-file-name doesn't reset buffer-auto-save-file-name)

From: [email-masked] (GNU bug Tracking System)
Date: Tue, 07 Apr 2015 18:59:03 +0000

Your bug report

#20257: [PATCH] 24.4.90; set-visited-file-name doesn't reset buffer-auto-save-file-name

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
20257: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=20257
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#20257: [PATCH] 24.4.90; set-visited-file-name doesn't reset buffer-auto-save-file-name
From: Stefan Monnier <[email-masked]>
To: Vitalie Spinu <[email-masked]>
Cc: [email-masked]
Date: Tue, 07 Apr 2015 14:57:25 -0400
List-Id: <debbugs-submit.debbugs.gnu.org>

Thank you, installed into master,

        Stefan

Subject: [PATCH] 24.4.90; set-visited-file-name doesn't reset buffer-auto-save-file-name
From: Vitalie Spinu <[email-masked]>
To: [email-masked]
Date: Sat, 04 Apr 2015 15:41:58 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi,

Do (set-visited-file-name nil) and then rename the buffer. The buffer
will be auto-saved into the old visiting file.

  Vitalie

>From 9b68126dfe58478424ec2b726cc307b1c0d96b1a Mon Sep 17 00:00:00 2001
From: Vitalie Spinu <[email-masked]>
Date: Sat, 4 Apr 2015 15:28:07 +0200
Subject: [PATCH] Stop auto-saving after `set-visited-file-name` with nil
 FILENAME

---
 lisp/files.el | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/lisp/files.el b/lisp/files.el
index 42b00ac..7d36608 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)
-- 
2.1.0