[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#6817: (Feature request w/ patch) wdired should create directories ne
bug#6817: (Feature request w/ patch) wdired should create directories needed for destination files
Fri, 26 Feb 2016 18:49:07 +0100
Notmuch/0.20.2+113~g6332e6e (http://notmuchmail.org) Emacs/22.214.171.124 (x86_64-pc-linux-gnu)
On Fri, Feb 26 2016 17:14 (+1030), Lars Ingebrigtsen wrote:
> Phil Sung <address@hidden> writes:
>> It is sometimes useful in wdired to be able to move files into
>> directories that don't yet exist, e.g. when one is reorganizing files
>> and directories. The attached patch (against git HEAD), based on
>> previous work by Joakim Verona (source:
>> http://www.emacswiki.org/emacs/WDired), makes wdired create parent
>> directories needed as necessary for the destination files, conditional
>> on the variable `wdired-create-parent-directories'.
>> What do others think of this feature?
>> +(defcustom wdired-create-parent-directories nil
>> + "If non-nil, create parent directories of destination files.
>> +If non-nil, when you rename a file to a destination path within a
>> +nonexistent directory, wdired will create any parent directories
>> +necessary. When nil, attempts to rename a file into a nonexistent
>> +directory will fail."
>> + :type 'boolean
>> + :group 'wdired)
>> +(defun wdired-create-parentdirs (file-new)
>> + "Create parent directories for FILE-NEW if they don't exist."
>> + (and (not (file-exists-p (file-name-directory file-new)))
>> + (message "Creating directory for file %s" file-new)
>> + (make-directory (file-name-directory file-new) t)))
> I think this makes sense, but I've used wdired very little, so I don't
> quite have a handle on whether this is a use case that people would
> like. (And if so, the default should probably be t, here.)
I've been running with this patch for years (though not extensively
using it), and it has never failed me. I think this is a very useful
addition, and would also like the "t"-default, though that is not