help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Creating a directory target for dired-do-copy


From: Kevin Rodgers
Subject: Re: Creating a directory target for dired-do-copy
Date: Fri, 28 Jan 2005 08:09:26 -0700
User-agent: Mozilla Thunderbird 0.9 (X11/20041105)

Luis O. Silva wrote:
> Let us suppose that you are in dired mode without any marked
> files and you type `C', that is (`dired-do-copy'). You're
> asked for the directory to copy into or the new file
> name. What do you have to do if you want to copy the file to a
> nonexistent directory? Is there an easy way to create the
> target directory without doing this separately?

Could it be as simple as;

(defadvice dired-mark-read-file-name (after make-directory activate)
  "Create non-existent directories for the result, as necessary.
If the returned file name is a directory name (e.g. ends in slash on Unix),
create it."
  (let ((directory (file-name-directory ad-return-value)))
    (unless (file-directory-p directory)
      (make-directory directory t)))
  (when (equal (file-name-as-directory ad-return-value) ad-return-value)
    (make-directory ad-return-value)))

--
Kevin Rodgers

reply via email to

[Prev in Thread] Current Thread [Next in Thread]