Subject: 25.1; Dired: Copy folder with 'dired-dwim-target t' results in nested copy

From: Mathieu Basille <[email-masked]>
Date: Thu, 2 Feb 2017 11:54:00 -0500

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