GNU bug report logs - #20257
[PATCH] 24.4.90; set-visited-file-name doesn't reset buffer-auto-save-file-name

Previous Next

Package: emacs;

Reported by: Vitalie Spinu <spinuvit <at> gmail.com>

Date: Sat, 4 Apr 2015 13:51:03 UTC

Severity: normal

Tags: patch

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 20257 in the body.
You can then email your comments to 20257 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#20257; Package emacs. (Sat, 04 Apr 2015 13:51:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Vitalie Spinu <spinuvit <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 04 Apr 2015 13:51:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Vitalie Spinu <spinuvit <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] 24.4.90;
 set-visited-file-name doesn't reset buffer-auto-save-file-name
Date: Sat, 04 Apr 2015 15:41:58 +0200
[Message part 1 (text/plain, inline)]
Hi,

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

  Vitalie

[0001-Stop-auto-saving-after-set-visited-file-name-with-ni.patch (text/x-diff, inline)]
From 9b68126dfe58478424ec2b726cc307b1c0d96b1a Mon Sep 17 00:00:00 2001
From: Vitalie Spinu <spinuvit <at> gmail.com>
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


Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20257; Package emacs. (Sat, 04 Apr 2015 15:33:02 GMT) Full text and rfc822 format available.

Message #8 received at 20257 <at> debbugs.gnu.org (full text, mbox):

From: Vitalie Spinu <spinuvit <at> gmail.com>
To: 20257 <at> debbugs.gnu.org
Subject: Re: bug#20257: [PATCH] 24.4.90;
 set-visited-file-name doesn't reset buffer-auto-save-file-name
Date: Sat, 04 Apr 2015 17:32:35 +0200
[Message part 1 (text/plain, inline)]
Fix a typo in the previous patch.

[0001-Don-t-auto-save-after-set-visited-file-name-nil.patch (text/x-diff, inline)]
From 06533b83650f24fe1138ab043c9ac93e0ac59ae2 Mon Sep 17 00:00:00 2001
From: Vitalie Spinu <spinuvit <at> gmail.com>
Date: Sat, 4 Apr 2015 15:28:07 +0200
Subject: [PATCH] Don't auto-save after (set-visited-file-name nil)

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

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


Reply sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
You have taken responsibility. (Tue, 07 Apr 2015 18:59:02 GMT) Full text and rfc822 format available.

Notification sent to Vitalie Spinu <spinuvit <at> gmail.com>:
bug acknowledged by developer. (Tue, 07 Apr 2015 18:59:03 GMT) Full text and rfc822 format available.

Message #13 received at 20257-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Vitalie Spinu <spinuvit <at> gmail.com>
Cc: 20257-done <at> debbugs.gnu.org
Subject: Re: bug#20257: [PATCH] 24.4.90;
 set-visited-file-name doesn't reset buffer-auto-save-file-name
Date: Tue, 07 Apr 2015 14:57:25 -0400
Thank you, installed into master,


        Stefan




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 06 May 2015 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 10 years and 41 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.