diff options
| -rw-r--r-- | doc/emacs/files.texi | 8 | ||||
| -rw-r--r-- | doc/lispref/files.texi | 5 | ||||
| -rw-r--r-- | etc/NEWS | 4 | ||||
| -rw-r--r-- | lisp/files.el | 22 |
4 files changed, 19 insertions, 20 deletions
diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi index 0cf46b6df1c..ca4f2239537 100644 --- a/doc/emacs/files.texi +++ b/doc/emacs/files.texi | |||
| @@ -1572,10 +1572,10 @@ file @var{new}. | |||
| 1572 | 1572 | ||
| 1573 | @findex copy-directory | 1573 | @findex copy-directory |
| 1574 | @kbd{M-x copy-directory} copies directories, similar to the | 1574 | @kbd{M-x copy-directory} copies directories, similar to the |
| 1575 | @command{cp -r} shell command. If @var{new} is an existing directory, | 1575 | @command{cp -r} shell command. If @var{new} is a directory name, it |
| 1576 | it creates a copy of the @var{old} directory and puts it in @var{new}. | 1576 | creates a copy of the @var{old} directory and puts it in @var{new}. |
| 1577 | If @var{new} is not an existing directory, it copies all the contents | 1577 | Otherwise it copies all the contents of @var{old} into a new directory |
| 1578 | of @var{old} into a new directory named @var{new}. | 1578 | named @var{new}. |
| 1579 | 1579 | ||
| 1580 | @cindex renaming files | 1580 | @cindex renaming files |
| 1581 | @findex rename-file | 1581 | @findex rename-file |
diff --git a/doc/lispref/files.texi b/doc/lispref/files.texi index eacaf046370..901382fe9bd 100644 --- a/doc/lispref/files.texi +++ b/doc/lispref/files.texi | |||
| @@ -2976,8 +2976,9 @@ if they don't already exist. | |||
| 2976 | 2976 | ||
| 2977 | @deffn Command copy-directory dirname newname &optional keep-time parents copy-contents | 2977 | @deffn Command copy-directory dirname newname &optional keep-time parents copy-contents |
| 2978 | This command copies the directory named @var{dirname} to | 2978 | This command copies the directory named @var{dirname} to |
| 2979 | @var{newname}. If @var{newname} names an existing directory, | 2979 | @var{newname}. If @var{newname} is a directory name, |
| 2980 | @var{dirname} will be copied to a subdirectory there. | 2980 | @var{dirname} will be copied to a subdirectory there. |
| 2981 | @xref{Directory Names}. | ||
| 2981 | 2982 | ||
| 2982 | It always sets the file modes of the copied files to match the | 2983 | It always sets the file modes of the copied files to match the |
| 2983 | corresponding original file. | 2984 | corresponding original file. |
| @@ -2992,7 +2993,7 @@ this happens by default. | |||
| 2992 | 2993 | ||
| 2993 | The fifth argument @var{copy-contents}, if non-@code{nil}, means to | 2994 | The fifth argument @var{copy-contents}, if non-@code{nil}, means to |
| 2994 | copy the contents of @var{dirname} directly into @var{newname} if the | 2995 | copy the contents of @var{dirname} directly into @var{newname} if the |
| 2995 | latter is an existing directory, instead of copying @var{dirname} into | 2996 | latter is a directory name, instead of copying @var{dirname} into |
| 2996 | it as a subdirectory. | 2997 | it as a subdirectory. |
| 2997 | @end deffn | 2998 | @end deffn |
| 2998 | 2999 | ||
| @@ -1285,8 +1285,8 @@ documentation and had inherent races that led to security holes. A | |||
| 1285 | call like (rename-file C D) that used the old, undocumented behavior | 1285 | call like (rename-file C D) that used the old, undocumented behavior |
| 1286 | can be written as (rename-file C (file-name-as-directory D)), a | 1286 | can be written as (rename-file C (file-name-as-directory D)), a |
| 1287 | formulation portable to both older and newer versions of Emacs. | 1287 | formulation portable to both older and newer versions of Emacs. |
| 1288 | Affected functions include add-name-to-file, copy-file, | 1288 | Affected functions include add-name-to-file, copy-directory, |
| 1289 | make-symbolic-link, and rename-file. | 1289 | copy-file, make-symbolic-link, and rename-file. |
| 1290 | 1290 | ||
| 1291 | 1291 | ||
| 1292 | * Lisp Changes in Emacs 26.1 | 1292 | * Lisp Changes in Emacs 26.1 |
diff --git a/lisp/files.el b/lisp/files.el index 85e649fbb59..7ab6f769a8f 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -5501,10 +5501,10 @@ Noninteractively, the last argument PARENTS says whether to | |||
| 5501 | create parent directories if they don't exist. Interactively, | 5501 | create parent directories if they don't exist. Interactively, |
| 5502 | this happens by default. | 5502 | this happens by default. |
| 5503 | 5503 | ||
| 5504 | If NEWNAME names an existing directory, copy DIRECTORY as a | 5504 | If NEWNAME is a directory name, copy DIRECTORY as a subdirectory |
| 5505 | subdirectory there. However, if called from Lisp with a non-nil | 5505 | there. However, if called from Lisp with a non-nil optional |
| 5506 | optional argument COPY-CONTENTS, copy the contents of DIRECTORY | 5506 | argument COPY-CONTENTS, copy the contents of DIRECTORY directly |
| 5507 | directly into NEWNAME instead." | 5507 | into NEWNAME instead." |
| 5508 | (interactive | 5508 | (interactive |
| 5509 | (let ((dir (read-directory-name | 5509 | (let ((dir (read-directory-name |
| 5510 | "Copy directory: " default-directory default-directory t nil))) | 5510 | "Copy directory: " default-directory default-directory t nil))) |
| @@ -5526,19 +5526,17 @@ directly into NEWNAME instead." | |||
| 5526 | 5526 | ||
| 5527 | ;; Compute target name. | 5527 | ;; Compute target name. |
| 5528 | (setq directory (directory-file-name (expand-file-name directory)) | 5528 | (setq directory (directory-file-name (expand-file-name directory)) |
| 5529 | newname (directory-file-name (expand-file-name newname))) | 5529 | newname (expand-file-name newname)) |
| 5530 | 5530 | ||
| 5531 | (cond ((not (file-directory-p newname)) | 5531 | (cond ((not (directory-name-p newname)) |
| 5532 | ;; If NEWNAME is not an existing directory, create it; | 5532 | ;; If NEWNAME is not a directory name, create it; |
| 5533 | ;; that is where we will copy the files of DIRECTORY. | 5533 | ;; that is where we will copy the files of DIRECTORY. |
| 5534 | (make-directory newname parents)) | 5534 | (make-directory newname parents)) |
| 5535 | ;; If NEWNAME is an existing directory and COPY-CONTENTS | 5535 | ;; If NEWNAME is a directory name and COPY-CONTENTS |
| 5536 | ;; is nil, copy into NEWNAME/[DIRECTORY-BASENAME]. | 5536 | ;; is nil, copy into NEWNAME/[DIRECTORY-BASENAME]. |
| 5537 | ((not copy-contents) | 5537 | ((not copy-contents) |
| 5538 | (setq newname (concat | 5538 | (setq newname (concat newname |
| 5539 | (file-name-as-directory newname) | 5539 | (file-name-nondirectory directory))) |
| 5540 | (file-name-nondirectory | ||
| 5541 | (directory-file-name directory)))) | ||
| 5542 | (and (file-exists-p newname) | 5540 | (and (file-exists-p newname) |
| 5543 | (not (file-directory-p newname)) | 5541 | (not (file-directory-p newname)) |
| 5544 | (error "Cannot overwrite non-directory %s with a directory" | 5542 | (error "Cannot overwrite non-directory %s with a directory" |