summaryrefslogtreecommitdiff
path: root/lisp/dired-aux.el
diff options
context:
space:
mode:
authorNightMachinary <rudiwillalwaysloveyou@gmail.com>2021-11-09 16:19:45 +0330
committerTassilo Horn <tsdh@gnu.org>2021-12-06 07:00:14 +0100
commit4434deaee2aa9d8c6b9631690c6376f78a9b057f (patch)
tree2bc61b9711ea12e8d1204413a904423ef2295b82 /lisp/dired-aux.el
parent013161d4a77658c501c05aa754d36164fceb3982 (diff)
downloademacs-4434deaee2aa9d8c6b9631690c6376f78a9b057f.tar.gz
emacs-4434deaee2aa9d8c6b9631690c6376f78a9b057f.tar.bz2
emacs-4434deaee2aa9d8c6b9631690c6376f78a9b057f.zip
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.
Diffstat (limited to 'lisp/dired-aux.el')
-rw-r--r--lisp/dired-aux.el42
1 files changed, 40 insertions, 2 deletions
diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index 588551a6417..af7b160c1a4 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -1787,13 +1787,46 @@ Special value `always' suppresses confirmation."
"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 @@ Optional arg HOW-TO determines how to treat the target.
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