From 934b49686de4d606e69fb6a2acbffdf3a7e62997 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Sat, 17 Nov 2007 01:27:52 +0000 Subject: [PATCH] (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. --- lisp/ChangeLog | 7 +++++++ lisp/dired-aux.el | 14 ++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 0cfe7fe704d..d0fb5ef28da 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2007-11-17 Juri Linkov + + * dired-aux.el (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. + 2007-11-16 Jay Belanger * calc/calc-aent.el (calc-last-user-lang-parse-table): New variable. diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index 321a7f67932..1ac6208313a 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el @@ -1578,10 +1578,16 @@ Optional arg HOW-TO is used to set the value of the into-dir variable "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) -- 2.39.2