[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#25609: 25.1; Dired: Copy folder with 'dired-dwim-target t' results i
From: |
Mathieu Basille |
Subject: |
bug#25609: 25.1; Dired: Copy folder with 'dired-dwim-target t' results in nested copy |
Date: |
Sat, 4 Feb 2017 13:13:24 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0 |
Thanks for looking it up! Do you know when/if this patch will be available?
Mathieu.
On 02/04/2017 06:59 AM, Tino Calancha wrote:
> Mathieu Basille <mathieu.web@basille.net> writes:
>
>> Dear Emacs maintainers,
>>
>> The behavior I have is odd at best, but the situation is simple: given a
>> folder 'test', I want to make a copy of it in another folder.
>>
>> In practice (keyboard commands are between <>):
>>
>> * Open Emacs, <M-x dired> in any folder.
>> * <+ test> to create a folder 'test'.
>> * <+ target> to create a folder 'target'.
>> * Move on 'test' then <C target/> to copy it in 'target', <yes> to copy
>> recursively.
>>
>> So far so good, the empty 'test' folder is copied as expected. Assuming
>> there is some change in this folder, we want to copy it again to the
>> same place:
>>
>> * Move on 'test' then <C target/> to copy it in 'target'.
>> * Dired asks for confirmation to overwrite it, and if yes copies it
>> again.
>>
>> Now the weird behavior. With '(setq dired-dwim-target t)':
>>
>> * Open a second window <C-x 3>.
>> * Move to 'target' in this window, as to have 'target' on the right
>> window, but the initial folder on the left window.
>> * In the left window, move on 'test' and <C> to copy it again, DWIM will
>> suggest directly 'target/', so all that is needed is <Enter>.
>>
>> Note that there is no question to overwrite it or not. Visiting 'target'
>> now shows the 'test' folder, but inside it a second copy of 'test'!
>>
>> Even weirder:
>>
>> * Create an empty file in the original folder (<C-x C-f bla>, then <C-x
>> C-s> to save it, and <C-x k> to kill it).
>> * Select in the left window both 'test' and 'bla' with <m>.
>> * <C> to copy them, DWIM will suggest directly 'target/', so all that is
>> needed is <Enter>.
>>
>> Now it asks for confirmation to overwrite and copies 'test' together
>> with 'bla' in 'target' as expected!
> Same behaviour in Emacs-24 and master branch.
> Following patch works to me:
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> From 796a13469ac9f0084416a8b0bc0b3355b67e9d12 Mon Sep 17 00:00:00 2001
> From: Tino Calancha <tino.calancha@gmail.com>
> Date: Sat, 4 Feb 2017 20:59:06 +0900
> Subject: [PATCH] Fix Bug#25609
>
> * lisp/dired-aux.el (dired-do-create-files):
> If 'dired-dwim-target is non-nil, then bind 'default' to nil.
> ---
> lisp/dired-aux.el | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
> index caa3b45705..bc44f036e5 100644
> --- a/lisp/dired-aux.el
> +++ b/lisp/dired-aux.el
> @@ -1791,6 +1791,7 @@ dired-do-create-files
> (and (consp fn-list) (null (cdr fn-list)) (car fn-list)))
> (target-dir (dired-dwim-target-directory))
> (default (and dired-one-file
> + (not dired-dwim-target)
> (expand-file-name (file-name-nondirectory (car fn-list))
> target-dir)))
> (defaults (dired-dwim-target-defaults fn-list target-dir))
>