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: Mon, 07 Feb 2011 17:02:17 +0100
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.2.93 (gnu/linux)

Stefan Monnier <address@hidden> writes:

>> If you want to be able to do:
>> (copy-directory "/tmp/test" "~/")
>> We will have to fallback to a function copy-directory1 used by dired and
>> a copy-directory function/command that ALWAYS use last arg of
>> copy-directory1.
>
> That sounds to me like the right thing to do (copy-directory already
> has many arguments, and adding one which will (almost) always need to
> be passed doesn't sound too attractive).
>
> But you say it in a tone that seems to imply it's undesirable: could you
> explain why you think it's undesirable?
No, i agree to use copy-directory without adding extra arguments.
i.e (copy-directory "/tmp/test" "~/")

The problem we have actually is to make something that:

- work in interactive call to copy-directory (M-x copy-directory)
- work non--interactively ==> (copy-directory "/tmp/test" "~/")
- work from dired.

If you have only one function copy-directory that work fine in case 2,
it will fail in dired because dired already does a part of the job of
this function (maybe because long time ago dired-create-files has been
wrote on this bug), and if you make it work in dired it will fail in
directs calls to copy-directory.

So to achieve the 3 cases above i propose:

- Make a copy-directory1 function that work with dired (like ancient
  code).
- call copy-directory1 in dired-copy-file-recursive.
- Make a copy-directory function/command that reuse copy-directory1
  without extra args (like it was before, last arg is parents).

This actually works and is IMHO the best solution.(see patch)

Otherwise you have to call in dired-do-copy dired-create-files something
like this:

,----
| (dired-create-files
|  fn (symbol-name action) files
|  ;; CANDIDATE is the destination.
|  (if (file-directory-p candidate)
|      ;; When CANDIDATE is a directory, build file-name in this directory.
|      ;; Else we use CANDIDATE.
|      #'(lambda (from)
|          (let ((target (expand-file-name (file-name-nondirectory from) 
candidate)))
|            (if (file-directory-p target) candidate target)))
|      #'(lambda (from) candidate))
|  marker)
`----

but in this case the NAME-CONSTRUCTOR returns wrong value for message,
but not for executing code (it does the right thing)

So in this case a rewrite (partial) of dired-create-files is needed in
addition of modification of dired-do-copy call to dired-create-files.
(with possible breakage of symlinking etc...)

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

Attachment: patch-copy-dir5
Description: Binary data


reply via email to

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