From: Robert Pluim <rpluim@gmail.com>
To: "Mattias Engdegård" <mattiase@acm.org>
Cc: 36372@debbugs.gnu.org
Subject: bug#36372: 27.0.50; replace-regexp-in-string skips START first chars in return value [PATCH]
Date: Wed, 26 Jun 2019 11:38:53 +0200 [thread overview]
Message-ID: <m2tvcc8z4i.fsf@gmail.com> (raw)
In-Reply-To: <B10BBB52-AAAA-46C8-A5F1-BEDA04011E95@acm.org> ("Mattias \=\?utf-8\?Q\?Engdeg\=C3\=A5rd\=22's\?\= message of "Wed, 26 Jun 2019 11:31:01 +0200")
>>>>> On Wed, 26 Jun 2019 11:31:01 +0200, Mattias Engdegård <mattiase@acm.org> said:
Mattias> 25 juni 2019 kl. 17.26 skrev Eli Zaretskii <eliz@gnu.org>:
>>
>>> The question is whether it is too late to fix the bug, or if it needs to be documented.
>>
>> Both, I think ;-)
Mattias> Documenting a bug rather than fixing it never feels very satisfactory, but it may be the lesser evil.
Mattias> What about this patch?
I think this is one of those 'who could possibly be relying on this
behaviour' bugs that bites you hard if you change things, so
documentation is probably best. Minor nits below
Mattias> From d5419cbf491cccb91843b8e3d6270df1c40a9004 Mon Sep 17 00:00:00 2001
Mattias> From: =?UTF-8?q?Mattias=20Engdeg=C3=A5rd?= <mattiase@acm.org>
Mattias> Date: Wed, 26 Jun 2019 11:23:32 +0200
Mattias> Subject: [PATCH] Document bug in `replace-regexp-in-string'
Mattias> `replace-regexp-in-string' omits the first START characters of the
Mattias> input string in its return value. This is a clear bug, but fixing it
Mattias> probably causes more trouble; document the behaviour instead (bug#36372).
Mattias> * doc/lispref/searching.texi (Search and Replace)
Mattias> * lisp/subr.el (replace-regexp-in-string):
Mattias> Document current behaviour.
Mattias> ---
Mattias> doc/lispref/searching.texi | 4 ++--
Mattias> lisp/subr.el | 3 ++-
Mattias> 2 files changed, 4 insertions(+), 3 deletions(-)
Mattias> diff --git a/doc/lispref/searching.texi b/doc/lispref/searching.texi
Mattias> index 33455114da..86a907021c 100644
Mattias> --- a/doc/lispref/searching.texi
Mattias> +++ b/doc/lispref/searching.texi
Mattias> @@ -1790,8 +1790,8 @@ Search and Replace
Mattias> This function copies @var{string} and searches it for matches for
Mattias> @var{regexp}, and replaces them with @var{rep}. It returns the
Mattias> modified copy. If @var{start} is non-@code{nil}, the search for
Mattias> -matches starts at that index in @var{string}, so matches starting
Mattias> -before that index are not changed.
Mattias> +matches starts at that index in @var{string}, and the returned value
Mattias> +does not include first @var{start} characters of @var{string}.
insert 'the' before 'first'
Mattias> This function uses @code{replace-match} to do the replacement, and it
Mattias> passes the optional arguments @var{fixedcase}, @var{literal} and
Mattias> diff --git a/lisp/subr.el b/lisp/subr.el
Mattias> index baff1e909a..ba388b3721 100644
Mattias> --- a/lisp/subr.el
Mattias> +++ b/lisp/subr.el
Mattias> @@ -4208,7 +4208,8 @@ replace-regexp-in-string
Mattias> Optional arguments FIXEDCASE, LITERAL and SUBEXP are like the
Mattias> arguments with the same names of function `replace-match'. If START
Mattias> -is non-nil, start replacements at that index in STRING.
Mattias> +is non-nil, start replacements at that index in STRING. The return
Mattias> +value then omits the first START characters of STRING.
'at that index in STRING, and omit the first START characters from the
return value.'
Mattias> REP is either a string used as the NEWTEXT arg of `replace-match' or a
Mattias> function. If it is a function, it is called with the actual text of each
Mattias> --
Mattias> 2.20.1 (Apple Git-117)
next prev parent reply other threads:[~2019-06-26 9:38 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2tvcc8z4i.fsf@gmail.com \
--to=rpluim@gmail.com \
--cc=36372@debbugs.gnu.org \
--cc=mattiase@acm.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.