unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#20257: [PATCH] 24.4.90; set-visited-file-name doesn't reset buffer-auto-save-file-name
@ 2015-04-04 13:41 Vitalie Spinu
  2015-04-04 15:32 ` Vitalie Spinu
  0 siblings, 1 reply; 3+ messages in thread
From: Vitalie Spinu @ 2015-04-04 13:41 UTC (permalink / raw)
  To: 20257

[-- Attachment #1: Type: text/plain, Size: 135 bytes --]


Hi,

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

  Vitalie


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Stop-auto-saving-after-set-visited-file-name-with-ni.patch --]
[-- Type: text/x-diff, Size: 1997 bytes --]

From 9b68126dfe58478424ec2b726cc307b1c0d96b1a Mon Sep 17 00:00:00 2001
From: Vitalie Spinu <spinuvit@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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* bug#20257: [PATCH] 24.4.90; set-visited-file-name doesn't reset buffer-auto-save-file-name
  2015-04-04 13:41 bug#20257: [PATCH] 24.4.90; set-visited-file-name doesn't reset buffer-auto-save-file-name Vitalie Spinu
@ 2015-04-04 15:32 ` Vitalie Spinu
  2015-04-07 18:57   ` Stefan Monnier
  0 siblings, 1 reply; 3+ messages in thread
From: Vitalie Spinu @ 2015-04-04 15:32 UTC (permalink / raw)
  To: 20257

[-- Attachment #1: Type: text/plain, Size: 36 bytes --]


Fix a typo in the previous patch.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Don-t-auto-save-after-set-visited-file-name-nil.patch --]
[-- Type: text/x-diff, Size: 1973 bytes --]

From 06533b83650f24fe1138ab043c9ac93e0ac59ae2 Mon Sep 17 00:00:00 2001
From: Vitalie Spinu <spinuvit@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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* bug#20257: [PATCH] 24.4.90; set-visited-file-name doesn't reset buffer-auto-save-file-name
  2015-04-04 15:32 ` Vitalie Spinu
@ 2015-04-07 18:57   ` Stefan Monnier
  0 siblings, 0 replies; 3+ messages in thread
From: Stefan Monnier @ 2015-04-07 18:57 UTC (permalink / raw)
  To: Vitalie Spinu; +Cc: 20257-done

Thank you, installed into master,


        Stefan





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-04-07 18:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-04 13:41 bug#20257: [PATCH] 24.4.90; set-visited-file-name doesn't reset buffer-auto-save-file-name Vitalie Spinu
2015-04-04 15:32 ` Vitalie Spinu
2015-04-07 18:57   ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).