Fix use of non-nil wdired-use-interactive-rename
This is a fairly minimal fix for the release branch; a more comprehensive fix is on master, so do not merge this to master. * lisp/wdired.el (wdired-search-and-rename): Remove dired-filename text property in order to find new filename when it only partially replaces old filename (bug#32173). If user quits before renaming succeeds, restore the dired-filename text property.
This commit is contained in:
parent
bd52f37cae
commit
831a3cb301
1 changed files with 29 additions and 9 deletions
|
@ -543,19 +543,39 @@ and proceed depending on the answer."
|
|||
(goto-char (point-max))
|
||||
(forward-line -1)
|
||||
(let ((done nil)
|
||||
(failed t)
|
||||
curr-filename)
|
||||
(while (and (not done) (not (bobp)))
|
||||
(setq curr-filename (wdired-get-filename nil t))
|
||||
(if (equal curr-filename filename-ori)
|
||||
(progn
|
||||
(setq done t)
|
||||
(let ((inhibit-read-only t))
|
||||
(dired-move-to-filename)
|
||||
(search-forward (wdired-get-filename t) nil t)
|
||||
(replace-match (file-name-nondirectory filename-ori) t t))
|
||||
(dired-do-create-files-regexp
|
||||
(function dired-rename-file)
|
||||
"Move" 1 ".*" filename-new nil t))
|
||||
(unwind-protect
|
||||
(progn
|
||||
(setq done t)
|
||||
(let ((inhibit-read-only t))
|
||||
;; Remove dired-filename text property in order to
|
||||
;; find filename-new when it only partially
|
||||
;; replaces filename-ori (bug#32173); the text
|
||||
;; property is added again when renaming succeeds.
|
||||
(remove-text-properties
|
||||
(line-beginning-position) (line-end-position)
|
||||
'(dired-filename nil))
|
||||
(dired-move-to-filename)
|
||||
(search-forward (wdired-get-filename t) nil t)
|
||||
(replace-match (file-name-nondirectory filename-ori) t t))
|
||||
(dired-do-create-files-regexp
|
||||
(function dired-rename-file)
|
||||
"Move" 1 ".*" filename-new nil t)
|
||||
(setq failed nil))
|
||||
;; If user quits before renaming succeeds, restore the
|
||||
;; dired-filename text property.
|
||||
(when failed
|
||||
(beginning-of-line)
|
||||
(let ((beg (re-search-forward
|
||||
directory-listing-before-filename-regexp
|
||||
(line-end-position) t))
|
||||
(end (dired-move-to-end-of-filename))
|
||||
(inhibit-read-only t))
|
||||
(add-text-properties beg end '(dired-filename t)))))
|
||||
(forward-line -1))))))
|
||||
|
||||
;; marks a list of files for deletion
|
||||
|
|
Loading…
Add table
Reference in a new issue