From a65ece8b2011bd69922262a6fbcf68c2e2c2a717 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sun, 16 Jul 2023 12:15:24 +0300 Subject: [PATCH] Fix Wdired with relative and abbreviated file names * lisp/wdired.el (wdired-finish-edit): Support Dired buffers where 'dired-directory' is a list made of relative or abbreviated file names. (Bug#64606) --- lisp/wdired.el | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/lisp/wdired.el b/lisp/wdired.el index 5c745cc9aab..7b9c75d36b1 100644 --- a/lisp/wdired.el +++ b/lisp/wdired.el @@ -556,8 +556,24 @@ non-nil means return old filename." ;; 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)))))) + collect + (or (assoc-default f files-renamed) + ;; F could be relative or + ;; abbreviated, whereas + ;; files-renamed always consists + ;; of absolute file names. + (let ((relative + (not (file-name-absolute-p f))) + (match + (assoc-default (expand-file-name f) + files-renamed))) + (cond + ;; If it was relative, convert + ;; the new name back to relative. + ((and match relative) + (file-relative-name match)) + (t match))) + f)))))) ;; Re-sort the buffer. (revert-buffer) (let ((inhibit-read-only t)) -- 2.39.5