aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/replace.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/replace.el')
-rw-r--r--lisp/replace.el7
1 files 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."
2644 (replace-match newtext fixedcase literal) 2644 (replace-match newtext fixedcase literal)
2645 ;; `query-replace' undo feature needs the beginning of the match position, 2645 ;; `query-replace' undo feature needs the beginning of the match position,
2646 ;; but `replace-match' may change it, for instance, with a regexp like "^". 2646 ;; but `replace-match' may change it, for instance, with a regexp like "^".
2647 ;; Ensure that this function preserves the match data (Bug#31492). 2647 ;; Ensure that this function preserves the beginning of the match position
2648 (set-match-data match-data) 2648 ;; (bug#31492). But we need to avoid clobbering the end of the match with
2649 ;; the original match-end position, since `replace-match' could have made
2650 ;; that incorrect or even invalid (bug#67124).
2651 (set-match-data (list (car match-data) (nth 1 (match-data))))
2649 ;; `replace-match' leaves point at the end of the replacement text, 2652 ;; `replace-match' leaves point at the end of the replacement text,
2650 ;; so move point to the beginning when replacing backward. 2653 ;; so move point to the beginning when replacing backward.
2651 (when backward (goto-char (nth 0 match-data))) 2654 (when backward (goto-char (nth 0 match-data)))