changeset 86167:117000c04a00

(dired-create-directory): Allow creating a directory of an arbitrary depth. Add a loop to find the topmost nonexistent parent dir `new', and call `dired-add-file' on it. Set the `PARENTS' arg of `make-directory' to t.
author Juri Linkov <juri@jurta.org>
date Sat, 17 Nov 2007 01:27:30 +0000
parents e40850c13975
children e20f2f0875e8
files lisp/dired-aux.el
diffstat 1 files changed, 10 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/dired-aux.el	Fri Nov 16 23:48:26 2007 +0000
+++ b/lisp/dired-aux.el	Sat Nov 17 01:27:30 2007 +0000
@@ -1578,10 +1578,16 @@
   "Create a directory called DIRECTORY."
   (interactive
    (list (read-file-name "Create directory: " (dired-current-directory))))
-  (let ((expanded (directory-file-name (expand-file-name directory))))
-    (make-directory expanded)
-    (dired-add-file expanded)
-    (dired-move-to-filename)))
+  (let* ((expanded (directory-file-name (expand-file-name directory)))
+	 (try expanded) new)
+    ;; Find the topmost nonexistent parent dir (variable `new')
+    (while (and try (not (file-exists-p try)) (not (equal new try)))
+      (setq new try
+	    try (directory-file-name (file-name-directory try))))
+    (make-directory expanded t)
+    (when new
+      (dired-add-file new)
+      (dired-move-to-filename))))
 
 (defun dired-into-dir-with-symlinks (target)
   (and (file-directory-p target)