Subject: bug#36372: closed (Re: bug#36372: 27.0.50; replace-regexp-in-string skips START first chars in return value [PATCH])

From: [email-masked] (GNU bug Tracking System)
Date: Wed, 26 Jun 2019 17:42:04 +0000

Your bug report

#36372: 27.0.50; replace-regexp-in-string skips START first chars in return value

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
36372: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=36372
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#36372: 27.0.50; replace-regexp-in-string skips START first chars in return value [PATCH]
From: Mattias Engdegård <[email-masked]>
To: Eli Zaretskii <[email-masked]>
Cc: Clément Pit-Claudel <[email-masked]>, Lars Ingebrigtsen <[email-masked]>, [email-masked]
Date: Wed, 26 Jun 2019 19:41:14 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

26 juni 2019 kl. 19.09 skrev Eli Zaretskii <[email-masked]>:
> LGTM, thanks.

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

Subject: 27.0.50; replace-regexp-in-string skips START first chars in return value
From: Mattias Engdegård <[email-masked]>
To: [email-masked]
Date: Tue, 25 Jun 2019 14:01:49 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

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.