emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bug in copy-directory


From: Thierry Volpiatto
Subject: Re: bug in copy-directory
Date: Fri, 28 Jan 2011 10:05:59 +0100
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.2.92 (gnu/linux)

Chong Yidong <address@hidden> writes:

> Thierry Volpiatto <address@hidden> writes:
>
>> Actually on 23.2.92.1, copy-directory, called interactively or not copy
>> the files of directory A to existing directory B instead of copying
>> directory A inside directory B.(as a subdirectory of B).
>
> Hmm, this is a bit problematic.
>
> The attached patch should fix the problem---Thierry, could you test?
Yes it works, thanks.

> The trouble is that Lisp callers might depend on the old behavior.  In
> particular, I don't understand how Tramp interacts with copy-directory.


This part of code call the tramp handler

,----[ files.el copy-directory ]
|   ;; If default-directory is a remote directory, make sure we find its
|   ;; copy-directory handler.
|   (let ((handler (or (find-file-name-handler directory 'copy-directory)
|                    (find-file-name-handler newname 'copy-directory))))
|     (if handler
|       (funcall handler 'copy-directory directory newname keep-time parents)
`----

[EVAL] (assoc 'copy-directory tramp-file-name-handler-alist)


> Michael, could you take a look and see if there is any problem?


> Also, I noticed that the command doesn't prompt for overwriting files.
> It probably ought to, at least when called interactively.
It should prompt also to copy recursively dir.


Please could you send git-style patchs?

---
 lisp/files.el |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/lisp/files.el b/lisp/files.el
index ee77975..9eac9a3 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -4756,7 +4756,16 @@ this happens by default."
       ;; Compute target name.
       (setq directory (directory-file-name (expand-file-name directory))
            newname   (directory-file-name (expand-file-name newname)))
-      (if (not (file-directory-p newname)) (make-directory newname parents))
+
+      (if (not (file-directory-p newname))
+         (make-directory newname parents)
+       ;; If NEWNAME is an existing directory, we want to copy into
+       ;; NEWNAME/DIRECTORY.
+       (setq newname (expand-file-name
+                      (file-name-nondirectory
+                       (directory-file-name directory))
+                      newname))
+       (make-directory newname t))
 
       ;; Copy recursively.
       (mapc

-- 
A+ Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]