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: Sun, 1 Apr 2018 20:08:07 +0900 (JST) Message-ID: References: <87muzv413e.fsf@gmail.com> <83in9so0p4.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII X-Trace: blaine.gmane.org 1522580833 15333 195.159.176.226 (1 Apr 2018 11:07:13 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 1 Apr 2018 11:07:13 +0000 (UTC) User-Agent: Alpine 2.20 (DEB 67 2015-01-07) Cc: Amos Bird , 30624@debbugs.gnu.org, Tino Calancha To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Apr 01 13:07:09 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 1f2apI-0003qF-Pf for geb-bug-gnu-emacs@m.gmane.org; Sun, 01 Apr 2018 13:07:09 +0200 Original-Received: from localhost ([::1]:52743 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f2arK-0003mb-CO for geb-bug-gnu-emacs@m.gmane.org; Sun, 01 Apr 2018 07:09:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55550) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f2arB-0003lo-U2 for bug-gnu-emacs@gnu.org; Sun, 01 Apr 2018 07:09:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f2ar8-0006Ke-Ky for bug-gnu-emacs@gnu.org; Sun, 01 Apr 2018 07:09:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:53864) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f2ar8-0006KV-HH for bug-gnu-emacs@gnu.org; Sun, 01 Apr 2018 07:09:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1f2ar8-00088Q-44 for bug-gnu-emacs@gnu.org; Sun, 01 Apr 2018 07:09: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: Sun, 01 Apr 2018 11:09:02 +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.152258089931223 (code B ref 30624); Sun, 01 Apr 2018 11:09:02 +0000 Original-Received: (at 30624) by debbugs.gnu.org; 1 Apr 2018 11:08:19 +0000 Original-Received: from localhost ([127.0.0.1]:33528 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1f2aqQ-00087X-Og for submit@debbugs.gnu.org; Sun, 01 Apr 2018 07:08:18 -0400 Original-Received: from mail-pg0-f52.google.com ([74.125.83.52]:46147) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1f2aqP-00087K-Iw for 30624@debbugs.gnu.org; Sun, 01 Apr 2018 07:08:17 -0400 Original-Received: by mail-pg0-f52.google.com with SMTP id t12so7406405pgp.13 for <30624@debbugs.gnu.org>; Sun, 01 Apr 2018 04:08:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=fSim63etigp2Tg7HNOFmddHKSnYMGzFNxbWQwPDouGs=; b=OUcZlyU2SrRNJ6vLCdE/qkiRgn6sOZkJID5VtBq22iJXFXu+JZjNtZmVAxhnXE/CyM X5JvdczQwZRjgaL3dZ5gKl6dY6uOfqLQU9u1Bta9TJ+KHmADL2JwYgvw6wxczsKW2D6f IQyvEYMH42WSydhf2AWWIlbQD7d5Ebe+Ztmh2XmcqC0P2dOjjiYmxeEDmrNW0uxHw71R Sjp5dtqtq0HNYUCUSTEB9A6+vQbCCpOop4nJT4QxLykVchWq0mpLPb26TUh5LjfF4Hfk RhTEYJZW/jqUrTfqDS7OzHrVyGQx3P2dRt/Gg1J+KjCXqCDm9v1L17ors/3khfuNiRuA 382Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=fSim63etigp2Tg7HNOFmddHKSnYMGzFNxbWQwPDouGs=; b=PS42ZdmknHThzpdN2MQ4K752+RT04zE3fdA4jVt1uq82mqR7UImLTDuPKRMwQjZMRL PIFUBIqdt6gBwtiWEXGQ2+rY+OXkeM1fsVtQZkXRb49zrW2yqiVAZfbNENRcPJPgsTLo mjX5yOo0XzVRp9z+JTk57wEWy5i8iwIAR16nKOo8pdP/0Llj/376pzTdaeOjnBgLq5Fu jOPGB5hp7Uk1fl5rNq8aNjPxs03nr1GvzGsH//z8zndwrAtciVocFgFDbkfvJRdiDgNu F6L6v5OKUEQKApIuxhIgTNP3UrqKyPq0A0Mo152JwnoA8FnFBKBghargVmOY9OS5CNct C3kQ== X-Gm-Message-State: AElRT7EqOmG1jVOBEee4CD+8/RwKgRpLCbhWdiBL3rzsqZNbQsW1sKTM P941uEuCwrhtC1PxxZYf/nk= X-Google-Smtp-Source: AIpwx4+Qn23JCy39dTtyRKCKVQsSvAGzHcffLV4GSkySEB933jFCYW76A/0DpzxsTM5uy6SnGujzVQ== X-Received: by 10.99.182.6 with SMTP id j6mr3747966pgf.122.1522580891795; Sun, 01 Apr 2018 04:08:11 -0700 (PDT) Original-Received: from calancha-pc ([240f:6e:ee9a:1:adc4:139f:709c:10b]) by smtp.gmail.com with ESMTPSA id q15sm19644818pgv.49.2018.04.01.04.08.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Apr 2018 04:08:10 -0700 (PDT) X-Google-Original-From: Tino Calancha X-X-Sender: calancha@calancha-pc In-Reply-To: <83in9so0p4.fsf@gnu.org> 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:144780 Archived-At: On Mon, 19 Mar 2018, Eli Zaretskii wrote: >> From: Amos Bird >> Date: Tue, 27 Feb 2018 10:29:09 +0800 >> >> I'm using emacs 27.0.50 and have dired-create-destination-dirs set >> to 'always. >> When renaming more than one files to a new directory, dired throws >> an error at >> /usr/local/share/emacs/27.0.50/lisp/dired-aux.el.gz:1891 . It >> fails early before >> it has time to check whether a new directory should be created. Thank you very much for your report Amos! I would be enough to call `dired-maybe-create-dirs' right before binding `into-dir', as follows: --8<-----------------------------cut here---------------start------------->8--- commit a89518cfb2f57509d3f0e31ddfe097f56e95c484 Author: Tino Calancha Date: Sun Apr 1 19:54:23 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). 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,29 +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)) --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-03-30 built on calancha-pc Repository revision: f759c5cfe4651af5f64fac2492fa362f8d383bd5