all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#36372: 27.0.50; replace-regexp-in-string skips START first chars in return value
@ 2019-06-25 12:01 Mattias Engdegård
  2019-06-25 15:26 ` Eli Zaretskii
  0 siblings, 1 reply; 17+ messages in thread
From: Mattias Engdegård @ 2019-06-25 12:01 UTC (permalink / raw)
  To: 36372

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.






^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2019-06-26 17:41 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-25 12:01 bug#36372: 27.0.50; replace-regexp-in-string skips START first chars in return value Mattias Engdegård
2019-06-25 15:26 ` Eli Zaretskii
2019-06-26  9:31   ` bug#36372: 27.0.50; replace-regexp-in-string skips START first chars in return value [PATCH] Mattias Engdegård
2019-06-26  9:38     ` Robert Pluim
2019-06-26 10:01       ` Mattias Engdegård
2019-06-26 11:11         ` Robert Pluim
2019-06-26 10:22       ` Lars Ingebrigtsen
2019-06-26 12:32         ` Robert Pluim
2019-06-26 13:51           ` Lars Ingebrigtsen
2019-06-26 14:01             ` Drew Adams
2019-06-26 14:51             ` Eli Zaretskii
2019-06-26 15:20               ` Mattias Engdegård
2019-06-26 15:59                 ` Clément Pit-Claudel
2019-06-26 17:03                   ` Mattias Engdegård
2019-06-26 17:09                     ` Eli Zaretskii
2019-06-26 17:41                       ` Mattias Engdegård
2019-06-26 15:17     ` Eli Zaretskii

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.