* bug#25609: 25.1; Dired: Copy folder with 'dired-dwim-target t' results in nested copy
@ 2017-02-02 16:54 Mathieu Basille
2017-02-04 11:59 ` Tino Calancha
0 siblings, 1 reply; 7+ messages in thread
From: Mathieu Basille @ 2017-02-02 16:54 UTC (permalink / raw)
To: 25609
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!
(of course, this example mostly uses empty files/folders, but that's
really just for the demonstration.)
Mathieu.
In GNU Emacs 25.1.1 (x86_64-pc-linux-gnu, GTK+ Version 3.22.5)
of 2016-12-31, modified by Debian built on binet
Windowing system distributor 'The X.Org Foundation', version 11.0.11900000
System Description: Debian GNU/Linux 9.0 (stretch)
Configured using:
'configure --build x86_64-linux-gnu --prefix=/usr
--sharedstatedir=/var/lib --libexecdir=/usr/lib
--localstatedir=/var/lib --infodir=/usr/share/info
--mandir=/usr/share/man --with-pop=yes
--enable-locallisppath=/etc/emacs25:/etc/emacs:/usr/local/share/emacs/25.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/25.1/site-lisp:/usr/share/emacs/site-lisp
--with-sound=alsa --build x86_64-linux-gnu --prefix=/usr
--sharedstatedir=/var/lib --libexecdir=/usr/lib
--localstatedir=/var/lib --infodir=/usr/share/info
--mandir=/usr/share/man --with-pop=yes
--enable-locallisppath=/etc/emacs25:/etc/emacs:/usr/local/share/emacs/25.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/25.1/site-lisp:/usr/share/emacs/site-lisp
--with-sound=alsa --with-x=yes --with-x-toolkit=gtk3
--with-toolkit-scroll-bars 'CFLAGS=-g -O2
-fdebug-prefix-map=/build/emacs25-4Gc0bO/emacs25-25.1+1=.
-fstack-protector-strong
-Wformat -Werror=format-security -Wall' 'CPPFLAGS=-Wdate-time
-D_FORTIFY_SOURCE=2' LDFLAGS=-Wl,-z,relro'
Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GCONF GSETTINGS
NOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11
Important settings:
value of $LC_MONETARY: en_US.UTF-8
value of $LC_NUMERIC: en_US.UTF-8
value of $LC_TIME: en_US.UTF-8
value of $LANG: en_US.UTF-8
locale-coding-system: utf-8-unix
Major mode: Emacs-Lisp
Minor modes in effect:
diff-auto-refine-mode: t
tooltip-mode: t
global-eldoc-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
line-number-mode: t
transient-mark-mode: t
Recent messages:
Loading /etc/emacs/site-start.d/50latex-cjk-common.el (source)...
Loading cjk-enc...done
Loading /etc/emacs/site-start.d/50latex-cjk-common.el (source)...done
Loading /etc/emacs/site-start.d/50latex-cjk-thai.el (source)...done
Loading /etc/emacs/site-start.d/50texlive-lang-english.el (source)...done
Saving file /home/mathieu/.emacs.d/init.el...
Wrote /home/mathieu/.emacs.d/init.el [2 times]
For information about GNU Emacs and the GNU system, type C-h C-a.
Making completion list...
ad-handle-definition: ‘ido-completing-read’ got redefined
Load-path shadows:
/usr/share/emacs/25.1/site-lisp/debian-startup hides
/usr/share/emacs/site-lisp/debian-startup
/usr/share/emacs25/site-lisp/cmake-data/cmake-mode hides
/usr/share/emacs/site-lisp/cmake-mode
/usr/share/emacs25/site-lisp/latex-cjk-thai/thai-word hides
/usr/share/emacs/25.1/lisp/language/thai-word
Features:
(shadow sort mail-extr emacsbug message dired format-spec rfc822 mml
mml-sec password-cache epg gnus-util mm-decode mm-bodies mm-encode
mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047
rfc2045 ietf-drums mm-util help-fns mail-prsvr mail-utils finder-inf
tex-site edmacro kmacro advice info vc-git diff-mode easy-mmode package
epg-config seq byte-opt gv bytecomp byte-compile cl-extra help-mode
easymenu cconv cl-loaddefs pcase cl-lib time-date mule-util tooltip
eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list newcomment elisp-mode lisp-mode prog-mode register page
menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core frame cl-generic cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese charscript case-table epa-hook jka-cmpr-hook help
simple abbrev minibuffer cl-preloaded nadvice loaddefs button faces
cus-face macroexp files text-properties overlay sha1 md5 base64 format
env code-pages mule custom widget hashtable-print-readable backquote
dbusbind inotify dynamic-setting system-font-setting font-render-setting
move-toolbar gtk x-toolkit x multi-tty make-network-process emacs)
Memory information:
((conses 16 113475 4970)
(symbols 48 23037 0)
(miscs 40 89 207)
(strings 32 26429 5656)
(string-bytes 1 819950)
(vectors 16 15640)
(vector-slots 8 474307 2835)
(floats 8 202 18)
(intervals 56 314 0)
(buffers 976 20))
--
Ce message est signé pour en assurer l'authenticité.
Pour une correspondance avec moi réellement privée,
utilisez ma clé publique pour chiffrer vos messages :
http://mathieu.basille.net/pub.asc
Plus d'infos : http://mzl.la/1BsOGiZ
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#25609: 25.1; Dired: Copy folder with 'dired-dwim-target t' results in nested copy
2017-02-02 16:54 bug#25609: 25.1; Dired: Copy folder with 'dired-dwim-target t' results in nested copy Mathieu Basille
@ 2017-02-04 11:59 ` Tino Calancha
2017-02-04 18:13 ` Mathieu Basille
2017-02-20 5:32 ` Tino Calancha
0 siblings, 2 replies; 7+ messages in thread
From: Tino Calancha @ 2017-02-04 11:59 UTC (permalink / raw)
To: Mathieu Basille; +Cc: 25609, tino.calancha
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))
--
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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* bug#25609: 25.1; Dired: Copy folder with 'dired-dwim-target t' results in nested copy
2017-02-04 11:59 ` Tino Calancha
@ 2017-02-04 18:13 ` Mathieu Basille
2017-02-04 18:23 ` Tino Calancha
2017-02-20 5:32 ` Tino Calancha
1 sibling, 1 reply; 7+ messages in thread
From: Mathieu Basille @ 2017-02-04 18:13 UTC (permalink / raw)
To: Tino Calancha; +Cc: 25609
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))
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#25609: 25.1; Dired: Copy folder with 'dired-dwim-target t' results in nested copy
2017-02-04 18:13 ` Mathieu Basille
@ 2017-02-04 18:23 ` Tino Calancha
2017-02-04 18:26 ` Mathieu Basille
0 siblings, 1 reply; 7+ messages in thread
From: Tino Calancha @ 2017-02-04 18:23 UTC (permalink / raw)
To: Mathieu Basille; +Cc: 25609, Tino Calancha
On Sat, 4 Feb 2017, Mathieu Basille wrote:
> Thanks for looking it up! Do you know when/if this patch will be available?
Thanks to you for reporting the issue. It has being there a while and
nobody notice.
The next release, 25.2, will fix just bugs added in 25.1; that means the
fix to this bug need to wait until Emacs 26.1.
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#25609: 25.1; Dired: Copy folder with 'dired-dwim-target t' results in nested copy
2017-02-04 11:59 ` Tino Calancha
2017-02-04 18:13 ` Mathieu Basille
@ 2017-02-20 5:32 ` Tino Calancha
2017-02-27 7:35 ` Tino Calancha
1 sibling, 1 reply; 7+ messages in thread
From: Tino Calancha @ 2017-02-20 5:32 UTC (permalink / raw)
To: 25609; +Cc: tino.calancha
Tino Calancha <tino.calancha@gmail.com> writes:
> Same behaviour in Emacs-24 and master branch.
> Following patch works to me:
Added a test.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
From 2795fd89177714712c2245294d79241d6dd36c70 Mon Sep 17 00:00:00 2001
From: Tino Calancha <tino.calancha@gmail.com>
Date: Mon, 20 Feb 2017 14:27:12 +0900
Subject: [PATCH] Choose the right target dir on dired operations
Prevent from changing the input target dir
when dired-dwim-target is non-nil (Bug#25609).
* lisp/dired-aux.el (dired-do-create-files):
If dired-dwim-target is non-nil, then bind 'default' to nil.
* test/lisp/dired-tests.el (dired-test-bug25609): Add test.
---
lisp/dired-aux.el | 1 +
test/lisp/dired-tests.el | 32 ++++++++++++++++++++++++++++++++
2 files changed, 33 insertions(+)
diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index caa3b45705..d7ca052787 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) ; Bug#25609
(expand-file-name (file-name-nondirectory (car fn-list))
target-dir)))
(defaults (dired-dwim-target-defaults fn-list target-dir))
diff --git a/test/lisp/dired-tests.el b/test/lisp/dired-tests.el
index 489f8fdfea..1863864abd 100644
--- a/test/lisp/dired-tests.el
+++ b/test/lisp/dired-tests.el
@@ -20,6 +20,7 @@
;;; Code:
(require 'ert)
(require 'dired)
+(require 'nadvice)
(ert-deftest dired-autoload ()
@@ -52,5 +53,36 @@
;; Clean up
(delete-directory dir 'recursive))))
+(ert-deftest dired-test-bug25609 ()
+ "Test for http://debbugs.gnu.org/25609 ."
+ (let* ((from (make-temp-file "foo" 'dir))
+ (to (make-temp-file "bar" 'dir))
+ (target (expand-file-name (file-name-nondirectory from) to))
+ (nested (expand-file-name (file-name-nondirectory from) target))
+ (dired-dwim-target t)
+ (dired-recursive-copies 'always)) ; Don't prompt me.
+ (advice-add 'dired-query ; Don't ask confirmation to overwrite a file.
+ :override
+ (lambda (sym prompt &rest args) (setq dired-query t))
+ '((name . "advice-dired-query")))
+ (advice-add 'completing-read ; Just return init.
+ :override
+ (lambda (prompt coll &optional pred match init hist def inherit keymap)
+ init)
+ '((name . "advice-completing-read")))
+ (dired to)
+ (dired-other-window temporary-file-directory)
+ (dired-goto-file from)
+ (dired-do-copy)
+ (dired-do-copy); Again.
+ (unwind-protect
+ (progn
+ (should (file-exists-p target))
+ (should-not (file-exists-p nested)))
+ (delete-directory from 'recursive)
+ (delete-directory to 'recursive)
+ (advice-remove 'dired-query "advice-dired-query")
+ (advice-remove 'completing-read "advice-completing-read"))))
+
(provide 'dired-tests)
;; dired-tests.el ends here
--
2.11.0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
In GNU Emacs 26.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.7)
of 2017-02-20
Repository revision: 0a670690f19bf263dadfe387e5bb22311e3b5231
^ permalink raw reply related [flat|nested] 7+ messages in thread
* bug#25609: 25.1; Dired: Copy folder with 'dired-dwim-target t' results in nested copy
2017-02-20 5:32 ` Tino Calancha
@ 2017-02-27 7:35 ` Tino Calancha
0 siblings, 0 replies; 7+ messages in thread
From: Tino Calancha @ 2017-02-27 7:35 UTC (permalink / raw)
To: 25609-done
Tino Calancha <tino.calancha@gmail.com> writes:
> Tino Calancha <tino.calancha@gmail.com> writes:
>
>> Same behaviour in Emacs-24 and master branch.
>> Following patch works to me:
> Added a test.
Fixed in master branch as commit 841e3e377c97142cfe76b9d91467f439198f5e39
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-02-27 7:35 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-02 16:54 bug#25609: 25.1; Dired: Copy folder with 'dired-dwim-target t' results in nested copy Mathieu Basille
2017-02-04 11:59 ` Tino Calancha
2017-02-04 18:13 ` Mathieu Basille
2017-02-04 18:23 ` Tino Calancha
2017-02-04 18:26 ` Mathieu Basille
2017-02-20 5:32 ` Tino Calancha
2017-02-27 7:35 ` Tino Calancha
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.