🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.bug
Article #99299

(prog2 (re-search ".*\\'") (replace-match "\\&"))

#99299
From: Benjamin Chase
Date: Fri, 12 Oct 1990 17:06
38 lines
2011 bytes
Shouldn't

    (prog2 (re-search-forward <foo>) (replace-match "\\&"))

(where <foo> is any pattern that results in a match) more or less do
nothing?  Well...

GNU Emacs 18.55.2  (really epoch)
SPARCstation 1
SunOS Release 4.1

Create a buffer, and put only zeroes in it (ie. no newline).  Place
dot anywhere but at the end of the buffer, do an ESC-x
eval-expression.  Feed eval-expression the following expression:

    (prog2 (re-search-forward "0+\\'") (replace-match "\\&"))

and a strange thing happens.  The last character disappears.  I think
it shouldn't do anything to the buffer. (other than marking the buffer
as having been modified...)  This same sequence does work as I expect
it to under GNU Emacs 18.55.1 (actually GNU emacs this time, not
epoch).

If I add a newline to the end of the buffer, and change the expression to

    (prog2 (re-search-forward "0+$") (replace-match "\\&"))

it works as I think it should.  

Looking further, the bug seems to occur whenever the buffer does not
end with a newline, and the search pattern tries to match the end of
the buffer (ie. ends with \\').  For example
	
    (prog2 (re-search-forward ".*\\'") (replace-match "\\&"))

seems to be a reliable loser, for buffers not ending in newlines.
--
	Ben Chase <bbc@rice.edu>, Rice University, Houston, Texas
Technical Details
Message-ID: <9010121706.AA08299@sicilia.rice.edu>
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!tut.cis.ohio-state.edu!RICE.EDU!bbc

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fb2f1,3bbedabcb5194820,start
X-Google-Attributes: gidfb2f1,public
X-Google-ArrivalTime: 1990-10-12 10:06:33 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!tut.cis.ohio-state.edu!RICE.EDU!bbc
From: bbc@RICE.EDU (Benjamin Chase)
Newsgroups: gnu.emacs.bug
Subject: (prog2 (re-search ".*\\'") (replace-match "\\&"))
Message-ID: <9010121706.AA08299@sicilia.rice.edu>
Date: 12 Oct 90 17:06:33 GMT
Sender: daemon@tut.cis.ohio-state.edu
Reply-To: Benjamin Chase <bbc@rice.edu>
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 38
Approved: bug-gnu-emacs@prep.ai.mit.edu
Posted: Fri Oct 12 18:06:33 1990