From: Gerd Moellmann Date: Mon, 26 Jun 2000 20:02:42 +0000 (+0000) Subject: (perform-replace): Undo change of 2000-04-04. X-Git-Tag: emacs-pretest-21.0.90~3057 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=889617de079fca1b745df4ec16ea55be67358335;p=emacs.git (perform-replace): Undo change of 2000-04-04. Instead, move backward 1 character At the end of the loop when necessary. --- diff --git a/lisp/replace.el b/lisp/replace.el index adf56293f51..418c3398e68 100644 --- a/lisp/replace.el +++ b/lisp/replace.el @@ -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"