From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tino Calancha Newsgroups: gmane.emacs.bugs Subject: bug#31601: Dired/Wdired: Play nicely with recursive list of files and directories. Date: Sat, 26 May 2018 18:02:26 +0900 Message-ID: <87zi0m6b8d.fsf@gmail.com> References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1527325265 16670 195.159.176.226 (26 May 2018 09:01:05 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 26 May 2018 09:01:05 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 31601@debbugs.gnu.org, tino.calancha@gmail.com To: Keith David Bershatsky Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat May 26 11:01:01 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fMV4O-0004Ev-Pk for geb-bug-gnu-emacs@m.gmane.org; Sat, 26 May 2018 11:01:01 +0200 Original-Received: from localhost ([::1]:48244 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fMV6W-0002zw-1l for geb-bug-gnu-emacs@m.gmane.org; Sat, 26 May 2018 05:03:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38776) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fMV6P-0002zp-Vb for bug-gnu-emacs@gnu.org; Sat, 26 May 2018 05:03:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fMV6M-0000ms-Nn for bug-gnu-emacs@gnu.org; Sat, 26 May 2018 05:03:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:41120) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fMV6M-0000mc-Ji for bug-gnu-emacs@gnu.org; Sat, 26 May 2018 05:03:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fMV6L-0000P0-W8 for bug-gnu-emacs@gnu.org; Sat, 26 May 2018 05:03:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 26 May 2018 09:03:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 31601 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 31601-submit@debbugs.gnu.org id=B31601.15273253631518 (code B ref 31601); Sat, 26 May 2018 09:03:01 +0000 Original-Received: (at 31601) by debbugs.gnu.org; 26 May 2018 09:02:43 +0000 Original-Received: from localhost ([127.0.0.1]:49017 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fMV63-0000OQ-AS for submit@debbugs.gnu.org; Sat, 26 May 2018 05:02:43 -0400 Original-Received: from mail-pl0-f46.google.com ([209.85.160.46]:41922) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fMV60-0000O8-M4 for 31601@debbugs.gnu.org; Sat, 26 May 2018 05:02:41 -0400 Original-Received: by mail-pl0-f46.google.com with SMTP id az12-v6so4467198plb.8 for <31601@debbugs.gnu.org>; Sat, 26 May 2018 02:02:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=vhJQzPTl3/l/pfr/ZAfVLz2hxwuL4DTTyS44aXLWVQo=; b=ipGsxuhQJml2P4jfcMHmbFcGfOfhkrjgtR9YbxwJkd2b90924cx5eTSSZaB5Kfdf+g nW7pI12363B/kryBrt/k9zyNCM6gOxmwYNSehc5zRx4nXA2dL7wa64Fl366Fl+QGCB+G rIKRiG97kHz23VicDO9tuSUkhY21CVli2IGcHSDqXWjdlAUMmXTt9FV8kqi+OZ/kIe82 2E0ej7R870ktCKo3cQsCluXVWLfMN9v5XSS4W3BN1pLciChIuXq+hLElxiSYZw3DvtAg AQ5SjbVevkmeA+aOOSXtn7neZDaWNrfU1XisDcC1HEETDDuH4Zlr9+88HKy6Oy4wySuV y6FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=vhJQzPTl3/l/pfr/ZAfVLz2hxwuL4DTTyS44aXLWVQo=; b=XD/M0YSwf+yrSGX1KaskkiZ6wi0O75loN3lp7or4E7rWFDXU4cpSnUWJu98s8adAsm sXxTnccGcCSa5SMYAEKs2FNtC28Tg2ti6HACs7lMU8IOPo1rNeCt/VYW2BiViNlNNXXI TKSYvrPFCUCXGlgBb6hP+N4Fn4dbo6NnbEK3kf0y5GIn4tQYE/qzkrW7uGG7uivR3RJ/ Ma74QECy7FXVUld+CHqOYPaSxhv/DASdq4KI/4zIBMeANgXKtWPnCwSDVvOvB2n2+Cf8 marhYP2IfjJbqK6qNUQertlFd+3ryP0JQuVK8RQsKIt4M4jkswH61OZq2ato0A7zyykm a0+g== X-Gm-Message-State: ALKqPwd4K4FF53oayI0laVmofrPr2R83Giw/b9GulRMp8A7/t9v7huav o+3RLnwfxYcpqMAz6XyFHMo= X-Google-Smtp-Source: AB8JxZqEDq1qQ6LKcDYtxr9Qffjm2+Y0DY4x4gg/jM5yQ4W7wR9j5UQeZYuFwVSOZk10UHxPgDG5Ng== X-Received: by 2002:a17:902:6b04:: with SMTP id o4-v6mr5843721plk.101.1527325354666; Sat, 26 May 2018 02:02:34 -0700 (PDT) Original-Received: from calancha-pc ([240f:6e:ee9a:1:adc4:139f:709c:10b]) by smtp.gmail.com with ESMTPSA id x2-v6sm35894756pgc.53.2018.05.26.02.02.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 26 May 2018 02:02:33 -0700 (PDT) In-Reply-To: (Keith David Bershatsky's message of "Fri, 25 May 2018 21:36:37 -0700") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:146565 Archived-At: Keith David Bershatsky 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 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