aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorPaul Eggert2017-09-10 22:07:30 -0700
committerPaul Eggert2017-09-10 22:31:23 -0700
commite22794867d878d53675fcc91d2ef1ad2494a2ff2 (patch)
tree49339927ea210b509507e704067cfe689145fc00 /lisp
parentcf9891e14e48a93bca2065fdd7998f5f677786dc (diff)
downloademacs-e22794867d878d53675fcc91d2ef1ad2494a2ff2.tar.gz
emacs-e22794867d878d53675fcc91d2ef1ad2494a2ff2.zip
Make copy-directory act like copy-file etc.
Do the special dance with the destination only if it is a directory name, for consistency with copy-file etc. (Bug#27986). * doc/emacs/files.texi (Copying and Naming): * doc/lispref/files.texi (Create/Delete Dirs): * etc/NEWS: Document this. * lisp/files.el (copy-directory): Treat NEWNAME as special only if it is a directory name.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/files.el22
1 files changed, 10 insertions, 12 deletions
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
5501create parent directories if they don't exist. Interactively, 5501create parent directories if they don't exist. Interactively,
5502this happens by default. 5502this happens by default.
5503 5503
5504If NEWNAME names an existing directory, copy DIRECTORY as a 5504If NEWNAME is a directory name, copy DIRECTORY as a subdirectory
5505subdirectory there. However, if called from Lisp with a non-nil 5505there. However, if called from Lisp with a non-nil optional
5506optional argument COPY-CONTENTS, copy the contents of DIRECTORY 5506argument COPY-CONTENTS, copy the contents of DIRECTORY directly
5507directly into NEWNAME instead." 5507into 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"