diff options
| author | Richard M. Stallman | 1993-03-03 05:12:05 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1993-03-03 05:12:05 +0000 |
| commit | 41f48cb1bd82bfd78d5d61dbfe173906ed298149 (patch) | |
| tree | 13cf806cb8c95746cd8c30d7510d85094edc7c5b | |
| parent | c751ebb6a3632b879cd7efbffdfeafa364c3a6cc (diff) | |
| download | emacs-41f48cb1bd82bfd78d5d61dbfe173906ed298149.tar.gz emacs-41f48cb1bd82bfd78d5d61dbfe173906ed298149.zip | |
(write-file): Handle directory name as arg.
| -rw-r--r-- | lisp/files.el | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/lisp/files.el b/lisp/files.el index 49d452b92e2..60329f162b2 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -935,7 +935,10 @@ if you wish to pass an empty string as the argument." | |||
| 935 | 935 | ||
| 936 | (defun write-file (filename) | 936 | (defun write-file (filename) |
| 937 | "Write current buffer into file FILENAME. | 937 | "Write current buffer into file FILENAME. |
| 938 | Makes buffer visit that file, and marks it not modified." | 938 | Makes buffer visit that file, and marks it not modified. |
| 939 | If the buffer is already visiting a file, you can specify | ||
| 940 | a directory name as FILENAME, to write a file of the same | ||
| 941 | old name in that directory." | ||
| 939 | ;; (interactive "FWrite file: ") | 942 | ;; (interactive "FWrite file: ") |
| 940 | (interactive | 943 | (interactive |
| 941 | (list (if buffer-file-name | 944 | (list (if buffer-file-name |
| @@ -946,7 +949,13 @@ Makes buffer visit that file, and marks it not modified." | |||
| 946 | (buffer-local-variables))) | 949 | (buffer-local-variables))) |
| 947 | nil nil (buffer-name))))) | 950 | nil nil (buffer-name))))) |
| 948 | (or (null filename) (string-equal filename "") | 951 | (or (null filename) (string-equal filename "") |
| 949 | (set-visited-file-name filename)) | 952 | (progn |
| 953 | ;; If arg is just a directory, | ||
| 954 | ;; use same file name, but in that directory. | ||
| 955 | (if (and (file-directory-p filename) buffer-file-name) | ||
| 956 | (setq filename (concat (file-name-as-directory filename) | ||
| 957 | (file-name-nondirectory buffer-file-name)))) | ||
| 958 | (set-visited-file-name filename))) | ||
| 950 | (set-buffer-modified-p t) | 959 | (set-buffer-modified-p t) |
| 951 | (save-buffer)) | 960 | (save-buffer)) |
| 952 | 961 | ||