[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 8b458aea86c: Fix query-replace at EOB
From: |
Eli Zaretskii |
Subject: |
master 8b458aea86c: Fix query-replace at EOB |
Date: |
Wed, 15 Nov 2023 08:16:27 -0500 (EST) |
branch: master
commit 8b458aea86ccbba255cbc5e97d6426df1e8bc6d9
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>
Fix query-replace at EOB
* lisp/replace.el (replace-match-maybe-edit): Avoid clobbering
match-data with outdated buffer position. (Bug#67124)
---
lisp/replace.el | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/lisp/replace.el b/lisp/replace.el
index 6b06e48c384..7fec54ecb27 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -2644,8 +2644,11 @@ passed in. If LITERAL is set, no checking is done,
anyway."
(replace-match newtext fixedcase literal)
;; `query-replace' undo feature needs the beginning of the match position,
;; but `replace-match' may change it, for instance, with a regexp like "^".
- ;; Ensure that this function preserves the match data (Bug#31492).
- (set-match-data match-data)
+ ;; Ensure that this function preserves the beginning of the match position
+ ;; (bug#31492). But we need to avoid clobbering the end of the match with
+ ;; the original match-end position, since `replace-match' could have made
+ ;; that incorrect or even invalid (bug#67124).
+ (set-match-data (list (car match-data) (nth 1 (match-data))))
;; `replace-match' leaves point at the end of the replacement text,
;; so move point to the beginning when replacing backward.
(when backward (goto-char (nth 0 match-data)))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 8b458aea86c: Fix query-replace at EOB,
Eli Zaretskii <=