[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: address@hidden: replace-regexp at end of buffer]
From: |
Chong Yidong |
Subject: |
Re: address@hidden: replace-regexp at end of buffer] |
Date: |
Tue, 27 Feb 2007 11:23:14 -0500 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.94 (gnu/linux) |
Richard Stallman <address@hidden> writes:
> Would someone please check that this is correct,
> and if so install it and ack?
perform-replace is a subroutine of query-replace, which does not
exhibit any problem (it corrects the buffer position when this case
occurs). It is not used in generic Elisp code, which should be using
replace-match instead.
Therefore, no fix is required or desired.
> replace-regexp/perform-replace wrongly moves back a character when the
> match is at end of buffer.
>
> Run
>
> (perform-replace "abc" "123" nil t nil)
>
> on a buffer that ends in "abc" (no final newline).
>
> Point ends up between 2 and 3.
>
> This is because point could not move too far in this case, and so the
> following correction shouldn't be done [perform-replace]:
>
> ;; 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))