1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-05 22:20:24 -08:00

Fix wdired with (dired '(dir f1 f2 ...))

* lisp/wdired.el (wdired-finish-edit): Fix wdired with (dired
'(dir f1 f2 ...)) (bug#57334).
This commit is contained in:
Thierry Volpiatto 2022-08-23 12:03:22 +02:00 committed by Lars Ingebrigtsen
parent e2c766a20d
commit 66040fbeed

View file

@ -537,15 +537,28 @@ 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
((and (stringp dired-directory)
(not (file-directory-p dired-directory))
(null some-file-names-unchanged)
(= (length files-renamed) 1))
;; If we are displaying a single file (rather than the
;; contents of a directory), change dired-directory if that
;; file was renamed.
(setq dired-directory (cdr (car files-renamed))))
((and (consp dired-directory)
(cdr dired-directory)
files-renamed)
;; Fix dired buffers created with
;; (dired '(foo f1 f2 f3)).
(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))