From: Tino Calancha <tino.calancha@gmail.com>
To: Keith David Bershatsky <esq@lawlist.com>
Cc: 31601@debbugs.gnu.org, tino.calancha@gmail.com
Subject: bug#31601: Dired/Wdired: Play nicely with recursive list of files and directories.
Date: Sat, 26 May 2018 18:02:26 +0900 [thread overview]
Message-ID: <87zi0m6b8d.fsf@gmail.com> (raw)
In-Reply-To: <m21sdzghii.wl%esq@lawlist.com> (Keith David Bershatsky's message of "Fri, 25 May 2018 21:36:37 -0700")
Keith David Bershatsky <esq@lawlist.com> writes:
> I occasionally have the need to rename files and directories that are recursively located. I create a dired-mode buffer as follows:
>
> (dired (directory-files-recursively "/path/to/directory" "" 'include-directories))
>
> Wdired: The first problem is that `wdired-get-filename' needs to be modified so that it handles absolute paths differently than relative filenames.
> Dired: The second problem is a dired-mode problem in that the `dired-directory' variable is not updated when renaming a file
Thank you for your report Keith!
You are right, it looks annoying.
Though I haven't arrived with an ideal solution, following
are two ways how I would try to perform a similar task.
I)
If you are lucky and "sh" points to a shell that
supports globstar (zsh, fish), or if you are using dired
via `em-ls', then you can do:
M-x dired /path/to/directory/**/* RET
;; Now both, wdired and `dired-do-rename' works fine.
[If you are using bash or ksh, that support globstar but
disable it by default, then you might be interestd in my
proposal in Bug#31495: it gives the chance to enable such
feature on dired via an user option.]
II)
Another way could be to use a command of the `find-dired' family:
M-x find-name-dired /path/to/directory/ RET * RET
;; I just noticed that wdired resets `revert-buffer-function' also for
;; these dired buffers. IMO it shouldn't, so I would propose
;; something like this:
--8<-----------------------------cut here---------------start------------->8---
commit 58842a20f570d32f5d3f90aced8f0e8c1b1535a7
Author: Tino Calancha <tino.calancha@gmail.com>
Date: Sat May 26 17:39:29 2018 +0900
Preserve revert-buffer-function on find-dired buffers
* lisp/wdired.el (wdired-find-dired-buffer-p): New predicate.
(wdired-change-to-wdired-mode, wdired-change-to-dired-mode):
Preserve `revert-buffer-function' on dired buffers created
with `find-dired' commands.
diff --git a/lisp/wdired.el b/lisp/wdired.el
index bb60e77776..de5b327d75 100644
--- a/lisp/wdired.el
+++ b/lisp/wdired.el
@@ -228,6 +228,12 @@ wdired-mode
(error "This mode can be enabled only by `wdired-change-to-wdired-mode'"))
(put 'wdired-mode 'mode-class 'special)
+(defun wdired-find-dired-buffer-p ()
+ "Return non-nil if the dired buffer comes from a `find-dired' command."
+ (save-excursion
+ (goto-char (point-min))
+ (forward-line 1)
+ (re-search-forward (format "^\\s-*%s " find-program) nil t)))
;;;###autoload
(defun wdired-change-to-wdired-mode ()
@@ -257,7 +263,8 @@ wdired-change-to-wdired-mode
(add-hook 'kill-buffer-hook 'wdired-check-kill-buffer nil t)
(setq major-mode 'wdired-mode)
(setq mode-name "Editable Dired")
- (setq revert-buffer-function 'wdired-revert)
+ (unless (wdired-find-dired-buffer-p)
+ (setq revert-buffer-function 'wdired-revert))
;; I temp disable undo for performance: since I'm going to clear the
;; undo list, it can save more than a 9% of time with big
;; directories because setting properties modify the undo-list.
@@ -363,7 +370,8 @@ wdired-change-to-dired-mode
(setq mode-name "Dired")
(dired-advertise)
(remove-hook 'kill-buffer-hook 'wdired-check-kill-buffer t)
- (set (make-local-variable 'revert-buffer-function) 'dired-revert))
+ (unless (wdired-find-dired-buffer-p)
+ (set (make-local-variable 'revert-buffer-function) 'dired-revert)))
(defun wdired-abort-changes ()
--8<-----------------------------cut here---------------end--------------->8---
In GNU Emacs 27.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.11)
of 2018-05-26 built on calancha-pc
Repository revision: 66c9ab90d5f8b566467549bf1d48c936bc6d296b
next prev parent reply other threads:[~2018-05-26 9:02 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-26 4:36 bug#31601: Dired/Wdired: Play nicely with recursive list of files and directories Keith David Bershatsky
2018-05-26 9:02 ` Tino Calancha [this message]
2018-05-26 18:51 ` Keith David Bershatsky
2018-05-28 23:11 ` Keith David Bershatsky
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87zi0m6b8d.fsf@gmail.com \
--to=tino.calancha@gmail.com \
--cc=31601@debbugs.gnu.org \
--cc=esq@lawlist.com \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).