GNU bug report logs - #36372
27.0.50; replace-regexp-in-string skips START first chars in return value

Previous Next

Package: emacs;

Reported by: Mattias Engdegård <mattiase <at> acm.org>

Date: Tue, 25 Jun 2019 12:41:02 UTC

Severity: normal

Found in version 27.0.50

Done: Mattias Engdegård <mattiase <at> acm.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Mattias Engdegård <mattiase <at> acm.org>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#36372: closed (27.0.50; replace-regexp-in-string skips START
 first chars in return value)
Date: Wed, 26 Jun 2019 17:42:04 +0000
[Message part 1 (text/plain, inline)]
Your message dated Wed, 26 Jun 2019 19:41:14 +0200
with message-id <F69741FB-CDFB-4FFB-A122-9307DD1A7E84 <at> acm.org>
and subject line Re: bug#36372: 27.0.50; replace-regexp-in-string skips START first chars in return value [PATCH]
has caused the debbugs.gnu.org bug report #36372,
regarding 27.0.50; replace-regexp-in-string skips START first chars in return value
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
36372: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=36372
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Mattias Engdegård <mattiase <at> acm.org>
To: bug-gnu-emacs <at> gnu.org
Subject: 27.0.50; replace-regexp-in-string skips START first chars in return
 value
Date: Tue, 25 Jun 2019 14:01:49 +0200
From the doc string and the manual, the call

 (replace-regexp-in-string "a" "X" "abcab" t t nil 2)

would be expected to return

 "abcXb"

but the actual return value is

 "cXb"

This was probably not intended. The manual text is

 This function copies STRING and searches it for matches for REGEXP,
 and replaces them with REP.  It returns the modified copy.  If
 START is non-‘nil’, the search for matches starts at that index in
 STRING, so matches starting before that index are not changed.

The question is whether it is too late to fix the bug, or if it needs to be documented.

`string-match' + `replace-match' work as expected:

(let ((s "abcab"))
  (string-match "a" s 2)
  (replace-match "X" t t s))
=> "abcXb"

Bug#15107 is somewhat related.



[Message part 3 (message/rfc822, inline)]
From: Mattias Engdegård <mattiase <at> acm.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Clément Pit-Claudel <cpitclaudel <at> gmail.com>,
 Lars Ingebrigtsen <larsi <at> gnus.org>, 36372-done <at> debbugs.gnu.org
Subject: Re: bug#36372: 27.0.50; replace-regexp-in-string skips START first
 chars in return value [PATCH]
Date: Wed, 26 Jun 2019 19:41:14 +0200
26 juni 2019 kl. 19.09 skrev Eli Zaretskii <eliz <at> gnu.org>:
> 
> LGTM, thanks.

That's it then. Thanks for the review; pushed.



This bug report was last modified 5 years and 331 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.