all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Tino Calancha <tino.calancha@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 30624@debbugs.gnu.org, Amos Bird <amosbird@gmail.com>
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	[thread overview]
Message-ID: <87woxqxqk1.fsf@gmail.com> (raw)
In-Reply-To: <alpine.DEB.2.20.1804012004310.20391@calancha-pc> (Tino Calancha's message of "Sun, 1 Apr 2018 20:08:07 +0900 (JST)")

Tino Calancha <tino.calancha@gmail.com> 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 <tino.calancha@gmail.com>
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





  reply	other threads:[~2018-04-02  2:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-27  2:29 bug#30624: 27.0.50; dired-create-destination-dirs doesn't work when renaming more than one file Amos Bird
2018-03-19  9:48 ` Eli Zaretskii
2018-04-01  9:52   ` Eli Zaretskii
2018-04-01 11:08   ` Tino Calancha
2018-04-02  2:58     ` Tino Calancha [this message]
2018-04-02  6:14       ` Eli Zaretskii
2018-04-05  3:22         ` 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=87woxqxqk1.fsf@gmail.com \
    --to=tino.calancha@gmail.com \
    --cc=30624@debbugs.gnu.org \
    --cc=amosbird@gmail.com \
    --cc=eliz@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.