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#30624: 27.0.50; dired-create-destination-dirs doesn't work when renaming more than one file Date: Mon, 02 Apr 2018 11:58:22 +0900 Message-ID: <87woxqxqk1.fsf@gmail.com> References: <87muzv413e.fsf@gmail.com> <83in9so0p4.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1522637830 16298 195.159.176.226 (2 Apr 2018 02:57:10 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 2 Apr 2018 02:57:10 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 30624@debbugs.gnu.org, Amos Bird To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Apr 02 04:57:05 2018 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 1f2peb-00049a-Iv for geb-bug-gnu-emacs@m.gmane.org; Mon, 02 Apr 2018 04:57:05 +0200 Original-Received: from localhost ([::1]:54989 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f2pgf-0003e0-DB for geb-bug-gnu-emacs@m.gmane.org; Sun, 01 Apr 2018 22:59:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38745) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f2pgX-0003dK-P7 for bug-gnu-emacs@gnu.org; Sun, 01 Apr 2018 22:59:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f2pgU-0006Pc-N1 for bug-gnu-emacs@gnu.org; Sun, 01 Apr 2018 22:59:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:54914) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f2pgU-0006PS-Hw for bug-gnu-emacs@gnu.org; Sun, 01 Apr 2018 22:59:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1f2pgT-0006NW-Vq for bug-gnu-emacs@gnu.org; Sun, 01 Apr 2018 22:59:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 02 Apr 2018 02:59:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 30624 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 30624-submit@debbugs.gnu.org id=B30624.152263791924490 (code B ref 30624); Mon, 02 Apr 2018 02:59:01 +0000 Original-Received: (at 30624) by debbugs.gnu.org; 2 Apr 2018 02:58:39 +0000 Original-Received: from localhost ([127.0.0.1]:34578 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1f2pg7-0006Mv-4v for submit@debbugs.gnu.org; Sun, 01 Apr 2018 22:58:39 -0400 Original-Received: from mail-pf0-f176.google.com ([209.85.192.176]:38591) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1f2pg5-0006Mi-JP for 30624@debbugs.gnu.org; Sun, 01 Apr 2018 22:58:38 -0400 Original-Received: by mail-pf0-f176.google.com with SMTP id y69so8617818pfb.5 for <30624@debbugs.gnu.org>; Sun, 01 Apr 2018 19:58:37 -0700 (PDT) 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=lNaWXpM4B8+MihLd5kg+/kxoTiwJFag9IV348YkItl4=; b=J5rS9u6sQyuULkMgrwMkSiMvuhRb9esACoroulvYsYnaWgPjN5LdxHr3FmExjyfKR/ 7+Iwlb+I85kYSjLjw14z+IhBpA52D3AH4dILEk6LUPiX9CvwgyuMdIScdDboNJuBQ0yf zXqRFgd+s5wsxqYRFRGCgrxyypJWEK4K1gcakBDX90E1WMx+r7x3NeUQZoHLkzQcnEIm K/lZsc4Stxmg9M7wJIsSh1tCCfxDXRcSqzFZcqckcnvGpXLTvMqq+jp0WbQ7eThLSZ0z ciQ5L95dlnMtckskiPW4O2Me+tsXP1ZALRTda4d8CXSD30YAmp8PIMAKKu4PjoQnyPoy 5syw== 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=lNaWXpM4B8+MihLd5kg+/kxoTiwJFag9IV348YkItl4=; b=ndT4pJtBpmvu8GT7Wytvs4Din5grXCebr3PkbG4V2fBAPZRUlh8+yUWOKmqh55PIhB /UtyeTqaay3dWSu0fPUimgrH1FjMfpT29XITRuGBdbgOFdU//AuJG8ZfDW3NVaNH+gic A4bW5tVExPAx3WiQOl0qX9kvkxAHtbiGHyeGLq7l45T6of0rYwdluW2CeM4RfqbCRUJh 1ETvgvKAkf8uWrZGj8JLLcc1S9dvMeAx0ChcpoUEh/Yv9jnvkQCDZ4eDg+AQj2yYf/XU +xjrgdsZsZaihD7OMA93LSYT6b4O9CUiRQ83pI5KRFMBktCh7E2KsFx5gJCcjIenzBym jXVg== X-Gm-Message-State: AElRT7EoY28tBAZ7KG0i8bmx+iIVOR0Auu766IgToQWLqoOLuJpOnFZq XMnmJxoz+g/Fs1VLZUHehQo= X-Google-Smtp-Source: AIpwx4/Zvo+w+HCGJ+Qm+Va3X+Sm2KJfh9z98hPMDbBLiujvxPz2yQlE0sfnvkMbU6Un1YjRSPfVbA== X-Received: by 10.101.89.6 with SMTP id f6mr5090378pgu.178.1522637911601; Sun, 01 Apr 2018 19:58:31 -0700 (PDT) Original-Received: from calancha-pc ([210.160.37.26]) by smtp.gmail.com with ESMTPSA id p89sm28626414pfk.63.2018.04.01.19.58.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 01 Apr 2018 19:58:30 -0700 (PDT) In-Reply-To: (Tino Calancha's message of "Sun, 1 Apr 2018 20:08:07 +0900 (JST)") 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:144784 Archived-At: Tino Calancha writes: > I would be enough to call `dired-maybe-create-dirs' right before > binding `into-dir', as follows: Added a test for this bug (dired-test-bug30624): --8<-----------------------------cut here---------------start------------->8--- commit f7560f9bbbb2470378a1b31b52f6c3ff4cd6a7d7 Author: Tino Calancha Date: Mon Apr 2 11:54:58 2018 +0900 Honor dired-create-destination-dirs if copying/renaming >1 files Check `dired-create-destination-dirs' when the user wants to copy/rename several files. * lisp/dired-aux.el (dired-do-create-files): Call `dired-maybe-create-dirs' right before bind `into-dir' (Bug#30624). * test/lisp/dired-aux-tests.el (dired-test-bug30624): Add test. diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index e8b5e6755e..821b7d7975 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el @@ -1864,28 +1864,31 @@ dired-do-create-files (dired-mark-read-file-name (concat (if dired-one-file op1 operation) " %s to: ") target-dir op-symbol arg rfn-list default)))) - (into-dir (cond ((null how-to) - ;; Allow users to change the letter case of - ;; a directory on a case-insensitive - ;; filesystem. If we don't test these - ;; conditions up front, file-directory-p - ;; below will return t on a case-insensitive - ;; filesystem, and Emacs will try to move - ;; foo -> foo/foo, which fails. - (if (and (file-name-case-insensitive-p (car fn-list)) - (eq op-symbol 'move) - dired-one-file - (string= (downcase - (expand-file-name (car fn-list))) - (downcase - (expand-file-name target))) - (not (string= - (file-name-nondirectory (car fn-list)) - (file-name-nondirectory target)))) - nil - (file-directory-p target))) - ((eq how-to t) nil) - (t (funcall how-to target))))) + (into-dir + (progn + (unless dired-one-file (dired-maybe-create-dirs target)) + (cond ((null how-to) + ;; Allow users to change the letter case of + ;; a directory on a case-insensitive + ;; filesystem. If we don't test these + ;; conditions up front, file-directory-p + ;; below will return t on a case-insensitive + ;; filesystem, and Emacs will try to move + ;; foo -> foo/foo, which fails. + (if (and (file-name-case-insensitive-p (car fn-list)) + (eq op-symbol 'move) + dired-one-file + (string= (downcase + (expand-file-name (car fn-list))) + (downcase + (expand-file-name target))) + (not (string= + (file-name-nondirectory (car fn-list)) + (file-name-nondirectory target)))) + nil + (file-directory-p target))) + ((eq how-to t) nil) + (t (funcall how-to target)))))) (if (and (consp into-dir) (functionp (car into-dir))) (apply (car into-dir) operation rfn-list fn-list target (cdr into-dir)) (if (not (or dired-one-file into-dir)) diff --git a/test/lisp/dired-aux-tests.el b/test/lisp/dired-aux-tests.el index ab6d1cb056..daf60f760e 100644 --- a/test/lisp/dired-aux-tests.el +++ b/test/lisp/dired-aux-tests.el @@ -93,6 +93,27 @@ with-dired-bug28834-test (should-error (dired-copy-file-recursive from to-cp nil)) (should-error (dired-rename-file from to-mv nil))))) +(ert-deftest dired-test-bug30624 () + "test for https://debbugs.gnu.org/30624 ." + (cl-letf* ((target-dir (make-temp-file "target" 'dir)) + ((symbol-function 'dired-mark-read-file-name) + (lambda (&rest _) target-dir)) + (inhibit-message t)) + ;; Delete target-dir: `dired-do-create-files' must recreate it. + (delete-directory target-dir) + (let ((file1 (make-temp-file "bug30624_file1")) + (file2 (make-temp-file "bug30624_file2")) + (dired-create-destination-dirs 'always) + (buf (dired temporary-file-directory))) + (unwind-protect + (progn + (dired-revert) + (dired-mark-files-regexp "bug30624_file") + (should (dired-do-create-files 'copy 'dired-copy-file "Copy" nil))) + (delete-directory target-dir 'recursive) + (mapc #'delete-file `(,file1 ,file2)) + (kill-buffer buf))))) + (provide 'dired-aux-tests) ;; dired-aux-tests.el ends here --8<-----------------------------cut here---------------end--------------->8--- In GNU Emacs 27.0.50 (build 10, x86_64-pc-linux-gnu, GTK+ Version 3.22.11) of 2018-04-02 built on calancha-pc Repository revision: 7bedc8812bd7ca1d9cf36636322068b28b690a85