From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tino Calancha Newsgroups: gmane.emacs.bugs 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 Message-ID: <87shn9a0m6.fsf@calancha-pc> References: <4cee1f04-3644-ba9f-1542-d29108cd2472@basille.net> <87mve2qi86.fsf@calancha-pc> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1487568799 28875 195.159.176.226 (20 Feb 2017 05:33:19 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 20 Feb 2017 05:33:19 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) Cc: tino.calancha@gmail.com To: 25609@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Feb 20 06:33:15 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cfgb4-0006tE-FP for geb-bug-gnu-emacs@m.gmane.org; Mon, 20 Feb 2017 06:33:14 +0100 Original-Received: from localhost ([::1]:36197 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cfgb8-0007R1-Jy for geb-bug-gnu-emacs@m.gmane.org; Mon, 20 Feb 2017 00:33:18 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49213) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cfgay-0007PJ-6J for bug-gnu-emacs@gnu.org; Mon, 20 Feb 2017 00:33:09 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cfgav-0006J2-31 for bug-gnu-emacs@gnu.org; Mon, 20 Feb 2017 00:33:08 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:48532) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cfgat-0006Ib-K2 for bug-gnu-emacs@gnu.org; Mon, 20 Feb 2017 00:33:05 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cfgas-0004ks-E5 for bug-gnu-emacs@gnu.org; Mon, 20 Feb 2017 00:33:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 20 Feb 2017 05:33:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 25609 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 25609-submit@debbugs.gnu.org id=B25609.148756874918236 (code B ref 25609); Mon, 20 Feb 2017 05:33:02 +0000 Original-Received: (at 25609) by debbugs.gnu.org; 20 Feb 2017 05:32:29 +0000 Original-Received: from localhost ([127.0.0.1]:46731 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cfgaK-0004k3-TZ for submit@debbugs.gnu.org; Mon, 20 Feb 2017 00:32:29 -0500 Original-Received: from mail-pg0-f47.google.com ([74.125.83.47]:35058) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cfgaJ-0004jr-CD for 25609@debbugs.gnu.org; Mon, 20 Feb 2017 00:32:27 -0500 Original-Received: by mail-pg0-f47.google.com with SMTP id b129so14446309pgc.2 for <25609@debbugs.gnu.org>; Sun, 19 Feb 2017 21:32:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=4EPR2z3fl0aV9tF6ScPTIllzpyJqx+eLGXlHHyNQzfY=; b=AKcy+RtEFbjnKQcttLR0PpaperpHZEGmMHzCBp/1R/y/yBLKmtvXlEaUXWn1rJfyVk tAWTeXP8Tk5O0//5yqcsCOjEPEwduxJ73I6TYDN2Hv+JrYTNkbn8wbOL6QWlWCLruYI/ 8n4V38X53UVFA7Vvzo2jgswfJI9Xf4aB7rcTPKFE1SnDyq/6lXWD2NZADqpvsn5KZHHI L9pKyStI459rzSziz0M+sKBqQqjvTEyuMjwN9+nQ9rUgMSCrIspkJZSY1EJ73gO2x2eU gDgJICCDkdV7vdrHvzIX0Pc0PegBEnNNl8cWLc++ZlCCa6++DMMwvlThvn0yLhaZxYnW p/5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=4EPR2z3fl0aV9tF6ScPTIllzpyJqx+eLGXlHHyNQzfY=; b=c9EzeP13bqCrF0YpXX/5tUvZR/OQIwgCnKudf9Vn3Ocv9WNQRDttoWsokFkule0Gbv w7xV4ogWpPTB1xvAVExgsCcZV7UIfqvJ/PnxUQjclixjco9eur/CYOeH2QXoP2+G0uua vTQBgYytP53U1+SlAvEFPtoFrmFrJT85IlUzWN9hLZdHIJo0CyRbex6Dlvd3YfVs05Gd 5atES5z5vU4bkDgw11/aKxklbp1N3ha4K1hg5549g4EBUFpMtuyiOa3DuNwaFpzWvqnW 2ngWqLG+mSl3km9ULnlVPTnaJ5AHh0EVoH/voAM390pezNStqDCjGMPlMGKif9n2C5Lp bOmg== X-Gm-Message-State: AMke39nYDukZ9nq8xLnPFKVIdA5NyqT0ZwdMPUA1yDZTDvq/4Y0ohsFw7Ig89RD5xpfKbw== X-Received: by 10.98.71.7 with SMTP id u7mr24154503pfa.76.1487568741608; Sun, 19 Feb 2017 21:32:21 -0800 (PST) Original-Received: from calancha-pc (104.81.147.124.dy.bbexcite.jp. [124.147.81.104]) by smtp.gmail.com with ESMTPSA id t22sm32017485pfa.114.2017.02.19.21.32.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 19 Feb 2017 21:32:20 -0800 (PST) In-Reply-To: <87mve2qi86.fsf@calancha-pc> (Tino Calancha's message of "Sat, 04 Feb 2017 20:59:53 +0900") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:129563 Archived-At: Tino Calancha 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 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