aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhil Sung2016-02-28 15:07:02 +1030
committerLars Ingebrigtsen2016-02-28 15:07:02 +1030
commite00974a7d1981d716d38ecf45b689dd30a381c65 (patch)
tree635c1677b80ec6db07e52e8c1c45bf7c4348ef0e
parentd5f270f2965f3c52963e2bf0057756e350d771d1 (diff)
downloademacs-e00974a7d1981d716d38ecf45b689dd30a381c65.tar.gz
emacs-e00974a7d1981d716d38ecf45b689dd30a381c65.zip
Create subdirectories automatically in wdired
* lisp/wdired.el (wdired-create-parent-directories): New variable (bug#6817). (wdired-create-parentdirs): New function. (wdired-do-renames): Use it. * doc/emacs/dired.texi (Wdired): Mention `wdired-create-parent-directories'
-rw-r--r--doc/emacs/dired.texi4
-rw-r--r--etc/NEWS6
-rw-r--r--lisp/wdired.el17
3 files changed, 27 insertions, 0 deletions
diff --git a/doc/emacs/dired.texi b/doc/emacs/dired.texi
index 13242d12d3c..60542df1097 100644
--- a/doc/emacs/dired.texi
+++ b/doc/emacs/dired.texi
@@ -1294,6 +1294,10 @@ relative). To mark a file for deletion, delete the entire file name.
1294To change the target of a symbolic link, edit the link target name 1294To change the target of a symbolic link, edit the link target name
1295which appears next to the link name. 1295which appears next to the link name.
1296 1296
1297 If you edit the file names to create a new subdirectory, Wdired will
1298automatically create these new directories. To inhibit this behavior,
1299set @code{wdired-create-parent-directories} to @code{nil}.
1300
1297 The rest of the text in the buffer, such as the file sizes and 1301 The rest of the text in the buffer, such as the file sizes and
1298modification dates, is marked read-only, so you can't edit it. 1302modification dates, is marked read-only, so you can't edit it.
1299However, if you set @code{wdired-allow-to-change-permissions} to 1303However, if you set @code{wdired-allow-to-change-permissions} to
diff --git a/etc/NEWS b/etc/NEWS
index 29b013a3ede..c12f4d19cf1 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1426,6 +1426,12 @@ compression command is determined from the new
1426`dired-compress-files-alist' variable. 1426`dired-compress-files-alist' variable.
1427 1427
1428+++ 1428+++
1429*** In wdired, when editing files to contain slash characters,
1430the resulting directories are automatically created. Whether
1431to do this or not is controlled by the
1432`wdired-create-parent-directories' variable.
1433
1434+++
1429*** `W' is now bound to `browse-url-of-dired-file', and is useful for 1435*** `W' is now bound to `browse-url-of-dired-file', and is useful for
1430viewing HTML files and the like. 1436viewing HTML files and the like.
1431 1437
diff --git a/lisp/wdired.el b/lisp/wdired.el
index 9f258794f96..d943dada030 100644
--- a/lisp/wdired.el
+++ b/lisp/wdired.el
@@ -152,6 +152,16 @@ renamed by `dired-do-rename' and `dired-do-rename-regexp'."
152 :version "24.3" 152 :version "24.3"
153 :group 'wdired) 153 :group 'wdired)
154 154
155(defcustom wdired-create-parent-directories t
156 "If non-nil, create parent directories of destination files.
157If non-nil, when you rename a file to a destination path within a
158nonexistent directory, wdired will create any parent directories
159necessary. When nil, attempts to rename a file into a
160nonexistent directory will fail."
161 :version "25.2"
162 :type 'boolean
163 :group 'wdired)
164
155(defvar wdired-mode-map 165(defvar wdired-mode-map
156 (let ((map (make-sparse-keymap))) 166 (let ((map (make-sparse-keymap)))
157 (define-key map "\C-x\C-s" 'wdired-finish-edit) 167 (define-key map "\C-x\C-s" 'wdired-finish-edit)
@@ -490,6 +500,8 @@ non-nil means return old filename."
490 (require 'dired-aux) 500 (require 'dired-aux)
491 (condition-case err 501 (condition-case err
492 (let ((dired-backup-overwrite nil)) 502 (let ((dired-backup-overwrite nil))
503 (and wdired-create-parent-directories
504 (wdired-create-parentdirs file-new))
493 (dired-rename-file file-ori file-new 505 (dired-rename-file file-ori file-new
494 overwrite)) 506 overwrite))
495 (error 507 (error
@@ -499,6 +511,11 @@ non-nil means return old filename."
499 err))))))))) 511 err)))))))))
500 errors)) 512 errors))
501 513
514(defun wdired-create-parentdirs (file-new)
515 "Create parent directories for FILE-NEW if they don't exist."
516 (and (not (file-exists-p (file-name-directory file-new)))
517 (message "Creating directory for file %s" file-new)
518 (make-directory (file-name-directory file-new) t)))
502 519
503(defun wdired-exit () 520(defun wdired-exit ()
504 "Exit wdired and return to dired mode. 521 "Exit wdired and return to dired mode.