aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Moellmann2000-12-12 14:13:13 +0000
committerGerd Moellmann2000-12-12 14:13:13 +0000
commitfa257eefd2edf0e186b0c3bd465ffa6afda12993 (patch)
treef1c913dfa515190a975d7dbf394deb22e96c2e72
parentbbbf6d06b87c9761471947e7bacfd34d7c422a92 (diff)
downloademacs-fa257eefd2edf0e186b0c3bd465ffa6afda12993.tar.gz
emacs-fa257eefd2edf0e186b0c3bd465ffa6afda12993.zip
(perform-replace): Don't use an empty match adjacent
to a non-empty match when computing the next match before the replacement is performed.
-rw-r--r--lisp/replace.el9
1 files changed, 7 insertions, 2 deletions
diff --git a/lisp/replace.el b/lisp/replace.el
index 6fc67ad87bc..2a0735cfe5a 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -965,15 +965,20 @@ which will run faster and probably do exactly what you want."
965 (setq nonempty-match 965 (setq nonempty-match
966 (/= (nth 0 real-match-data) (nth 1 real-match-data))) 966 (/= (nth 0 real-match-data) (nth 1 real-match-data)))
967 967
968 ;; If the match is empty, record that the next one can't be adjacent. 968 ;; If the match is empty, record that the next one can't be
969 ;; adjacent.
970
969 ;; Otherwise, if matching a regular expression, do the next 971 ;; Otherwise, if matching a regular expression, do the next
970 ;; match now, since the replacement for this match may 972 ;; match now, since the replacement for this match may
971 ;; affect whether the next match is adjacent to this one. 973 ;; affect whether the next match is adjacent to this one.
974 ;; If that match is empty, don't use it.
972 (setq match-again 975 (setq match-again
973 (and nonempty-match 976 (and nonempty-match
974 (or (not regexp-flag) 977 (or (not regexp-flag)
975 (and (looking-at search-string) 978 (and (looking-at search-string)
976 (match-data))))) 979 (let ((match (match-data)))
980 (and (/= (nth 0 match) (nth 1 match))
981 match))))))
977 982
978 ;; Calculate the replacement string, if necessary. 983 ;; Calculate the replacement string, if necessary.
979 (when replacements 984 (when replacements