From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.devel Subject: Re: PR: dired-do-create-files now checks for trailing slashes in the target Date: Sun, 05 Dec 2021 13:12:31 +0100 Message-ID: <8735n7utvv.fsf@gnu.org> References: <83ee97il43.fsf@gnu.org> <87zgrv33mf.fsf@gnu.org> <838rzfijnj.fsf@gnu.org> <87r1d73312.fsf@gnu.org> <837deziiwz.fsf@gnu.org> <87ee97bgxt.fsf@gnus.org> <87fstn2ydc.fsf@gnu.org> <87bl4a7g2m.fsf@gnus.org> <87sfxmqwdr.fsf@gnu.org> <87bl4a2nng.fsf@gnus.org> <87lf3ew3k5.fsf@gnu.org> <83wnmyf3u3.fsf@gnu.org> <87h7e2vvrp.fsf@gnu.org> <83pmsqez1d.fsf@gnu.org> <87cznimxbd.fsf@gnus.org> <83pmrik2r9.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16855"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.7.5; emacs 29.0.50 Cc: Eli Zaretskii , emacs-devel@gnu.org, larsi@gnus.org, stefankangas@gmail.com To: Rudi C Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Dec 05 13:20:19 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mtqV7-0004As-Ro for ged-emacs-devel@m.gmane-mx.org; Sun, 05 Dec 2021 13:20:18 +0100 Original-Received: from localhost ([::1]:48648 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mtqV6-0006hW-Mi for ged-emacs-devel@m.gmane-mx.org; Sun, 05 Dec 2021 07:20:16 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:41958) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mtqTy-0005zd-J8 for emacs-devel@gnu.org; Sun, 05 Dec 2021 07:19:06 -0500 Original-Received: from [2001:470:142:3::e] (port=38248 helo=fencepost.gnu.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mtqTy-0007cg-8W; Sun, 05 Dec 2021 07:19:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-reply-to:Date:Subject:To:From: References; bh=9OGZTQTB1RGI97ic2AsJMVFw3s76rc+fb9HQ/SqB404=; b=OmNhds89BlgLVb oqoTX9xXRD8S8cD7eU61Bdx0NFM3DhyDdIGuqwyHXGQlMiYGQ02/mFD+wN9WsDva9EN2pZbQCX3+s pMgAspdhvtU4v+frynF8DhUqtjoi/xoeWB6sV/ALnFDiqec6Zvgf/yihTTMV+Qr4mDxEm3pEqShNJ qdybTgJIbV7+H92nuW7rdRHndq1BWT7N1JHGmQXtgDzneP4ZJbvpv3ao2kIPMT8eg7+iqrfSyRra7 XwHGy2ggMke3E/vFyhhligbTHG4qPTy0EHpQ9mujovDrIDpIByObiJoCIe/VFJuOY8R7zaQUxL0L9 p/qLsjSwfU+GpfbPPsUQ==; Original-Received: from auth2-smtp.messagingengine.com ([66.111.4.228]:49989) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mtqTx-0006p8-Te; Sun, 05 Dec 2021 07:19:05 -0500 Original-Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailauth.nyi.internal (Postfix) with ESMTP id 17A2A27C0054; Sun, 5 Dec 2021 07:19:05 -0500 (EST) Original-Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Sun, 05 Dec 2021 07:19:05 -0500 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddrjedugdefjecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpehffgfhvffuffgjkfggtgesmhdtreertdertdenucfhrhhomhepvfgrshhsihhl ohcujfhorhhnuceothhsughhsehgnhhurdhorhhgqeenucggtffrrghtthgvrhhnpeevfe evhfejkeeikeeuleejveejgffhffdtffdutdevtddtueefveffvdefudfhheenucevlhhu shhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehthhhorhhnodhmvg hsmhhtphgruhhthhhpvghrshhonhgrlhhithihqdekieejfeekjeekgedqieefhedvleek qdhtshguhheppehgnhhurdhorhhgsehfrghsthhmrghilhdrfhhm X-ME-Proxy: Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 5 Dec 2021 07:19:03 -0500 (EST) In-reply-to: X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:280992 Archived-At: --=-=-= Content-Type: text/plain Rudi C writes: Hi all, > Okay, I have attached a new patch (no need for the previous patches). since it seems that no progress has been made on this issue and the only remaining stuff is just adapting the patch to our conventions, I reworked Rudi's last version of the patch (while keeping him as the author, of course). Would the following be acceptable for master? If so, I'd volunteer to extend the dired docs wrt. the new feature. (I have to confess I've made the new option's name longer again but IMHO a slightly longer but more descriptive name is no real burden. Especially since it pairs with dired-create-destination-dirs, it's good when it's named very similarly.) Thanks, Tassilo --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Added-dired-create-destination-dirs-on-trailing-dirs.patch >From 8d957061a9cd0e6924558c2634932a8d08a92975 Mon Sep 17 00:00:00 2001 From: NightMachinary Date: Tue, 9 Nov 2021 16:19:45 +0330 Subject: [PATCH] Added dired-create-destination-dirs-on-trailing-dirsep * lisp/dired-aux.el (dired-create-destination-dirs-on-trailing-dirsep): New customization option. (dired-do-create-files): Use it. (dired-create-destination-dirs): Mention the new option in the docstring. --- lisp/dired-aux.el | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index 588551a641..af7b160c1a 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el @@ -1787,13 +1787,46 @@ dired-create-destination-dirs "Whether Dired should create destination dirs when copying/removing files. If nil, don't create them. If `always', create them without asking. -If `ask', ask for user confirmation." +If `ask', ask for user confirmation. + +Also see `dired-create-destination-dirs-on-trailing-dirsep'." :type '(choice (const :tag "Never create non-existent dirs" nil) (const :tag "Always create non-existent dirs" always) (const :tag "Ask for user confirmation" ask)) :group 'dired :version "27.1") +(defcustom dired-create-destination-dirs-on-trailing-dirsep nil + "If non-nil, treat a trailing slash at queried destination dir specially. + +If this variable is non-nil and a single destination filename is +queried which ends in a directory separator (/), it will be +treated as a non-existent directory and acted on according to +`dired-create-destination-dirs'. + +This option is only relevant if `dired-create-destination-dirs' +is non-nil, too. + +For example, if both `dired-create-destination-dirs' and this +option are non-nil, renaming a directory named `old_name' to +`new_name/' (note the trailing directory separator) where +`new_name' does not exists already, it will be created and +`old_name' be moved into it. If only `new_name' (without the +trailing /) is given or this option or +`dired-create-destination-dirs' is `nil', `old_name' will be +renamed to `new_name'." + :type '(choice + (const :tag + (concat "Do not treat destination dirs with a " + "trailing directory separator specially") + nil) + (const :tag + (concat "Treat destination dirs with trailing " + "directory separator specially") + t)) + :group 'dired + :version "29.1") + (defun dired-maybe-create-dirs (dir) "Create DIR if doesn't exist according to `dired-create-destination-dirs'." (when (and dired-create-destination-dirs (not (file-exists-p dir))) @@ -2163,7 +2196,12 @@ dired-do-create-files target-dir op-symbol arg rfn-list default)))) (into-dir (progn - (unless dired-one-file (dired-maybe-create-dirs target)) + (when + (or + (not dired-one-file) + (and dired-create-destination-dirs-on-trailing-dirsep + (directory-name-p target))) + (dired-maybe-create-dirs target)) (cond ((null how-to) ;; Allow users to change the letter case of ;; a directory on a case-insensitive -- 2.34.1 --=-=-=--