]> git.eshelyaron.com Git - emacs.git/commitdiff
(basic-save-buffer): Confirm for overwriting old file
authorRichard M. Stallman <rms@gnu.org>
Sat, 19 Aug 1995 17:01:27 +0000 (17:01 +0000)
committerRichard M. Stallman <rms@gnu.org>
Sat, 19 Aug 1995 17:01:27 +0000 (17:01 +0000)
when a file name is specified.

lisp/files.el

index 4f36427a2e23f502f612c4d033f9dc3d647b5685..930c343430e49493c095e21711e40efa41be2764 100644 (file)
@@ -1716,8 +1716,14 @@ the last real save, but optional arg FORCE non-nil means delete anyway."
                (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