all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Tino Calancha <tino.calancha@gmail.com>
To: 25609@debbugs.gnu.org
Cc: tino.calancha@gmail.com
Subject: bug#25609: 25.1; Dired: Copy folder with 'dired-dwim-target t' results in nested copy
Date: Mon, 20 Feb 2017 14:32:17 +0900	[thread overview]
Message-ID: <87shn9a0m6.fsf@calancha-pc> (raw)
In-Reply-To: <87mve2qi86.fsf@calancha-pc> (Tino Calancha's message of "Sat, 04 Feb 2017 20:59:53 +0900")

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





  parent reply	other threads:[~2017-02-20  5:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2017-02-27  7:35     ` Tino Calancha

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=87shn9a0m6.fsf@calancha-pc \
    --to=tino.calancha@gmail.com \
    --cc=25609@debbugs.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.