all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
To: emacs-devel@gnu.org
Subject: dired-create-directory with arbitrary depth
Date: Thu, 08 Nov 2007 02:45:00 +0200	[thread overview]
Message-ID: <87lk99a8sr.fsf@jurta.org> (raw)

I propose to remove a restriction that `dired-create-directory' can create
only one immediate subdirectory.  The patch below keeps the old behavior
for creating an immediate subdirectory but also allows creating
subdirectories with an arbitrary depth.  It searches for the topmost
nonexistent parent directory and uses it to add a dired entry.  It also
calls `make-directory' with the `parents' arguments to create all parent
directories:

Index: lisp/dired-aux.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/dired-aux.el,v
retrieving revision 1.156
diff -c -r1.156 dired-aux.el
*** lisp/dired-aux.el	25 Sep 2007 10:44:23 -0000	1.156
--- lisp/dired-aux.el	8 Nov 2007 00:44:45 -0000
***************
*** 1528,1537 ****
    "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)))
  
  (defun dired-into-dir-with-symlinks (target)
    (and (file-directory-p target)
--- 1542,1557 ----
    "Create a directory called DIRECTORY."
    (interactive
     (list (read-file-name "Create directory: " (dired-current-directory))))
!   (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)

-- 
Juri Linkov
http://www.jurta.org/emacs/

             reply	other threads:[~2007-11-08  0:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-08  0:45 Juri Linkov [this message]
2007-11-08 17:39 ` dired-create-directory with arbitrary depth Richard Stallman

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

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

  git send-email \
    --in-reply-to=87lk99a8sr.fsf@jurta.org \
    --to=juri@jurta.org \
    --cc=emacs-devel@gnu.org \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.