]> code.delx.au - gnu-emacs/commitdiff
(perform-replace): Undo change of 2000-04-04.
authorGerd Moellmann <gerd@gnu.org>
Mon, 26 Jun 2000 20:02:42 +0000 (20:02 +0000)
committerGerd Moellmann <gerd@gnu.org>
Mon, 26 Jun 2000 20:02:42 +0000 (20:02 +0000)
Instead, move backward 1 character At the end of the loop when
necessary.

lisp/replace.el

index adf56293f51ff5bc221df376597b87a0c6088703..418c3398e68f1ae232eeb6d200cc06ea1a37cf5a 100644 (file)
@@ -885,16 +885,13 @@ which will run faster and probably do exactly what you want."
                              (progn (goto-char (nth 1 match-again))
                                     match-again)
                            (and (or match-again
-                                    ;; MATCH-AGAIN nil means in the
-                                    ;; regexp case that there's no
-                                    ;; match adjacent to the last
-                                    ;; one.  So, we could move
-                                    ;; forward, but we don't want to
-                                    ;; because that moves point 1
-                                    ;; position after the last
-                                    ;; replacement when everything
-                                    ;; has been done.
-                                    regexp-flag
+                                    ;; MATCH-AGAIN non-nil means we
+                                    ;; accept an adjacent match.  If
+                                    ;; we don't, move one char to the
+                                    ;; right.  This takes us a
+                                    ;; character too far at the end,
+                                    ;; but this is undone after the
+                                    ;; while-loop.
                                     (progn (forward-char 1) (not (eobp))))
                                 (funcall search-function search-string limit t)
                                 ;; For speed, use only integers and
@@ -1048,6 +1045,13 @@ which will run faster and probably do exactly what you want."
                    (cons (cons (point)
                                (or replaced (match-data t)))
                          stack)))))
+
+      ;; The code preventing adjacent regexp matches in the condition
+      ;; of the while-loop above will haven taken us one character
+      ;; beyond the last replacement.  Undo that.
+      (when (and regexp-flag (not match-again) (> replace-count 0))
+       (backward-char 1))
+      
       (replace-dehighlight))
     (or unread-command-events
        (message "Replaced %d occurrence%s"