changeset 12895:4dbac3df0ec7

(basic-save-buffer): Confirm for overwriting old file when a file name is specified.
author Richard M. Stallman <rms@gnu.org>
date Sat, 19 Aug 1995 17:01:27 +0000
parents b2a75405de3c
children d4f7dec4acb7
files lisp/files.el
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/files.el	Sat Aug 19 17:00:34 1995 +0000
+++ b/lisp/files.el	Sat Aug 19 17:01:27 1995 +0000
@@ -1716,8 +1716,14 @@
 		(rename-buffer buffer-new-name)))
 	  ;; If buffer has no file name, ask user for one.
 	  (or buffer-file-name
-	      (set-visited-file-name
-	       (expand-file-name (read-file-name "File to save in: ") nil)))
+	      (let ((filename
+		     (expand-file-name
+		      (read-file-name "File to save in: ") nil)))
+		(and (file-exists-p filename)
+		     (or (y-or-n-p (format "File `%s' exists; overwrite? "
+					   filename))
+			 (error "Canceled")))
+		(set-visited-file-name filename)))
 	  (or (verify-visited-file-modtime (current-buffer))
 	      (not (file-exists-p buffer-file-name))
 	      (yes-or-no-p