changeset 2003:bff31af6c721

(write-file): Handle directory name as arg.
author Richard M. Stallman <rms@gnu.org>
date Wed, 03 Mar 1993 05:12:05 +0000
parents 4c9113b2d6e0
children 6469a137fea6
files lisp/files.el
diffstat 1 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/files.el	Tue Mar 02 22:25:16 1993 +0000
+++ b/lisp/files.el	Wed Mar 03 05:12:05 1993 +0000
@@ -935,7 +935,10 @@
 
 (defun write-file (filename)
   "Write current buffer into file FILENAME.
-Makes buffer visit that file, and marks it not modified."
+Makes buffer visit that file, and marks it not modified.
+If the buffer is already visiting a file, you can specify
+a directory name as FILENAME, to write a file of the same
+old name in that directory."
 ;;  (interactive "FWrite file: ")
   (interactive
    (list (if buffer-file-name
@@ -946,7 +949,13 @@
 					  (buffer-local-variables)))
 			       nil nil (buffer-name)))))
   (or (null filename) (string-equal filename "")
-      (set-visited-file-name filename))
+      (progn
+	;; If arg is just a directory,
+	;; use same file name, but in that directory.
+	(if (and (file-directory-p filename) buffer-file-name)
+	    (setq filename (concat (file-name-as-directory filename)
+				   (file-name-nondirectory buffer-file-name))))
+	(set-visited-file-name filename)))
   (set-buffer-modified-p t)
   (save-buffer))