unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Tassilo Horn <tsdh@gnu.org>
To: Rudi C <rudiwillalwaysloveyou@gmail.com>
Cc: Eli Zaretskii <eliz@gnu.org>,
	emacs-devel@gnu.org, larsi@gnus.org, stefankangas@gmail.com
Subject: Re: PR: dired-do-create-files now checks for trailing slashes in the target
Date: Sun, 05 Dec 2021 13:12:31 +0100	[thread overview]
Message-ID: <8735n7utvv.fsf@gnu.org> (raw)
In-Reply-To: <CAE9z9A1tvh=VAcSz-A5KA0eVH0aRvfbc5eswPzwhRmi=8sEiUQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 735 bytes --]

Rudi C <rudiwillalwaysloveyou@gmail.com> 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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Added-dired-create-destination-dirs-on-trailing-dirs.patch --]
[-- Type: text/x-patch, Size: 3331 bytes --]

From 8d957061a9cd0e6924558c2634932a8d08a92975 Mon Sep 17 00:00:00 2001
From: NightMachinary <rudiwillalwaysloveyou@gmail.com>
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


  parent reply	other threads:[~2021-12-05 12:12 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-28 17:50 PR: dired-do-create-files now checks for trailing slashes in the target Rudi C
2021-09-28 18:17 ` Stefan Kangas
2021-09-28 18:42   ` Rudi C
2021-09-28 19:03     ` Stefan Kangas
2021-09-28 19:38       ` Tassilo Horn
2021-09-28 20:07         ` Stefan Kangas
2021-09-28 20:23       ` Rudi C
2021-09-28 18:42   ` Eli Zaretskii
2021-09-28 19:29     ` Tassilo Horn
2021-09-28 19:55       ` Eli Zaretskii
2021-09-29  4:46         ` Tassilo Horn
2021-09-29 13:09           ` Eli Zaretskii
2021-09-29 13:20             ` Rudi C
2021-09-29 13:34               ` Eli Zaretskii
2021-09-29 13:37               ` Tassilo Horn
2021-09-29 13:42               ` Stefan Kangas
2021-09-29 13:53                 ` Tassilo Horn
2021-09-29 14:31                   ` Rudi C
2021-09-29 13:23             ` Tassilo Horn
2021-09-29 13:41               ` Eli Zaretskii
2021-09-29 13:42                 ` Tassilo Horn
2021-09-29 13:57                   ` Eli Zaretskii
2021-09-29 14:21                     ` Lars Ingebrigtsen
2021-09-29 15:04                       ` Stefan Kangas
2021-09-29 15:17                         ` Tassilo Horn
2021-09-30  6:06                           ` Lars Ingebrigtsen
2021-09-30  7:29                             ` Lars Ingebrigtsen
2021-09-30  8:32                             ` Tassilo Horn
2021-09-30 13:33                               ` Lars Ingebrigtsen
2021-09-30 14:10                                 ` Tassilo Horn
2021-09-30 16:03                                   ` Eli Zaretskii
2021-09-30 16:48                                     ` Tassilo Horn
2021-09-30 17:47                                       ` Eli Zaretskii
2021-09-30 18:52                                         ` Rudi C
2021-09-30 19:02                                           ` Eli Zaretskii
2021-11-01 15:37                                         ` Rudi C
2021-11-02 14:44                                           ` Lars Ingebrigtsen
2021-11-02 15:08                                             ` Rudi C
2021-11-02 15:15                                               ` Eli Zaretskii
2021-11-09 12:52                                                 ` Rudi C
2021-11-09 13:47                                                   ` Eli Zaretskii
2021-12-05 12:12                                                   ` Tassilo Horn [this message]
2021-12-05 13:26                                                     ` Rudi C
2021-12-05 17:00                                                       ` Tassilo Horn
2021-12-06  4:34                                                       ` Richard Stallman
2021-12-05 20:24                                                     ` Lars Ingebrigtsen
2021-12-06  6:01                                                       ` Tassilo Horn
2021-09-30 15:45                               ` [External] : " Drew Adams
2021-09-30 13:54                             ` Stefan Kangas
2021-09-30 13:59                               ` Lars Ingebrigtsen
2021-09-29 15:44                       ` Eli Zaretskii
2021-09-29 17:01                   ` [External] : " Drew Adams
2021-09-29 19:09                     ` Tassilo Horn
2021-09-29 19:35                       ` Drew Adams
2021-09-29 13:57               ` Stefan Kangas

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8735n7utvv.fsf@gnu.org \
    --to=tsdh@gnu.org \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=larsi@gnus.org \
    --cc=rudiwillalwaysloveyou@gmail.com \
    --cc=stefankangas@gmail.com \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).