I am working on implementing my own feature request -- http://debbugs.gnu.org/cgi/bugreport.cgi?bug=31601 -- to give
wdired the ability to handle a
dired- buffer that contains an arbitrary list of absolute paths to directories and files; e.g.,
(dired (directory-files-recursively "/path/to/directory" "" 'include-directories))
However, the files and directories may not necessarily be recursive -- i.e.,
dired-mode can handle creating a buffer containing an arbitrary list of files and directories.
I have added draft code to
wdired that places read-only text properties on the
file-name-directory. That way, a user cannot edit those portions of the path while in
The next step is to process the renaming of files/directories, which requires they be done in a hierarchical order. For example, a user may have renamed a directory and a file:
If we first rename the directory from
rename-file will be unable to rename
/path/to/directory/file because the
directory no longer exists; i.e., the
directory was changed to
Therefore, it makes sense to sort all of the files and directories into a hierarchical order such that the deepest file or directory is processed fist in time when renaming the files/directories. For example, if we have a set of files that are 5 directories deep, then those should be processed before processing directories or files that are less than 5 deep.
Q: How to sort a list of files/directories by hierarchical depth?
'("/path/to/different_directory/different_file" "/path/to/directory/file" "/X/Y" "/a/b/c/d/e/f" "/1/2/3/4" "/A/B/C/D/e" "/x/y/Z" "/Z" "/path/to/different_directory" "/path/to/directory")
'("/a/b/c/d/e/f" "/A/B/C/D/e" "/path/to/different_directory/different_file" "/1/2/3/4" "/path/to/directory/file" "/x/y/Z" "/path/to/different_directory" "/path/to/directory" "/X/Y" "/Z")