bug-gnu-emacs
[Top][All Lists]
Advanced

[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: Tino Calancha
Subject: bug#25609: 25.1; Dired: Copy folder with 'dired-dwim-target t' results in nested copy
Date: Sat, 04 Feb 2017 20:59:53 +0900
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)

Mathieu Basille <address@hidden> 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 <address@hidden>
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))
-- 
2.11.0

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
In GNU Emacs 26.0.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.22.7)
 of 2017-02-04
Repository revision: c8f91b168b0955e1e21acbf291171af1f70725ec





reply via email to

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