Commit 6b8b57db authored by Richard M. Stallman's avatar Richard M. Stallman
Browse files

(write-file): Query if file exists already.

parent 80ddb8ed
...@@ -1344,6 +1344,9 @@ old name in that directory." ...@@ -1344,6 +1344,9 @@ old name in that directory."
(if (and (file-directory-p filename) buffer-file-name) (if (and (file-directory-p filename) buffer-file-name)
(setq filename (concat (file-name-as-directory filename) (setq filename (concat (file-name-as-directory filename)
(file-name-nondirectory buffer-file-name)))) (file-name-nondirectory buffer-file-name))))
(if (file-exists-p filename)
(or (y-or-n-p "File `%s' exists; overwrite? " filename)
(error "Canceled")))
(set-visited-file-name filename))) (set-visited-file-name filename)))
(set-buffer-modified-p t) (set-buffer-modified-p t)
(save-buffer)) (save-buffer))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment