From: Thierry Volpiatto <thierry.volpiatto@gmail.com>
To: emacs-devel@gnu.org
Subject: Re: bug in copy-directory
Date: Sun, 06 Feb 2011 18:46:54 +0100 [thread overview]
Message-ID: <87tyghxdgx.fsf@gmail.com> (raw)
In-Reply-To: 87y65txele.fsf@gmail.com
Thierry Volpiatto <thierry.volpiatto@gmail.com> writes:
> Michael Albinus <michael.albinus@gmx.de> writes:
>
>> Chong Yidong <cyd@stupidchicken.com> writes:
>>
>>> Thierry Volpiatto <thierry.volpiatto@gmail.com> writes:
>>>
>>>> Ok thanks, i sent a patch to Chong.
>>>
>>> I've committed your patch, with a number of changes (e.g. renaming the
>>> new argument to `copy-as-subdir'). Please test it and see if everything
>>> behaves as you expect. Thanks.
>>
>> Now it is even worse. Going to the initial test case:
>>
>> - Create directory /tmp/test
>> - Create directory /tmp/test/test
>> - Create file /tmp/test/a
>> - Create file /tmp/test/test/b
>> - Apply (copy-directory "/tmp/test" "~/")
>>
>> You get "~/a", "~/test" and "~/test/b".
> Now you have to do:
> (copy-directory "/tmp/test" "~/" nil nil t)
>
> And if you do M-x copy-directory, all work fine because last arg is
> always used in interactive calls.
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.
Here are units-test for copy-directory:
(replace /home/thierry to /home/you)
;; Unit tests for copy-directory.
;; Download:
;; http://www.emacswiki.org/cgi-bin/wiki/download/el-expectations.el
;; http://www.emacswiki.org/cgi-bin/wiki/download/el-mock.el
(require 'cl)
(require 'el-expectations)
(require 'el-mock)
(expectations
(desc "Copy directory and overwrite")
(expect '("/home/thierry/test/a" "/home/thierry/test/test" "/home/thierry/test/test/b")
(delete-directory "~/test" t)
(make-directory "/tmp/test/test" t)
(with-current-buffer (find-file-noselect "/tmp/test/a")
(insert "test1")
(save-buffer))
(with-current-buffer (find-file-noselect "/tmp/test/test/b")
(insert "test2")
(save-buffer))
(copy-directory "/tmp/test" "~/" nil nil t)
(copy-directory "/tmp/test" "~/" nil nil t)
(let (result)
(labels ((ls-R (dir)
(loop with ls = (directory-files dir t directory-files-no-dot-files-regexp)
for f in ls
if (file-directory-p f)
do (progn (push f result) (ls-R f))
else do (push f result))))
(ls-R "~/test")
(nreverse result)))))
(expectations
(desc "Copy directory and overwrite from dired")
(expect '("/home/thierry/test/a" "/home/thierry/test/test" "/home/thierry/test/test/b")
(let ((A "/tmp/test")
(B "/home/thierry/test"))
(flet ((test-dired (flist dir)
(dired-create-files 'dired-copy-file "copy" flist
(if (file-directory-p dir)
#'(lambda (from)
(expand-file-name (anything-c-basename from) dir))
#'(lambda (from) dir)))))
(when (and (file-directory-p A)
(y-or-n-p (format "Delete directory %s? " A)))
(delete-directory A t))
(when (and (file-directory-p B)
(y-or-n-p (format "Delete directory %s? " B)))
(delete-directory B t))
(make-directory (concat (file-name-as-directory A) "test") t)
(with-current-buffer (find-file-noselect "/tmp/test/a")
(insert "test1")
(save-buffer))
(with-current-buffer (find-file-noselect "/tmp/test/test/b")
(insert "test2")
(save-buffer))
;; Create
(test-dired (list A) "~/")
;; Overwrite
(test-dired (list A) "~/")
(let (result)
(labels ((ls-R (dir)
(loop with ls = (directory-files dir t directory-files-no-dot-files-regexp)
for f in ls
if (file-directory-p f)
do (progn (push f result) (ls-R f))
else do (push f result))))
(ls-R B)
(nreverse result)))))))
--
A+ Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997
next prev parent reply other threads:[~2011-02-06 17:46 UTC|newest]
Thread overview: 92+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-27 15:18 bug in copy-directory Thierry Volpiatto
2011-01-28 1:13 ` Chong Yidong
2011-01-28 9:05 ` Thierry Volpiatto
2011-01-28 15:02 ` Stefan Monnier
2011-01-28 16:30 ` Chong Yidong
2011-01-28 16:51 ` Lennart Borgman
2011-01-28 17:05 ` Andreas Schwab
2011-01-28 17:08 ` Lennart Borgman
2011-01-28 17:18 ` Andreas Schwab
2011-01-28 17:13 ` Thierry Volpiatto
2011-01-28 17:17 ` Lennart Borgman
2011-01-28 18:11 ` Thierry Volpiatto
2011-01-28 18:28 ` Lennart Borgman
2011-01-28 20:12 ` Jan Djärv
2011-01-28 20:48 ` Lennart Borgman
2011-01-28 22:44 ` Jan Djärv
2011-01-28 22:55 ` Lennart Borgman
2011-01-28 18:31 ` Eli Zaretskii
2011-01-28 18:33 ` Thierry Volpiatto
2011-01-28 18:35 ` Stefan Monnier
2011-01-29 22:12 ` Chong Yidong
2011-01-29 22:51 ` Thierry Volpiatto
2011-01-30 10:51 ` Michael Albinus
2011-01-30 13:54 ` Thierry Volpiatto
2011-01-30 14:05 ` Michael Albinus
2011-01-30 10:46 ` Michael Albinus
2011-01-30 13:51 ` Thierry Volpiatto
2011-01-30 14:12 ` Michael Albinus
2011-01-30 14:36 ` Thierry Volpiatto
2011-01-30 15:21 ` Thierry Volpiatto
2011-01-30 16:00 ` Thierry Volpiatto
2011-01-30 17:43 ` Michael Albinus
2011-01-30 18:07 ` Thierry Volpiatto
2011-01-30 18:32 ` Thierry Volpiatto
2011-01-30 18:36 ` Michael Albinus
2011-01-30 19:07 ` Thierry Volpiatto
2011-01-30 21:18 ` Thierry Volpiatto
2011-01-31 17:06 ` Chong Yidong
2011-02-01 9:44 ` Michael Albinus
2011-02-01 11:57 ` Thierry Volpiatto
2011-02-02 8:19 ` Thierry Volpiatto
2011-02-02 9:24 ` Thierry Volpiatto
2011-02-02 9:47 ` Michael Albinus
2011-02-02 20:48 ` Thierry Volpiatto
2011-02-04 8:40 ` Thierry Volpiatto
2011-02-04 10:17 ` Michael Albinus
2011-02-04 17:28 ` Thierry Volpiatto
2011-02-04 19:20 ` Michael Albinus
2011-02-04 20:00 ` Thierry Volpiatto
2011-02-06 5:01 ` Chong Yidong
2011-02-06 6:23 ` Thierry Volpiatto
2011-02-06 12:03 ` Michael Albinus
2011-02-06 13:33 ` Chong Yidong
2011-02-07 16:43 ` Michael Albinus
2011-02-07 17:32 ` Thierry Volpiatto
2011-02-08 9:18 ` Michael Albinus
2011-02-08 10:58 ` Thierry Volpiatto
2011-02-08 11:29 ` Michael Albinus
2011-02-08 15:06 ` Thierry Volpiatto
2011-02-08 15:22 ` Michael Albinus
2011-02-08 16:39 ` Michael Albinus
2011-02-09 0:46 ` Chong Yidong
2011-02-09 7:13 ` Thierry Volpiatto
2011-02-09 8:32 ` Michael Albinus
2011-02-09 15:37 ` Chong Yidong
2011-02-09 16:07 ` Michael Albinus
2011-02-09 16:11 ` Thierry Volpiatto
2011-02-09 16:50 ` Chong Yidong
2011-02-09 17:37 ` Thierry Volpiatto
2011-02-06 17:22 ` Thierry Volpiatto
2011-02-06 17:46 ` Thierry Volpiatto [this message]
2011-02-07 15:22 ` Stefan Monnier
2011-02-07 16:02 ` Thierry Volpiatto
2011-02-07 18:55 ` Stefan Monnier
2011-02-07 20:00 ` Thierry Volpiatto
2011-02-08 3:32 ` Stefan Monnier
2011-02-09 16:02 ` Chong Yidong
2011-02-09 21:42 ` Stefan Monnier
2011-02-11 8:12 ` Thierry Volpiatto
2011-02-11 8:32 ` Michael Albinus
2011-02-11 9:48 ` Thierry Volpiatto
2011-02-11 10:36 ` Michael Albinus
2011-02-11 23:58 ` Chong Yidong
2011-02-12 7:06 ` Thierry Volpiatto
2011-02-12 9:01 ` Michael Albinus
2011-02-12 18:42 ` Chong Yidong
2011-02-12 19:41 ` Chong Yidong
2011-02-12 21:55 ` Thierry Volpiatto
2011-02-12 22:46 ` Chong Yidong
2011-02-14 11:40 ` Thierry Volpiatto
2011-02-12 7:26 ` Thierry Volpiatto
2011-02-06 17:47 ` Michael Albinus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87tyghxdgx.fsf@gmail.com \
--to=thierry.volpiatto@gmail.com \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.