From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Robert Pluim Newsgroups: gmane.emacs.bugs 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 Message-ID: References: <83tvcdlm8x.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="243617"; mail-complaints-to="usenet@blaine.gmane.org" Cc: 36372@debbugs.gnu.org To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jun 26 11:40:13 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hg4PU-0011GR-PC for geb-bug-gnu-emacs@m.gmane.org; Wed, 26 Jun 2019 11:40:12 +0200 Original-Received: from localhost ([::1]:38274 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hg4PT-0004F5-Mf for geb-bug-gnu-emacs@m.gmane.org; Wed, 26 Jun 2019 05:40:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37694) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hg4PL-0004En-QU for bug-gnu-emacs@gnu.org; Wed, 26 Jun 2019 05:40:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hg4PK-000165-JP for bug-gnu-emacs@gnu.org; Wed, 26 Jun 2019 05:40:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:48965) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hg4PK-00015v-Fk for bug-gnu-emacs@gnu.org; Wed, 26 Jun 2019 05:40:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hg4PK-00013f-Bd for bug-gnu-emacs@gnu.org; Wed, 26 Jun 2019 05:40:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Robert Pluim Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 26 Jun 2019 09:40:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36372 X-GNU-PR-Package: emacs Original-Received: via spool by 36372-submit@debbugs.gnu.org id=B36372.15615419443986 (code B ref 36372); Wed, 26 Jun 2019 09:40:02 +0000 Original-Received: (at 36372) by debbugs.gnu.org; 26 Jun 2019 09:39:04 +0000 Original-Received: from localhost ([127.0.0.1]:34276 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hg4ON-00012B-Jm for submit@debbugs.gnu.org; Wed, 26 Jun 2019 05:39:04 -0400 Original-Received: from mail-ed1-f53.google.com ([209.85.208.53]:40793) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hg4OL-00011F-JT for 36372@debbugs.gnu.org; Wed, 26 Jun 2019 05:39:02 -0400 Original-Received: by mail-ed1-f53.google.com with SMTP id k8so2335977eds.7 for <36372@debbugs.gnu.org>; Wed, 26 Jun 2019 02:39:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:mail-copies-to:gmane-reply-to-list :date:in-reply-to:message-id:mime-version:content-transfer-encoding; bh=Wafi7Vvds5YZB3ul6KK/cvo1wmbZeCI6oCXWJZudAqw=; b=ERhNr1htlXiPyYLGAB+IIvfd1fkYtQxi/qe8StstKHzOvuqtLTIXrA0rnKwGLKEgVN O+vC4DpSH6fuHlcBW3r6rNCNH53dSE0iYdhd1Gh1YiWsIiYlZGWYHuukEc1Q1afZ8l63 4UFQZynKGEtwkrW0GUzCLibAkAoA7Mg3vVvWR2cK4HIjUxMa3TwgWfOMDT8KDay9wp0Z z48m/awoP1VT0faxetF6Iyo7VLEeJXH3lsc+gqKnEA6eDDXlyRKI81uXzuUui7Dj2YkH DLGx3zgxLWfqzX2AkiwRN119Q8RDnc5FkmqW0ysGyNP+yUL0E07bDYCKhBQcP02TXTfI hQ0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:mail-copies-to :gmane-reply-to-list:date:in-reply-to:message-id:mime-version :content-transfer-encoding; bh=Wafi7Vvds5YZB3ul6KK/cvo1wmbZeCI6oCXWJZudAqw=; b=Lcqtq575K5QEswi6r1JMY0ncuq+6OeCDVZ2w4fvMr2ESzAQB2SaWptS7Sb2M1HXSsy HWRRLw6eRBf7oWdblkFYp3wva6al5nsxF+JCYyE9aVjyiN4Z6eKFJZzSV5/pwFy/afjK EiZl1AVPns+0CQUVMiP22IC3sngW8Dx/fAKYWule9jdklvSm97mjDS4sFKr3fcE8hFa1 Br3O8mPquVVHMvN/ucdhv2Yz7cA76+I/W9Wz7nc03+dHoIqF8ibA3KC9beuOeEn4fHDb XU/fcpZxdWf2C+mJyzHgsogZ03cofW5XJG10sG6cjeZ10T1mPgUSZyYG5Xg28QMg4QGm NAXg== X-Gm-Message-State: APjAAAWADOyUdppKMLGBv6cC+3XfulrJSQCDFSTUU8KfB5WhkTRlB7HR jSeWp1PsuD3w9/FV694HxB1M133FV8E= X-Google-Smtp-Source: APXvYqwE8Vcm4TFTvY6BEBCmYiMCo/Xv/3wsUQArgHlE4u4gVwI/J6pVppB21TkR2r9OJ7Uwi/TZ2w== X-Received: by 2002:a50:b187:: with SMTP id m7mr3971557edd.81.1561541935364; Wed, 26 Jun 2019 02:38:55 -0700 (PDT) Original-Received: from rpluim-mac ([149.5.228.1]) by smtp.gmail.com with ESMTPSA id l35sm2486493edc.2.2019.06.26.02.38.53 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 26 Jun 2019 02:38:54 -0700 (PDT) Mail-Copies-To: never Gmane-Reply-To-List: yes In-Reply-To: ("Mattias \=\?utf-8\?Q\?Engdeg\=C3\=A5rd\=22's\?\= message of "Wed, 26 Jun 2019 11:31:01 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:161469 Archived-At: >>>>> On Wed, 26 Jun 2019 11:31:01 +0200, Mattias Engdeg=C3=A5rd said: Mattias> 25 juni 2019 kl. 17.26 skrev Eli Zaretskii : >>=20 >>> The question is whether it is too late to fix the bug, or if it nee= ds to be documented. >>=20 >> Both, I think ;-) Mattias> Documenting a bug rather than fixing it never feels very satis= factory, 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: =3D?UTF-8?q?Mattias=3D20Engdeg=3DC3=3DA5rd?=3D 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 fi= xing 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/searchin= g.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 t= he Mattias> modified copy. If @var{start} is non-@code{nil}, the search = for Mattias> -matches starts at that index in @var{string}, so matches star= ting Mattias> -before that index are not changed. Mattias> +matches starts at that index in @var{string}, and the returne= d 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 =20 Mattias> Optional arguments FIXEDCASE, LITERAL and SUBEXP are like the Mattias> arguments with the same names of function `replace-match'. I= f 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. =20 '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-ma= tch' or a Mattias> function. If it is a function, it is called with the actual = text of each Mattias> --=20 Mattias> 2.20.1 (Apple Git-117)