From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= 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 12:01:45 +0200 Message-ID: <829FF0B4-1CC8-4F89-A861-4929D2182DF5@acm.org> References: <83tvcdlm8x.fsf@gnu.org> Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_FF951FEC-2520-4C3E-A909-79C3625E881B" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="86759"; mail-complaints-to="usenet@blaine.gmane.org" Cc: 36372@debbugs.gnu.org To: Robert Pluim Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jun 26 12:06:58 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 1hg4pN-000MSR-Rv for geb-bug-gnu-emacs@m.gmane.org; Wed, 26 Jun 2019 12:06:58 +0200 Original-Received: from localhost ([::1]:38444 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hg4pL-0005o0-BF for geb-bug-gnu-emacs@m.gmane.org; Wed, 26 Jun 2019 06:06:55 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43270) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hg4kn-0003AK-E8 for bug-gnu-emacs@gnu.org; Wed, 26 Jun 2019 06:02:14 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hg4kh-00063H-MN for bug-gnu-emacs@gnu.org; Wed, 26 Jun 2019 06:02:13 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:48995) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hg4kd-0005z0-IT for bug-gnu-emacs@gnu.org; Wed, 26 Jun 2019 06:02:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hg4kc-0003lZ-3J for bug-gnu-emacs@gnu.org; Wed, 26 Jun 2019 06:02:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 26 Jun 2019 10:02: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.156154331814465 (code B ref 36372); Wed, 26 Jun 2019 10:02:02 +0000 Original-Received: (at 36372) by debbugs.gnu.org; 26 Jun 2019 10:01:58 +0000 Original-Received: from localhost ([127.0.0.1]:34306 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hg4kX-0003lF-Tw for submit@debbugs.gnu.org; Wed, 26 Jun 2019 06:01:58 -0400 Original-Received: from mail212c50.megamailservers.eu ([91.136.10.222]:56308 helo=mail194c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hg4kV-0003l0-3h for 36372@debbugs.gnu.org; Wed, 26 Jun 2019 06:01:56 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1561543308; bh=E+2gDNIPqoiwLRwb/pgjf3oS73nOT3oyWzW5adTKuDw=; h=From:Subject:Date:In-Reply-To:Cc:To:References:From; b=JvdI9110FdU5hEp8TyFXLSvGaTXSLBxWkdHkhd2VXo8rxp5tjEByWpIDfIU80ikEG J2a4CTrF+nECHLNNflUTrH99diTPOWdmqViZx909VlrAlLfK42bIi1rHskikap4jde jJwVYyCVr0hq7A89Fxf0JoDS3cWVqW8TTY/RLDKc= Feedback-ID: mattiase@acm.or Original-Received: from [192.168.1.65] (c-e636e253.032-75-73746f71.bbcust.telenor.se [83.226.54.230]) (authenticated bits=0) by mail194c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id x5QA1jqE023190; Wed, 26 Jun 2019 10:01:47 +0000 In-Reply-To: X-Mailer: Apple Mail (2.3445.104.11) X-CTCH-RefID: str=0001.0A0B0215.5D13428C.0036, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=e9Qot5h/ c=1 sm=1 tr=0 a=M+GU/qJco4WXjv8D6jB2IA==:117 a=M+GU/qJco4WXjv8D6jB2IA==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=pGLkceISAAAA:8 a=J76o89rjkjefrKwPeR8A:9 a=CjuIK1q_8ugA:10 a=msdtjPRGih3RbnlAbvYA:9 a=B2y7HmGcmWMA:10 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:161471 Archived-At: --Apple-Mail=_FF951FEC-2520-4C3E-A909-79C3625E881B Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii 26 juni 2019 kl. 11.38 skrev Robert Pluim : >=20 > insert 'the' before 'first' Oh dear, thank you for spotting that. > 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. >=20 > 'at that index in STRING, and omit the first START characters from the > return value.' Thank you, but that would approach circular reasoning (from what return = value, exactly? The one that we are in the process of defining?). I went = with [...] If START is non-nil, start replacements at that index in STRING, = and omit the first START characters of STRING from the return value. in the revised patch below. --Apple-Mail=_FF951FEC-2520-4C3E-A909-79C3625E881B Content-Disposition: attachment; filename=0001-Document-bug-in-replace-regexp-in-string.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0001-Document-bug-in-replace-regexp-in-string.patch" Content-Transfer-Encoding: quoted-printable =46rom=204fea4c96868985690c7db363bf29fac8beff19ff=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20=3D?UTF-8?q?Mattias=3D20Engdeg=3DC3=3DA5rd?=3D=20= =0ADate:=20Wed,=2026=20Jun=202019=2011:23:32=20+0200=0A= Subject:=20[PATCH]=20Document=20bug=20in=20`replace-regexp-in-string'=0A=0A= `replace-regexp-in-string'=20omits=20the=20first=20START=20characters=20= of=20the=0Ainput=20string=20in=20its=20return=20value.=20=20This=20is=20= a=20clear=20bug,=20but=20fixing=20it=0Aprobably=20causes=20more=20= trouble;=20document=20the=20behaviour=20instead=20(bug#36372).=0A=0A*=20= doc/lispref/searching.texi=20(Search=20and=20Replace)=0A*=20lisp/subr.el=20= (replace-regexp-in-string):=0ADocument=20current=20behaviour.=0A---=0A=20= doc/lispref/searching.texi=20|=204=20++--=0A=20lisp/subr.el=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20|=203=20++-=0A=202=20files=20changed,=204=20= insertions(+),=203=20deletions(-)=0A=0Adiff=20--git=20= a/doc/lispref/searching.texi=20b/doc/lispref/searching.texi=0Aindex=20= 33455114da..b82f5dade0=20100644=0A---=20a/doc/lispref/searching.texi=0A= +++=20b/doc/lispref/searching.texi=0A@@=20-1790,8=20+1790,8=20@@=20= Search=20and=20Replace=0A=20This=20function=20copies=20@var{string}=20= and=20searches=20it=20for=20matches=20for=0A=20@var{regexp},=20and=20= replaces=20them=20with=20@var{rep}.=20=20It=20returns=20the=0A=20= modified=20copy.=20=20If=20@var{start}=20is=20non-@code{nil},=20the=20= search=20for=0A-matches=20starts=20at=20that=20index=20in=20= @var{string},=20so=20matches=20starting=0A-before=20that=20index=20are=20= not=20changed.=0A+matches=20starts=20at=20that=20index=20in=20= @var{string},=20and=20the=20returned=20value=0A+does=20not=20include=20= the=20first=20@var{start}=20characters=20of=20@var{string}.=0A=20=0A=20= This=20function=20uses=20@code{replace-match}=20to=20do=20the=20= replacement,=20and=20it=0A=20passes=20the=20optional=20arguments=20= @var{fixedcase},=20@var{literal}=20and=0Adiff=20--git=20a/lisp/subr.el=20= b/lisp/subr.el=0Aindex=20baff1e909a..b981af6afe=20100644=0A---=20= a/lisp/subr.el=0A+++=20b/lisp/subr.el=0A@@=20-4208,7=20+4208,8=20@@=20= replace-regexp-in-string=0A=20=0A=20Optional=20arguments=20FIXEDCASE,=20= LITERAL=20and=20SUBEXP=20are=20like=20the=0A=20arguments=20with=20the=20= same=20names=20of=20function=20`replace-match'.=20=20If=20START=0A-is=20= non-nil,=20start=20replacements=20at=20that=20index=20in=20STRING.=0A+is=20= non-nil,=20start=20replacements=20at=20that=20index=20in=20STRING,=20and=20= omit=0A+the=20first=20START=20characters=20of=20STRING=20from=20the=20= return=20value.=0A=20=0A=20REP=20is=20either=20a=20string=20used=20as=20= the=20NEWTEXT=20arg=20of=20`replace-match'=20or=20a=0A=20function.=20=20= If=20it=20is=20a=20function,=20it=20is=20called=20with=20the=20actual=20= text=20of=20each=0A--=20=0A2.20.1=20(Apple=20Git-117)=0A=0A= --Apple-Mail=_FF951FEC-2520-4C3E-A909-79C3625E881B--