unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Thierry Volpiatto <thievol@posteo.net>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: 57334@debbugs.gnu.org
Subject: bug#57334: 28.1; Fix wdired with (dired '(dir f1 f2 ...))
Date: Tue, 23 Aug 2022 04:50:20 +0000	[thread overview]
Message-ID: <87a67vsgtb.fsf@posteo.net> (raw)
In-Reply-To: <87o7wc15cv.fsf@gnus.org>

[-- Attachment #1: Type: text/plain, Size: 2637 bytes --]


Lars Ingebrigtsen <larsi@gnus.org> writes:

> Thierry Volpiatto <thievol@posteo.net> writes:
>
>>> 3 unexpected results:
>>>    FAILED  wdired-test-bug32173-01
>>>    FAILED  wdired-test-bug32173-02
>>>    FAILED  wdired-test-bug34915
>>
>> Sorry but I am not a big fan of ERT, I have no idea what these tests do.
>
> If you say "make wdired-tests" in the "test" directory, the output will
> tell you what the problem is.  (I didn't examine the output myself.)

The tests succeed with following patch (avoid setting dired-directory to
nil).

diff --git a/lisp/wdired.el b/lisp/wdired.el
index 106d57174d5..40008f186eb 100644
--- a/lisp/wdired.el
+++ b/lisp/wdired.el
@@ -537,15 +537,27 @@ non-nil means return old filename."
     (wdired-change-to-dired-mode)
     (if changes
 	(progn
-	  ;; If we are displaying a single file (rather than the
-	  ;; contents of a directory), change dired-directory if that
-	  ;; file was renamed.  (This ought to be generalized to
-	  ;; handle the multiple files case, but that's less trivial).
-	  (when (and (stringp dired-directory)
-		     (not (file-directory-p dired-directory))
-		     (null some-file-names-unchanged)
-		     (= (length files-renamed) 1))
-	    (setq dired-directory (cdr (car files-renamed))))
+	  (cond (;; If we are displaying a single file (rather than the
+	         ;; contents of a directory), change dired-directory if that
+	         ;; file was renamed.
+                 (and (stringp dired-directory)
+                      (not (file-directory-p dired-directory))
+                      (null some-file-names-unchanged)
+                      (= (length files-renamed) 1))
+                 (setq dired-directory (cdr (car files-renamed))))
+                ;; Fix dired buffers created with
+                ;; (dired '(foo f1 f2 f3)).
+                ((and (consp dired-directory)
+                      (cdr dired-directory)
+                      files-renamed)
+                 (setq dired-directory
+                       (cons (car dired-directory)
+                             ;; Replace in `dired-directory' files that have
+                             ;; been modified with their new name keeping
+                             ;; the ones that are unmodified at the same place.
+                             (cl-loop for f in (cdr dired-directory)
+                                      collect (or (assoc-default f files-renamed)
+                                                  f))))))
 	  ;; Re-sort the buffer.
 	  (revert-buffer)
 	  (let ((inhibit-read-only t))

-- 
Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 686 bytes --]

  parent reply	other threads:[~2022-08-23  4:50 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-22  6:23 bug#57334: 28.1; Fix wdired with (dired '(dir f1 f2 ...)) Thierry Volpiatto
2022-08-22 10:27 ` Lars Ingebrigtsen
2022-08-22 14:42   ` Thierry Volpiatto
2022-08-22 14:54     ` Lars Ingebrigtsen
2022-08-22 14:59       ` Lars Ingebrigtsen
2022-08-22 15:45       ` Thierry Volpiatto
2022-08-22 15:56         ` Lars Ingebrigtsen
2022-08-22 18:46           ` Thierry Volpiatto
2022-08-22 18:49             ` Lars Ingebrigtsen
2022-08-22 20:05               ` Thierry Volpiatto
2022-08-23  4:50               ` Thierry Volpiatto [this message]
2022-08-23 10:04                 ` Lars Ingebrigtsen
2022-08-23 10:53                   ` Thierry Volpiatto
2022-08-22 11:26 ` Eli Zaretskii
2022-08-22 14:51   ` Thierry Volpiatto
2022-08-23  1:01 ` Michael Heerdegen

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=87a67vsgtb.fsf@posteo.net \
    --to=thievol@posteo.net \
    --cc=57334@debbugs.gnu.org \
    --cc=larsi@gnus.org \
    /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).