bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#57334: 28.1; Fix wdired with (dired '(dir f1 f2 ...))


From: Thierry Volpiatto
Subject: bug#57334: 28.1; Fix wdired with (dired '(dir f1 f2 ...))
Date: Tue, 23 Aug 2022 04:50:20 +0000

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: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]