From unknown Sat Jun 21 12:28:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#36372: 27.0.50; replace-regexp-in-string skips START first chars in return value Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 25 Jun 2019 12:41:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 36372 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 36372@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.156146642029414 (code B ref -1); Tue, 25 Jun 2019 12:41:02 +0000 Received: (at submit) by debbugs.gnu.org; 25 Jun 2019 12:40:20 +0000 Received: from localhost ([127.0.0.1]:58876 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hfkkG-0007eM-CP for submit@debbugs.gnu.org; Tue, 25 Jun 2019 08:40:20 -0400 Received: from lists.gnu.org ([209.51.188.17]:48624) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hfkkD-0007eE-PB for submit@debbugs.gnu.org; Tue, 25 Jun 2019 08:40:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44062) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hfkkB-0007mx-N5 for bug-gnu-emacs@gnu.org; Tue, 25 Jun 2019 08:40:17 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,URIBL_BLOCKED autolearn=disabled version=3.3.2 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hfkkA-0002o4-IH for bug-gnu-emacs@gnu.org; Tue, 25 Jun 2019 08:40:15 -0400 Received: from mail1430c50.megamailservers.eu ([91.136.14.30]:48288 helo=mail118c50.megamailservers.eu) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hfkk9-0002lR-Vo for bug-gnu-emacs@gnu.org; Tue, 25 Jun 2019 08:40:14 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1561464111; bh=1mgz+NPMyEylJgMIPFIvhUxCM0EzDgPa7ocsXOsDsPM=; h=From:Subject:Date:To:From; b=p8qMtXg44sOiS+Paobd/LSTu8PFKkCb4AoKcFu6xsTDL0npHLj6cQlQ0N0LUP70/u DjVRkisncKntFRaJ2KPF7rQc/ME+CGUxJKx2tQ055I4geZfA6tBr83NQcWPfkRyozl 83VJdRtQ3u8N744BlT59/H2SzmRw6vdEUgM4VBFc= Feedback-ID: mattiase@acm.or Received: from [192.168.0.4] ([188.150.171.71]) (authenticated bits=0) by mail118c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id x5PC1oiI009710 for ; Tue, 25 Jun 2019 12:01:51 +0000 From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Message-Id: Date: Tue, 25 Jun 2019 14:01:49 +0200 X-Mailer: Apple Mail (2.3445.104.11) X-CTCH-RefID: str=0001.0A0B0201.5D120D2F.0060, 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-Rules: X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=JLcVTfCb c=1 sm=1 tr=0 a=SF+I6pRkHZhrawxbOkkvaA==:117 a=SF+I6pRkHZhrawxbOkkvaA==:17 a=IkcTkHD0fZMA:10 a=M6lMmiwvbBaVFJyVF6wA:9 a=QEXdDO2ut3YA:10 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] X-Received-From: 91.136.14.30 X-Spam-Score: -1.3 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) =46rom 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-=E2=80=98nil=E2=80=99, 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)) =3D> "abcXb" Bug#15107 is somewhat related. From unknown Sat Jun 21 12:28:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#36372: 27.0.50; replace-regexp-in-string skips START first chars in return value Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 25 Jun 2019 15:27:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36372 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Cc: 36372@debbugs.gnu.org Received: via spool by 36372-submit@debbugs.gnu.org id=B36372.156147638924571 (code B ref 36372); Tue, 25 Jun 2019 15:27:02 +0000 Received: (at 36372) by debbugs.gnu.org; 25 Jun 2019 15:26:29 +0000 Received: from localhost ([127.0.0.1]:33233 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hfnL3-0006OF-CN for submit@debbugs.gnu.org; Tue, 25 Jun 2019 11:26:29 -0400 Received: from eggs.gnu.org ([209.51.188.92]:53914) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hfnL1-0006O3-VA for 36372@debbugs.gnu.org; Tue, 25 Jun 2019 11:26:28 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:59915) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hfnKw-00077i-27; Tue, 25 Jun 2019 11:26:22 -0400 Received: from [176.228.60.248] (port=3059 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1hfnKv-0001Ru-Ak; Tue, 25 Jun 2019 11:26:21 -0400 Date: Tue, 25 Jun 2019 18:26:22 +0300 Message-Id: <83tvcdlm8x.fsf@gnu.org> From: Eli Zaretskii In-reply-to: (message from Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= on Tue, 25 Jun 2019 14:01:49 +0200) References: MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Mattias Engdegård > Date: Tue, 25 Jun 2019 14:01:49 +0200 > > (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. Both, I think ;-) Thanks. From unknown Sat Jun 21 12:28:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#36372: 27.0.50; replace-regexp-in-string skips START first chars in return value [PATCH] 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 09:32:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36372 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eli Zaretskii Cc: 36372@debbugs.gnu.org Received: via spool by 36372-submit@debbugs.gnu.org id=B36372.15615414743194 (code B ref 36372); Wed, 26 Jun 2019 09:32:02 +0000 Received: (at 36372) by debbugs.gnu.org; 26 Jun 2019 09:31:14 +0000 Received: from localhost ([127.0.0.1]:34251 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hg4Go-0000pS-GQ for submit@debbugs.gnu.org; Wed, 26 Jun 2019 05:31:14 -0400 Received: from mail1428c50.megamailservers.eu ([91.136.14.28]:47906 helo=mail118c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hg4Gl-0000p8-VL for 36372@debbugs.gnu.org; Wed, 26 Jun 2019 05:31:13 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1561541464; bh=ACoYBgA1U+rZxjRSR40SSXF54PvavyzHYRINYY1Vf5w=; h=From:Subject:Date:In-Reply-To:Cc:To:References:From; b=SxBD9550XyV3BFEBhro2/HJU3NqQKoR1TUPIXjFr39jEBgLwxlgiUqaGmUaJnbcZv xcA53XNttClLM+73rFVQ4P9kJULPjvwZSsWNA0fvFk9WO7Lh4IhcJ+J+hOzLUoP5+N fqUter8H6o7fSfKMkUm4q+50PimAhpvHhj2TbAgM= Feedback-ID: mattiase@acm.or Received: from [192.168.1.65] (c-e636e253.032-75-73746f71.bbcust.telenor.se [83.226.54.230]) (authenticated bits=0) by mail118c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id x5Q9V2b4025396; Wed, 26 Jun 2019 09:31:03 +0000 From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Message-Id: Content-Type: multipart/mixed; boundary="Apple-Mail=_E6AE78B3-1DCB-460D-9822-BD852A7478A0" Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Date: Wed, 26 Jun 2019 11:31:01 +0200 In-Reply-To: <83tvcdlm8x.fsf@gnu.org> References: <83tvcdlm8x.fsf@gnu.org> X-Mailer: Apple Mail (2.3445.104.11) X-CTCH-RefID: str=0001.0A0B0210.5D133B58.0057, 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-Rules: X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=JLcVTfCb c=1 sm=1 tr=0 a=M+GU/qJco4WXjv8D6jB2IA==:117 a=M+GU/qJco4WXjv8D6jB2IA==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=mDV3o1hIAAAA:8 a=eEMQBBp6JfhL4kqq34cA:9 a=CjuIK1q_8ugA:10 a=msdtjPRGih3RbnlAbvYA:9 a=B2y7HmGcmWMA:10 a=_FVE-zBwftR9WsbkzFJk:22 X-Spam-Score: 1.0 (+) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) --Apple-Mail=_E6AE78B3-1DCB-460D-9822-BD852A7478A0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii 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 needs = to be documented. >=20 > Both, I think ;-) Documenting a bug rather than fixing it never feels very satisfactory, = but it may be the lesser evil. What about this patch? --Apple-Mail=_E6AE78B3-1DCB-460D-9822-BD852A7478A0 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=20d5419cbf491cccb91843b8e3d6270df1c40a9004=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..86a907021c=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= first=20@var{start}=20characters=20of=20@var{string}.=0A=20=0A=20This=20= function=20uses=20@code{replace-match}=20to=20do=20the=20replacement,=20= and=20it=0A=20passes=20the=20optional=20arguments=20@var{fixedcase},=20= @var{literal}=20and=0Adiff=20--git=20a/lisp/subr.el=20b/lisp/subr.el=0A= index=20baff1e909a..ba388b3721=20100644=0A---=20a/lisp/subr.el=0A+++=20= b/lisp/subr.el=0A@@=20-4208,7=20+4208,8=20@@=20replace-regexp-in-string=0A= =20=0A=20Optional=20arguments=20FIXEDCASE,=20LITERAL=20and=20SUBEXP=20= are=20like=20the=0A=20arguments=20with=20the=20same=20names=20of=20= function=20`replace-match'.=20=20If=20START=0A-is=20non-nil,=20start=20= replacements=20at=20that=20index=20in=20STRING.=0A+is=20non-nil,=20start=20= replacements=20at=20that=20index=20in=20STRING.=20=20The=20return=0A= +value=20then=20omits=20the=20first=20START=20characters=20of=20STRING.=0A= =20=0A=20REP=20is=20either=20a=20string=20used=20as=20the=20NEWTEXT=20= arg=20of=20`replace-match'=20or=20a=0A=20function.=20=20If=20it=20is=20a=20= function,=20it=20is=20called=20with=20the=20actual=20text=20of=20each=0A= --=20=0A2.20.1=20(Apple=20Git-117)=0A=0A= --Apple-Mail=_E6AE78B3-1DCB-460D-9822-BD852A7478A0-- From unknown Sat Jun 21 12:28:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#36372: 27.0.50; replace-regexp-in-string skips START first chars in return value [PATCH] 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 X-GNU-PR-Keywords: To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Cc: Eli Zaretskii , 36372@debbugs.gnu.org Received: via spool by 36372-submit@debbugs.gnu.org id=B36372.15615419443986 (code B ref 36372); Wed, 26 Jun 2019 09:40:02 +0000 Received: (at 36372) by debbugs.gnu.org; 26 Jun 2019 09:39:04 +0000 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 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 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) 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) From: Robert Pluim References: <83tvcdlm8x.fsf@gnu.org> Mail-Copies-To: never Gmane-Reply-To-List: yes Date: Wed, 26 Jun 2019 11:38:53 +0200 In-Reply-To: ("Mattias \=\?utf-8\?Q\?Engdeg\=C3\=A5rd\=22's\?\= message of "Wed, 26 Jun 2019 11:31:01 +0200") Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) >>>>> 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) From unknown Sat Jun 21 12:28:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#36372: 27.0.50; replace-regexp-in-string skips START first chars in return value [PATCH] 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 X-GNU-PR-Keywords: To: Robert Pluim Cc: Eli Zaretskii , 36372@debbugs.gnu.org Received: via spool by 36372-submit@debbugs.gnu.org id=B36372.156154331814465 (code B ref 36372); Wed, 26 Jun 2019 10:02:02 +0000 Received: (at 36372) by debbugs.gnu.org; 26 Jun 2019 10:01:58 +0000 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 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 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 From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Message-Id: <829FF0B4-1CC8-4F89-A861-4929D2182DF5@acm.org> Content-Type: multipart/mixed; boundary="Apple-Mail=_FF951FEC-2520-4C3E-A909-79C3625E881B" Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Date: Wed, 26 Jun 2019 12:01:45 +0200 In-Reply-To: References: <83tvcdlm8x.fsf@gnu.org> 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-Rules: 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-Spam-Score: 1.0 (+) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) --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-- From unknown Sat Jun 21 12:28:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#36372: 27.0.50; replace-regexp-in-string skips START first chars in return value [PATCH] Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 26 Jun 2019 10:23:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36372 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Cc: 36372@debbugs.gnu.org Received: via spool by 36372-submit@debbugs.gnu.org id=B36372.156154453316372 (code B ref 36372); Wed, 26 Jun 2019 10:23:02 +0000 Received: (at 36372) by debbugs.gnu.org; 26 Jun 2019 10:22:13 +0000 Received: from localhost ([127.0.0.1]:34326 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hg549-0004G0-3e for submit@debbugs.gnu.org; Wed, 26 Jun 2019 06:22:13 -0400 Received: from quimby.gnus.org ([80.91.231.51]:38790) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hg547-0004Ft-SH for 36372@debbugs.gnu.org; Wed, 26 Jun 2019 06:22:12 -0400 Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=stories) by quimby.gnus.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hg542-0003fy-My; Wed, 26 Jun 2019 12:22:09 +0200 From: Lars Ingebrigtsen References: <83tvcdlm8x.fsf@gnu.org> Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAFVBMVEURDw0JBwVMSki7ubdy b24EAwIuLCtErD9UAAACYUlEQVQ4jV1UwXbbIBBcKYnOWjXW2cY8zq3h5ZyifZyj16pnmaj8/yd0 ALl2uyfEMLszywrqN2vfiUitK9FK65OtQRk4Ami4xpcbwBW47T8AlFZizkBPDaXOpBLEK/Z67jtm 2lSctDGFSdzV44gubT4EpSrQd62UmGpurMo5GpJSyuNzLyraXgswdjrXUkrK8cmJfK0ABBB1KWns K3WWt3icS3EtAYyoUEO80kokNEsuHlTDxx6kySl0pUO+byWVQS1I5nFMBA9KjDvNMEtnkJU+8ed0 AYFEvLzMTIQNa816TN0mWcZzknjIDNbZmZMAo8HQBta25OKcYCBEK1HDpZqg0CwLcjGH0oe9J/An fgEFgORP+xBvd6Aw/gLfbwA6kaM2S6xvDihCPKTUjNZcR22dk6TO5loZQ1yp26ys1E4X63VqAx+y XI5a2+Nk0UidhZvW16tlHt5t6Pw6YpJcYH49wXkB+jC51b6V6u7KT6fdII9awcm5SHUNP6tDlTts +ni2Ysq+XXmk7xVoFVqKMSsNuaTfM8cK6OnBuCvr9wzkKbD/9ApxxdViCib7f1waGraHMdxHEd+B XrWYpPcazlpfB9bTENMYtS/TWGcOkX+DheZR+cnfZ64G5YsHfRJV0rnb7QCY51bgBfyIW6o/VNQ0 MzrWfHTRi9nU2mAEMadaaM7XxcsH1kF7qtGKQao9enjN+bXCCIq6AzO/nl3RlFX7HeAMfGYXMRaC ofz3zEuu9Et8VVS0ZcZcWT8nV7RCuknpXmP5AftVqsdj8QA861Aejtw5PB53YFMvRV3UBi/MH7Cj 5g9wELhsAAAAAElFTkSuQmCC Date: Wed, 26 Jun 2019 12:22:06 +0200 In-Reply-To: (Robert Pluim's message of "Wed, 26 Jun 2019 11:38:53 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Robert Pluim writes: > 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. Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Robert Pluim writes: > 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. Yup. But this is very unusual behaviour for such a function, so even if documented, it's going to cause confusion... Has anybody grepped through the Emacs tree to see whether anybody uses the parameter, and if so, whether it's expecting the wrong behaviour? -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From unknown Sat Jun 21 12:28:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#36372: 27.0.50; replace-regexp-in-string skips START first chars in return value [PATCH] Resent-From: Robert Pluim Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 26 Jun 2019 11:12:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36372 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Cc: Eli Zaretskii , 36372@debbugs.gnu.org Received: via spool by 36372-submit@debbugs.gnu.org id=B36372.156154750321367 (code B ref 36372); Wed, 26 Jun 2019 11:12:01 +0000 Received: (at 36372) by debbugs.gnu.org; 26 Jun 2019 11:11:43 +0000 Received: from localhost ([127.0.0.1]:34366 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hg5q3-0005YZ-Hc for submit@debbugs.gnu.org; Wed, 26 Jun 2019 07:11:43 -0400 Received: from mail-ed1-f47.google.com ([209.85.208.47]:35892) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hg5q2-0005YM-By for 36372@debbugs.gnu.org; Wed, 26 Jun 2019 07:11:42 -0400 Received: by mail-ed1-f47.google.com with SMTP id k21so2776499edq.3 for <36372@debbugs.gnu.org>; Wed, 26 Jun 2019 04:11:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :mime-version:content-transfer-encoding; bh=DNmjePboYo2prlDG3rvv1pWRtOpi9LNiuxwlKgHq/wI=; b=nwwkmIrmUy9JzvCTKLhy7K0n4WdAS+2hnxN4FVWvFMtbvcGfNH/Blu8MtBF/GA/3x5 7LLzQhwXFtvdX06k/Xun37yYoRWFDCdjfFhrWliDXAhcU+Znkqcw4WX+5oP18UcBOia2 WRrGxfzXaO/7S3hvLqoR7Fe+45qaaiLH21Rl/qCMotkVU5FWVizEQu23mxAvEmDwRyFd ivLuUyy0u/JMlzVkaESM5J3kXYcR3pzCX7/IO/A1qlkWB6sWZd+QxJClILsj+Wg62sET Tfey0J7r+xwAEVp3PSTjBbQrAnn/QAcbRT/e7xQ1Q5TXNFnYThjhQpNe7Y5VuqENsWc6 LTVQ== 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:date:in-reply-to :message-id:mime-version:content-transfer-encoding; bh=DNmjePboYo2prlDG3rvv1pWRtOpi9LNiuxwlKgHq/wI=; b=ckupM0wQo5zJQM+qgbdtEiio+GKgm6CeQ1MVoqf9ji4r1Uzpm6McDqrtdhAv8kfCjt nJXMoMPi60ub/ylxzzhl5g7W+DbN4C+blBQEH4nBnq0vr2EXZWM0WKbCOekh/17slX7Y zncZ3+qa7xPzfbI+fHP62f/T3O7UAgVi7f43rsnoaQPypB5IBnURodLwvKc8oIXMzY5q 5YTBp0dgeAGQiKdDQQ2AgVhfOnqUfHdOglgBGuOX6iho4XA7GcRm/zx/fN25JeWm+paB 2WwT4ZWFLB7d7LNI39CgFwRRBACaWo8PSoZ219FR7tuO7P5KP4oVF7ylTnBe/JmiJ24V HwUw== X-Gm-Message-State: APjAAAWj371MF1h1f90feJoYE2IIZ8JnfaCoXlxwWhmZlG0AVJuf0bmr Km1pct5vsvHWRhZJxxS8l/itx402HqI= X-Google-Smtp-Source: APXvYqwfcreRCwRHyo3ymlOJf3eq/9orrBPBlUhGUxupJlXOHYHS2pebljj/laxg/Ms/q1Sj6ZGFdA== X-Received: by 2002:a17:906:4e92:: with SMTP id v18mr3625818eju.57.1561547495940; Wed, 26 Jun 2019 04:11:35 -0700 (PDT) Received: from rpluim-mac ([149.5.228.1]) by smtp.gmail.com with ESMTPSA id p18sm2903024ejr.61.2019.06.26.04.11.34 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 26 Jun 2019 04:11:35 -0700 (PDT) From: Robert Pluim References: <83tvcdlm8x.fsf@gnu.org> <829FF0B4-1CC8-4F89-A861-4929D2182DF5@acm.org> Date: Wed, 26 Jun 2019 13:11:34 +0200 In-Reply-To: <829FF0B4-1CC8-4F89-A861-4929D2182DF5@acm.org> ("Mattias \=\?utf-8\?Q\?Engdeg\=C3\=A5rd\=22's\?\= message of "Wed, 26 Jun 2019 12:01:45 +0200") Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) >>>>> On Wed, 26 Jun 2019 12:01:45 +0200, Mattias Engdeg=C3=A5rd said: >> 'at that index in STRING, and omit the first START characters from t= he >> return value.' Mattias> Thank you, but that would approach circular reasoning (from wh= at return value, exactly? The one that we are in the process of defining?).= I went with Mattias> [...] If START is non-nil, start replacements at that index in= STRING, and omit the first START characters of STRING from the return valu= e. Sure, that works. Robert From unknown Sat Jun 21 12:28:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#36372: 27.0.50; replace-regexp-in-string skips START first chars in return value [PATCH] Resent-From: Robert Pluim Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 26 Jun 2019 12:33:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36372 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Lars Ingebrigtsen Cc: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= , 36372@debbugs.gnu.org Received: via spool by 36372-submit@debbugs.gnu.org id=B36372.156155237212912 (code B ref 36372); Wed, 26 Jun 2019 12:33:02 +0000 Received: (at 36372) by debbugs.gnu.org; 26 Jun 2019 12:32:52 +0000 Received: from localhost ([127.0.0.1]:34460 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hg76Z-0003MA-LX for submit@debbugs.gnu.org; Wed, 26 Jun 2019 08:32:51 -0400 Received: from mail-wm1-f47.google.com ([209.85.128.47]:35209) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hg76X-0003Lw-1V for 36372@debbugs.gnu.org; Wed, 26 Jun 2019 08:32:49 -0400 Received: by mail-wm1-f47.google.com with SMTP id c6so1943289wml.0 for <36372@debbugs.gnu.org>; Wed, 26 Jun 2019 05:32:48 -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; bh=XRjVkcdtnpqJBx227/x5ZXOo8rZDEAh4t7/APlXaBnE=; b=WYsWwGDCTGKRbC4/Bc4Kr1NwzCvxgkqsMgxFUWmVDL35X+ehqZD9CedQ/g5sMavEyf Wq9W9Z06z0dh9G+a8w7s2rBIYSboq27s/UOGo8KNwnl/MitfWHeyxn6Vq9J6Rjgybzem mQA6CktUPUrNIOuTa4tVsJMq1eReRzVB0Yre9ytmBIvfVsLB9s6Lnh4uzj16tNg0Gh8Z tUN2H/0piREYGizjt2afX8Cmk0Fz8Ed6vK2CTiqy5GoX/qgL/qwNpRtabkKkocvsSaHv lXyOAI6WWqsM1pvLv5iM37pyl7sNM/DbP3CYmh2rYqF+jIdSoZDDQzi3hK0ET2lVRWO7 rOjA== 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; bh=XRjVkcdtnpqJBx227/x5ZXOo8rZDEAh4t7/APlXaBnE=; b=XbRSdhZi9h3iu+93z00jf0Y6gizBmWC0/Gsv9D6Ff1LhfGm7dcdi/jgdl8DpAtryOt C+8Omu74DlJf9o8Td4mzped/ZreWa5PU9yLyTgRTHogkzUpr0nPFvOzQHvTd3fQJCzJN dxFx640jvb1zVICNYIsmCDFvdQqi8lnSLgB1rcPI2YKaJylt/88HDSCa/mkssp4Lgeog gZfd2w6rCQNgwnERis+laCppVaRsozBNl5CqgyzTVEaJax24enJitO8Y0wnMtD5LlBzp +nMlBBbnEvNyvajG3lNb2femKZaAULXUud/EQ3JHvNvEsOOTITxf+U2Chmzt2NXPdIJF F4FA== X-Gm-Message-State: APjAAAXC9WvbeqMu89xAOu7ipZFT7E/IJjXgElEHWNAh8LMQ2Ze2zAKr cjT/1wAUmUQHFl5Cxc7BHJ3NnqKh6yw= X-Google-Smtp-Source: APXvYqwuT8X4sqMY7Z+ood0oJ7mSGEZD35T7aelByD29L9FvXdvfZDZnu9HkFr6eiJTIzhk2coR73g== X-Received: by 2002:a1c:7414:: with SMTP id p20mr2130237wmc.145.1561552362664; Wed, 26 Jun 2019 05:32:42 -0700 (PDT) Received: from rpluim-mac ([149.5.228.1]) by smtp.gmail.com with ESMTPSA id m9sm18385793wrn.92.2019.06.26.05.32.40 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 26 Jun 2019 05:32:41 -0700 (PDT) From: Robert Pluim References: <83tvcdlm8x.fsf@gnu.org> Mail-Copies-To: never Gmane-Reply-To-List: yes Date: Wed, 26 Jun 2019 14:32:40 +0200 In-Reply-To: (Lars Ingebrigtsen's message of "Wed, 26 Jun 2019 12:22:06 +0200") Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) >>>>> On Wed, 26 Jun 2019 12:22:06 +0200, Lars Ingebrigtsen said: Larsi> Robert Pluim writes: >> 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. Larsi> Yup. But this is very unusual behaviour for such a function, so even if Larsi> documented, it's going to cause confusion... Larsi> Has anybody grepped through the Emacs tree to see whether anybody uses Larsi> the parameter, and if so, whether it's expecting the wrong behaviour? 'grep'? Sounds complicated. I ran a combination of find-dired and diredp-do-apply-function over the lisp sources, and none of the 656 calls to replace-regexp-in-string have 7 arguments. Robert From unknown Sat Jun 21 12:28:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#36372: 27.0.50; replace-regexp-in-string skips START first chars in return value [PATCH] Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 26 Jun 2019 13:52:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36372 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Cc: 36372@debbugs.gnu.org Received: via spool by 36372-submit@debbugs.gnu.org id=B36372.156155710728483 (code B ref 36372); Wed, 26 Jun 2019 13:52:01 +0000 Received: (at 36372) by debbugs.gnu.org; 26 Jun 2019 13:51:47 +0000 Received: from localhost ([127.0.0.1]:34545 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hg8Kw-0007PL-Vh for submit@debbugs.gnu.org; Wed, 26 Jun 2019 09:51:47 -0400 Received: from quimby.gnus.org ([80.91.231.51]:49174) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hg8Ku-0007PB-9k for 36372@debbugs.gnu.org; Wed, 26 Jun 2019 09:51:44 -0400 Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=stories) by quimby.gnus.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hg8Kr-0000N4-5V; Wed, 26 Jun 2019 15:51:43 +0200 From: Lars Ingebrigtsen References: <83tvcdlm8x.fsf@gnu.org> Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAFVBMVEURDw0JBwVMSki7ubdy b24EAwIuLCtErD9UAAACYUlEQVQ4jV1UwXbbIBBcKYnOWjXW2cY8zq3h5ZyifZyj16pnmaj8/yd0 ALl2uyfEMLszywrqN2vfiUitK9FK65OtQRk4Ami4xpcbwBW47T8AlFZizkBPDaXOpBLEK/Z67jtm 2lSctDGFSdzV44gubT4EpSrQd62UmGpurMo5GpJSyuNzLyraXgswdjrXUkrK8cmJfK0ABBB1KWns K3WWt3icS3EtAYyoUEO80kokNEsuHlTDxx6kySl0pUO+byWVQS1I5nFMBA9KjDvNMEtnkJU+8ed0 AYFEvLzMTIQNa816TN0mWcZzknjIDNbZmZMAo8HQBta25OKcYCBEK1HDpZqg0CwLcjGH0oe9J/An fgEFgORP+xBvd6Aw/gLfbwA6kaM2S6xvDihCPKTUjNZcR22dk6TO5loZQ1yp26ys1E4X63VqAx+y XI5a2+Nk0UidhZvW16tlHt5t6Pw6YpJcYH49wXkB+jC51b6V6u7KT6fdII9awcm5SHUNP6tDlTts +ni2Ysq+XXmk7xVoFVqKMSsNuaTfM8cK6OnBuCvr9wzkKbD/9ApxxdViCib7f1waGraHMdxHEd+B XrWYpPcazlpfB9bTENMYtS/TWGcOkX+DheZR+cnfZ64G5YsHfRJV0rnb7QCY51bgBfyIW6o/VNQ0 MzrWfHTRi9nU2mAEMadaaM7XxcsH1kF7qtGKQao9enjN+bXCCIq6AzO/nl3RlFX7HeAMfGYXMRaC ofz3zEuu9Et8VVS0ZcZcWT8nV7RCuknpXmP5AftVqsdj8QA861Aejtw5PB53YFMvRV3UBi/MH7Cj 5g9wELhsAAAAAElFTkSuQmCC Date: Wed, 26 Jun 2019 15:51:41 +0200 In-Reply-To: (Robert Pluim's message of "Wed, 26 Jun 2019 14:32:40 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Robert Pluim writes: > 'grep'? Sounds complicated. I ran a combination of find-dired and > diredp-do-apply-function over the lisp sources, and none of the 656 > calls to replace-regexp-in-string have 7 arguments. Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Robert Pluim writes: > 'grep'? Sounds complicated. I ran a combination of find-dired and > diredp-do-apply-function over the lisp sources, and none of the 656 > calls to replace-regexp-in-string have 7 arguments. I started thinking about adding a check in the byte compiler for this, but now you've checked anyway. :-) So it isn't used in-tree at all. Since it's an (in my opinion) pretty useless parameter as it's currently implemented, I think we should deprecate the parameter and remove the documentation. Then, perhaps, in ten years time we can reintroduce the parameter with better semantics. :-) -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From unknown Sat Jun 21 12:28:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#36372: 27.0.50; replace-regexp-in-string skips START first chars in return value [PATCH] Resent-From: Drew Adams Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 26 Jun 2019 14:02:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36372 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Lars Ingebrigtsen , Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Cc: 36372@debbugs.gnu.org Received: via spool by 36372-submit@debbugs.gnu.org id=B36372.15615576773281 (code B ref 36372); Wed, 26 Jun 2019 14:02:02 +0000 Received: (at 36372) by debbugs.gnu.org; 26 Jun 2019 14:01:17 +0000 Received: from localhost ([127.0.0.1]:36617 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hg8U9-0000qb-5Q for submit@debbugs.gnu.org; Wed, 26 Jun 2019 10:01:17 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:34474) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hg8U6-0000kp-U1 for 36372@debbugs.gnu.org; Wed, 26 Jun 2019 10:01:15 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x5QDxKov071047; Wed, 26 Jun 2019 14:01:07 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=mime-version : message-id : date : from : sender : to : cc : subject : references : in-reply-to : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=g0JGLG+GFxvPtT9bP4nRH2qBa+aRXqROrFKTA2d4N8w=; b=yF5Qlbr8gGXDh6FZZDvZXE5a89D6wdQxwAepaavpVWSu7pQejmlC81AuGEqOlqYfb70f KkdRBjSsgIhw12Qqpyy5gkKL+Hnu0QVTNr9dKVG+HH0QtCEEatfROvVXYZDp9KAw2imK /VM3qYQcYms6lXJJ9/1wtfhSUkuiY6S409MDaIAC8WBqxRRaV0pJJZRpIMqkxVh/7vps rZsIEUJjXcJYFwoBr/Wk5dXbbFMhQIKMEhk2BkJooB8w2+C5cjd84gg41HgYZ4hWuLXj FI//95D6luOBuUZ6r8cQvhFrRA2ZQBvLXTiGbKMxiS+9bBosg6LBmsgm0229NOEl8mch sg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 2t9cyqjf5h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Jun 2019 14:01:07 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x5QDxtJn174307; Wed, 26 Jun 2019 14:01:06 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3030.oracle.com with ESMTP id 2t99f4fsrg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Jun 2019 14:01:06 +0000 Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x5QE15oP020284; Wed, 26 Jun 2019 14:01:05 GMT MIME-Version: 1.0 Message-ID: <732ddb90-5456-45dc-9c79-15d0a0662c28@default> Date: Wed, 26 Jun 2019 07:01:04 -0700 (PDT) From: Drew Adams References: <83tvcdlm8x.fsf@gnu.org> In-Reply-To: X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 16.0.4861.0 (x86)] Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9299 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906260167 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9299 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906260168 X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > So it isn't used in-tree at all. Since it's an (in my opinion) pretty > useless parameter as it's currently implemented, I think we should ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > deprecate the parameter and remove the documentation. >=20 > Then, perhaps, in ten years time we can reintroduce the parameter with > better semantics. :-) 1. Whether it's used in-tree is not sufficient. 2. Whether it is useless "as it's currently implemented" is not sufficient. That's what implementation bugs are about. 3. But I agree that it is likely very rarely used, if at all. (Searched my code and found no matches, as one example.) 3. IF it has a use, when fixed as you see fit, then fix it, and call out the fixed behavior as an incompatible change. In that case, do not deprecate it. (I don't know that it has a use, if fixed, hence "IF".) From unknown Sat Jun 21 12:28:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#36372: 27.0.50; replace-regexp-in-string skips START first chars in return value [PATCH] Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 26 Jun 2019 14:52:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36372 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Lars Ingebrigtsen Cc: mattiase@acm.org, 36372@debbugs.gnu.org Received: via spool by 36372-submit@debbugs.gnu.org id=B36372.15615606965315 (code B ref 36372); Wed, 26 Jun 2019 14:52:01 +0000 Received: (at 36372) by debbugs.gnu.org; 26 Jun 2019 14:51:36 +0000 Received: from localhost ([127.0.0.1]:36747 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hg9Gq-0001Nf-7w for submit@debbugs.gnu.org; Wed, 26 Jun 2019 10:51:36 -0400 Received: from eggs.gnu.org ([209.51.188.92]:56471) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hg9Go-0001NP-8B for 36372@debbugs.gnu.org; Wed, 26 Jun 2019 10:51:35 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:53419) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hg9Ge-0008Fm-Tu; Wed, 26 Jun 2019 10:51:28 -0400 Received: from [176.228.60.248] (port=1114 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1hg9GZ-0007kD-3l; Wed, 26 Jun 2019 10:51:20 -0400 Date: Wed, 26 Jun 2019 17:51:01 +0300 Message-Id: <8336jwl7sa.fsf@gnu.org> From: Eli Zaretskii In-reply-to: (message from Lars Ingebrigtsen on Wed, 26 Jun 2019 15:51:41 +0200) References: <83tvcdlm8x.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Lars Ingebrigtsen > Date: Wed, 26 Jun 2019 15:51:41 +0200 > Cc: 36372@debbugs.gnu.org > > So it isn't used in-tree at all. Since it's an (in my opinion) pretty > useless parameter as it's currently implemented, I think we should > deprecate the parameter and remove the documentation. I disagree. This has been in Emacs since 2000, it's too late to remove it. We must assume that whoever wrote the code (which operated like that from the get-go) actually meant for it to operate like that. From unknown Sat Jun 21 12:28:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#36372: 27.0.50; replace-regexp-in-string skips START first chars in return value [PATCH] Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 26 Jun 2019 15:18:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36372 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Cc: 36372@debbugs.gnu.org Received: via spool by 36372-submit@debbugs.gnu.org id=B36372.156156227424712 (code B ref 36372); Wed, 26 Jun 2019 15:18:02 +0000 Received: (at 36372) by debbugs.gnu.org; 26 Jun 2019 15:17:54 +0000 Received: from localhost ([127.0.0.1]:36818 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hg9gI-0006QW-0I for submit@debbugs.gnu.org; Wed, 26 Jun 2019 11:17:54 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34890) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hg9gE-0006Mk-Mf for 36372@debbugs.gnu.org; Wed, 26 Jun 2019 11:17:52 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:53979) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hg9fy-00062I-PW; Wed, 26 Jun 2019 11:17:37 -0400 Received: from [176.228.60.248] (port=2719 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1hg9ft-0000UD-67; Wed, 26 Jun 2019 11:17:30 -0400 Date: Wed, 26 Jun 2019 18:17:13 +0300 Message-Id: <83woh8js06.fsf@gnu.org> From: Eli Zaretskii In-reply-to: (message from Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= on Wed, 26 Jun 2019 11:31:01 +0200) References: <83tvcdlm8x.fsf@gnu.org> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Mattias Engdegård > Date: Wed, 26 Jun 2019 11:31:01 +0200 > Cc: 36372@debbugs.gnu.org > > diff --git a/doc/lispref/searching.texi b/doc/lispref/searching.texi > index 33455114da..86a907021c 100644 > --- a/doc/lispref/searching.texi > +++ b/doc/lispref/searching.texi > @@ -1790,8 +1790,8 @@ Search and Replace > This function copies @var{string} and searches it for matches for > @var{regexp}, and replaces them with @var{rep}. It returns the > modified copy. If @var{start} is non-@code{nil}, the search for > -matches starts at that index in @var{string}, so matches starting > -before that index are not changed. > +matches starts at that index in @var{string}, and the returned value > +does not include first @var{start} characters of @var{string}. For the manual, I'd expand a bit on this, and explained how to get the result you thought you will when using non-nil START (by concatenating with the initial substring). Thanks. From unknown Sat Jun 21 12:28:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#36372: 27.0.50; replace-regexp-in-string skips START first chars in return value [PATCH] 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 15:21:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36372 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eli Zaretskii , =?UTF-8?Q?Cl=C3=A9ment?= Pit-Claudel Cc: Lars Ingebrigtsen , 36372@debbugs.gnu.org Received: via spool by 36372-submit@debbugs.gnu.org id=B36372.156156241024955 (code B ref 36372); Wed, 26 Jun 2019 15:21:02 +0000 Received: (at 36372) by debbugs.gnu.org; 26 Jun 2019 15:20:10 +0000 Received: from localhost ([127.0.0.1]:36823 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hg9iU-0006UR-EF for submit@debbugs.gnu.org; Wed, 26 Jun 2019 11:20:10 -0400 Received: from mail214c50.megamailservers.eu ([91.136.10.224]:42496 helo=mail193c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hg9iR-0006UE-VE for 36372@debbugs.gnu.org; Wed, 26 Jun 2019 11:20:09 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1561562405; bh=pqUpNQk/pMdLNNh48GxbT4QWqvfRWWgiFKjXJTiFLvE=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=Lq/Ch4t0D3FjisxNkq5e6fax3r18FksUzIDbV6Fh3dAzlv4/2+pxFurtfcU7tizhc CMNX3InzpJwAbuxcTL9+yOOX2WbnUClBiauXvGWxaTFWdm6mdsPFQO8XX7pTJum7nt SCo8nPe+XosJm5zg8g9/Fsr94wWR1fHb2eV8Rxug= Feedback-ID: mattiase@acm.or Received: from [192.168.1.65] (c-e636e253.032-75-73746f71.bbcust.telenor.se [83.226.54.230]) (authenticated bits=0) by mail193c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id x5QFK3BD030497; Wed, 26 Jun 2019 15:20:04 +0000 Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= In-Reply-To: <8336jwl7sa.fsf@gnu.org> Date: Wed, 26 Jun 2019 17:20:02 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: References: <83tvcdlm8x.fsf@gnu.org> <8336jwl7sa.fsf@gnu.org> X-Mailer: Apple Mail (2.3445.104.11) X-CTCH-RefID: str=0001.0A0B020E.5D138D25.002C, 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-Rules: X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=KsZjJ1eN c=1 sm=1 tr=0 a=M+GU/qJco4WXjv8D6jB2IA==:117 a=M+GU/qJco4WXjv8D6jB2IA==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=IkcTkHD0fZMA:10 a=mDV3o1hIAAAA:8 a=_SgBhRY-wxL7eVxdMXcA:9 a=QEXdDO2ut3YA:10 a=_FVE-zBwftR9WsbkzFJk:22 X-Spam-Score: 1.0 (+) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) 26 juni 2019 kl. 16.51 skrev Eli Zaretskii : >>=20 >> So it isn't used in-tree at all. Since it's an (in my opinion) = pretty >> useless parameter as it's currently implemented, I think we should >> deprecate the parameter and remove the documentation. >=20 > I disagree. This has been in Emacs since 2000, it's too late to > remove it. We must assume that whoever wrote the code (which operated > like that from the get-go) actually meant for it to operate like that. It may be too late to change, but that doesn't mean that we have to = agree with your last statement: it looks like a mistake from the very = beginning to me. Given the seventh argument's infrequency of use (and = the lack of tests), this is perfectly plausible. By the way, I found no use of the START argument in GNU ELPA either so I = started searching all elisp code on my disk, and found exactly one, in = company-coq. Cl=C3=A9ment, apologies for dragging you into the discussion, but when = you woke up this morning, you probably didn't know that you were = possibly the only man in history to use the last argument to = replace-regexp-in-string. Now I would be curious to know: (1) Does this code, in company-coq--loc-fully-qualified-name, actually = work the way you intended? (Looks like it.) (2) Did you learn how the START parameter affects the return value by = reading the doc string, the manual, the source code, or by testing? (3) Are you aware of other code using the START parameter to = replace-regexp-in-string? Clearly this is anecdotal evidence but we have little else. From unknown Sat Jun 21 12:28:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#36372: 27.0.50; replace-regexp-in-string skips START first chars in return value [PATCH] Resent-From: =?UTF-8?Q?Cl=C3=A9ment?= Pit-Claudel Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 26 Jun 2019 16:00:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36372 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= , Eli Zaretskii Cc: Lars Ingebrigtsen , 36372@debbugs.gnu.org Received: via spool by 36372-submit@debbugs.gnu.org id=B36372.15615647864944 (code B ref 36372); Wed, 26 Jun 2019 16:00:02 +0000 Received: (at 36372) by debbugs.gnu.org; 26 Jun 2019 15:59:46 +0000 Received: from localhost ([127.0.0.1]:36895 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hgAKn-0001Hf-V3 for submit@debbugs.gnu.org; Wed, 26 Jun 2019 11:59:46 -0400 Received: from mail-qt1-f176.google.com ([209.85.160.176]:45301) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hgAKl-0001HQ-Lp for 36372@debbugs.gnu.org; Wed, 26 Jun 2019 11:59:44 -0400 Received: by mail-qt1-f176.google.com with SMTP id j19so2892493qtr.12 for <36372@debbugs.gnu.org>; Wed, 26 Jun 2019 08:59:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=9gtBXZhnFVhiT34+TZ/uwRZCYASW8sjoXTibHqKldII=; b=sVcGXoG/xOXFBJQrokLqJ2MCp2Z5Va4LAauN3Q2tKcd9MfWVyA7yPJKHUaS1mfE6eS SizkoPgc2R7pZTe9WbO6U49M1AQwNGvG5he5jN10Or4Dur9DMaBUom/2IXp5I1nM2u9k NTJCqa59BYRkdILEHYPNLW1i4ttf8xYJCNTolUIbjbT+QSEjDdMOesJFO7vnnzNndVzA kAKroMdib1RUpAQROTZQxp0/mszfs4OCgUUxvAi8K29O24mKogmD/Ec7lMsHDBa+b6Vp fWVtiToOGSosQuYrCXL5bykz+xc3u8uE0IucosXvpxf/R0gdCQXWB0DVODnlldNbHYq8 icLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=9gtBXZhnFVhiT34+TZ/uwRZCYASW8sjoXTibHqKldII=; b=PZrQyTd/4g22iEAQDCnMvqhrsxnJs4f3uWOwp3jQktCRUTgpt9+xwsQ2EkWPiPVt3H YwX2puTmAoq82GUATelKUTXmnOIHO8ie2YXEqhG3YuZH1pAkFTw8azA/P+nWxoHg/fW/ edk6oNgLbJVLOmn2wQc2e1wAT+BG/cRGNPZCWtJJXnGu+Ht45fKU7ugFulpZsn2+8kqt /PKfDnoF7EA5teivvKJ8CD7Ku7ixrTiksnxJmgK/U1f57nzkewcEPm34Zp5JA6pisVOG yGIQBjw4Lj8Yk7+A/99tFv1mqnf+2sgJuMHyf3CEXc6FpbibnBy/+GJ+KrcEtjNoMtsj GJJg== X-Gm-Message-State: APjAAAUbPGDncrb945d/fKRykF4oWf0S28HrRBefr8zDCMYBWj40kWb9 aQ0QiIEHa+OROsw4KgZF1I82pULG X-Google-Smtp-Source: APXvYqzf9/tEYcWCyg8GYoFTtur8APBRYZAOztZPf4EXwRxj2VS3LIvmBZyoWctHCylhrG+vHa4zYw== X-Received: by 2002:a0c:b163:: with SMTP id r32mr4191731qvc.169.1561564776790; Wed, 26 Jun 2019 08:59:36 -0700 (PDT) Received: from [128.30.93.186] (30-93-186.dynamic.csail.mit.edu. [128.30.93.186]) by smtp.googlemail.com with ESMTPSA id o54sm11444024qtb.63.2019.06.26.08.59.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Jun 2019 08:59:36 -0700 (PDT) References: <83tvcdlm8x.fsf@gnu.org> <8336jwl7sa.fsf@gnu.org> From: =?UTF-8?Q?Cl=C3=A9ment?= Pit-Claudel Message-ID: Date: Wed, 26 Jun 2019 11:59:35 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On 2019-06-26 11:20, Mattias Engdegård wrote: > Clément, apologies for dragging you into the discussion, but when you woke up this morning, you probably didn't know that you were possibly the only man in history to use the last argument to replace-regexp-in-string. Well, my morning just got a lot more interesting :) > Now I would be curious to know: > > (1) Does this code, in company-coq--loc-fully-qualified-name, actually work the way you intended? (Looks like it.) Yes, I think it does. It's a bit inscrutable, so here's an annotated copy: (defun company-coq--loc-fully-qualified-name (fqn) ;; assume fqn is Coq.Init.Nat.max (let* ((spec (company-coq-longest-matching-path-spec fqn)) ;; … spec is ("Coq.Init" . "/build/coq/theories/Init/") (logical (if spec (concat (car spec) ".") "")) ;; … logical is "Coq.Init." (mod-name (replace-regexp-in-string "\\..*\\'" "" fqn nil nil nil (length logical)))) ;; … mod-name is "Nat" (company-coq-library-path logical mod-name spec))) ;; … return /build/coq/theories/Init/Nat.v The reason for this odd dance is that a Coq identifier is essentially a directory path (Coq.Init.) + a file name (here Nat.) + an identifier name (max). But in some cases there can be modules in the path too, like maybe Coq.Init.Nat.XYZ.max, and in those cases the file is still only 'Nat.' This code would probably be clearer if I just used a substring to trim out the beginning of the string ^^ > (2) Did you learn how the START parameter affects the return value by reading the doc string, the manual, the source code, or by testing? Almost certainly the docstring, confirmed by testing. I haven't looked at this section of the manual. > (3) Are you aware of other code using the START parameter to replace-regexp-in-string? Nothing off the top of my head, but I probably wouldn't have thought of the instance in company-coq either. A quick grep through my local sources doesn't turn up anything else, but a quick visual check isn't a very reliable method (did you use a plain grep to find the instance in company-coq, or do you have a more sophisticated trick?). Hope this helps, Clément. From unknown Sat Jun 21 12:28:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#36372: 27.0.50; replace-regexp-in-string skips START first chars in return value [PATCH] 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 17:04:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36372 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: =?UTF-8?Q?Cl=C3=A9ment?= Pit-Claudel Cc: Eli Zaretskii , Lars Ingebrigtsen , 36372@debbugs.gnu.org Received: via spool by 36372-submit@debbugs.gnu.org id=B36372.156156860811650 (code B ref 36372); Wed, 26 Jun 2019 17:04:02 +0000 Received: (at 36372) by debbugs.gnu.org; 26 Jun 2019 17:03:28 +0000 Received: from localhost ([127.0.0.1]:36947 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hgBKR-00031p-Lt for submit@debbugs.gnu.org; Wed, 26 Jun 2019 13:03:28 -0400 Received: from mail175c50.megamailservers.eu ([91.136.10.185]:45368 helo=mail50c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hgBKO-00031e-D0 for 36372@debbugs.gnu.org; Wed, 26 Jun 2019 13:03:25 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1561568602; bh=dDgVpYS+BW6pEUHBAyOG01c6KLIpsb2AJPm/R3Wrmxg=; h=From:Subject:Date:In-Reply-To:Cc:To:References:From; b=aSyitmkljg6d1FjGZTJdX46l8R01vTXV43OgLCnGuzS1QOPUmU0hkVi5umFCU0Cix tPEmc6qtrqFjafDyupN/OD/9nsZHGZnHaOwsU3BN6uhSNLACNij8Gppc3S/Ov0fH9p kqFQqb2s4wamfbt/SlYnoK8EE3w3eTW/YIc5+YNs= Feedback-ID: mattiase@acm.or Received: from [192.168.1.65] (c-e636e253.032-75-73746f71.bbcust.telenor.se [83.226.54.230]) (authenticated bits=0) by mail50c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id x5QH3JC9014502; Wed, 26 Jun 2019 17:03:21 +0000 From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Message-Id: <4BBC2AEF-642C-40C8-9E28-570C4BA21F18@acm.org> Content-Type: multipart/mixed; boundary="Apple-Mail=_4ED47032-99C6-4DB4-80F2-AB922129398F" Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Date: Wed, 26 Jun 2019 19:03:19 +0200 In-Reply-To: References: <83tvcdlm8x.fsf@gnu.org> <8336jwl7sa.fsf@gnu.org> X-Mailer: Apple Mail (2.3445.104.11) X-CTCH-RefID: str=0001.0A0B0204.5D13A55A.0016, 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-Rules: X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=U/y889ju c=1 sm=1 tr=0 a=M+GU/qJco4WXjv8D6jB2IA==:117 a=M+GU/qJco4WXjv8D6jB2IA==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=pGLkceISAAAA:8 a=mDV3o1hIAAAA:8 a=3Y6RloVvkZW40JNhmQ4A:9 a=QEXdDO2ut3YA:10 a=h5Ve0Ubz_8bRSecn0PcA:9 a=B2y7HmGcmWMA:10 a=VDk6hhGL7EvPjjgMrysA:9 a=1OfwrDeanrQA:10 a=_FVE-zBwftR9WsbkzFJk:22 X-Spam-Score: 0.3 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) --Apple-Mail=_4ED47032-99C6-4DB4-80F2-AB922129398F Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 26 juni 2019 kl. 17.59 skrev Cl=C3=A9ment Pit-Claudel = : >=20 >> (1) Does this code, in company-coq--loc-fully-qualified-name, = actually work the way you intended? (Looks like it.) >=20 > Yes, I think it does. It's a bit inscrutable, so here's an annotated = copy: Thanks, so at least it wasn't written blindly from the docs --- good to = know. > This code would probably be clearer if I just used a substring to trim = out the beginning of the string ^^ Well I thought so, but who am I to judge? If it works... >> (2) Did you learn how the START parameter affects the return value by = reading the doc string, the manual, the source code, or by testing? >=20 > Almost certainly the docstring, confirmed by testing. I haven't = looked at this section of the manual.=20 >=20 >> (3) Are you aware of other code using the START parameter to = replace-regexp-in-string? >=20 > Nothing off the top of my head, but I probably wouldn't have thought = of the instance in company-coq either. A quick grep through my local = sources doesn't turn up anything else, but a quick visual check isn't a = very reliable method (did you use a plain grep to find the instance in = company-coq, or do you have a more sophisticated trick?). Definitely not sophisticated, just re-purposed my old regexp trawler = (attached in case you want to try). Cl=C3=A9ment, thank you very much for humouring me. We are in the = unenviable position to decide whether to fix an old, unsatisfactory, = apparently very rarely used interface, or to document the behaviour. The = stakes are low, but it looks like the semantics will be kept after all. 26 juni 2019 kl. 17.17 skrev Eli Zaretskii : >=20 > For the manual, I'd expand a bit on this, and explained how to get the > result you thought you will when using non-nil START (by concatenating > with the initial substring). All right, I added a sentence to that effect. --Apple-Mail=_4ED47032-99C6-4DB4-80F2-AB922129398F 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=2095b5c2f463edfe617f16a238081639ac58f6e7fb=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|=206=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,=20= 6=20insertions(+),=203=20deletions(-)=0A=0Adiff=20--git=20= a/doc/lispref/searching.texi=20b/doc/lispref/searching.texi=0Aindex=20= 33455114da..ef1cffc446=20100644=0A---=20a/doc/lispref/searching.texi=0A= +++=20b/doc/lispref/searching.texi=0A@@=20-1790,8=20+1790,10=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+To=20get=20= the=20whole=20transformed=20string,=20concatenate=20the=20first=0A= +@var{start}=20characters=20of=20@var{string}=20with=20the=20return=20= value.=0A=20=0A=20This=20function=20uses=20@code{replace-match}=20to=20= do=20the=20replacement,=20and=20it=0A=20passes=20the=20optional=20= arguments=20@var{fixedcase},=20@var{literal}=20and=0Adiff=20--git=20= a/lisp/subr.el=20b/lisp/subr.el=0Aindex=20baff1e909a..b981af6afe=20= 100644=0A---=20a/lisp/subr.el=0A+++=20b/lisp/subr.el=0A@@=20-4208,7=20= +4208,8=20@@=20replace-regexp-in-string=0A=20=0A=20Optional=20arguments=20= FIXEDCASE,=20LITERAL=20and=20SUBEXP=20are=20like=20the=0A=20arguments=20= with=20the=20same=20names=20of=20function=20`replace-match'.=20=20If=20= START=0A-is=20non-nil,=20start=20replacements=20at=20that=20index=20in=20= STRING.=0A+is=20non-nil,=20start=20replacements=20at=20that=20index=20in=20= STRING,=20and=20omit=0A+the=20first=20START=20characters=20of=20STRING=20= from=20the=20return=20value.=0A=20=0A=20REP=20is=20either=20a=20string=20= used=20as=20the=20NEWTEXT=20arg=20of=20`replace-match'=20or=20a=0A=20= function.=20=20If=20it=20is=20a=20function,=20it=20is=20called=20with=20= the=20actual=20text=20of=20each=0A--=20=0A2.20.1=20(Apple=20Git-117)=0A=0A= --Apple-Mail=_4ED47032-99C6-4DB4-80F2-AB922129398F Content-Disposition: attachment; filename=trawl.el Content-Type: application/octet-stream; x-unix-mode=0644; name="trawl.el" Content-Transfer-Encoding: quoted-printable ;;;=20trawl.el=20--=20scan=20elisp=20code=20for=20various=20things=20=20=20= -*-=20lexical-binding:=20t=20-*-=0A=0A(require=20'compile)=0A(require=20= 'cl-lib)=0A=0A(defconst=20trawl--error-buffer-name=20"*trawl*")=0A=0A= (defun=20trawl--error-buffer=20()=0A=20=20(let=20((buf=20(get-buffer=20= trawl--error-buffer-name)))=0A=20=20=20=20(or=20buf=0A=20=20=20=20=20=20=20= =20(let=20((buf=20(get-buffer-create=20trawl--error-buffer-name)))=0A=20=20= =20=20=20=20=20=20=20=20(with-current-buffer=20buf=0A=20=20=20=20=20=20=20= =20=20=20=20=20(trawl-mode))=0A=20=20=20=20=20=20=20=20=20=20buf))))=0A=0A= (defvar=20trawl--error-count)=0A=0A(defun=20trawl--add-to-error-buffer=20= (string)=0A=20=20(with-current-buffer=20(trawl--error-buffer)=0A=20=20=20= =20(goto-char=20(point-max))=0A=20=20=20=20(let=20((inhibit-read-only=20= t))=0A=20=20=20=20=20=20(insert=20string))))=0A=0A(defun=20= trawl--line-col-from-pos-path=20(pos=20path)=0A=20=20"Compute=20(LINE=20= .=20COLUMN)=20from=20POS=20(toplevel=20position)=0Aand=20PATH=20= (reversed=20list=20of=20list=20indices=20to=20follow=20to=20target)."=0A=20= =20(save-excursion=0A=20=20=20=20(goto-char=20pos)=0A=20=20=20=20(let=20= ((p=20(reverse=20path)))=0A=20=20=20=20=20=20(while=20p=0A=20=20=20=20=20= =20=20=20(when=20(looking-at=20(rx=20(1+=20(or=20blank=20"\n"=20"\f"=0A=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20(seq=20";"=20(0+=20nonl))))))=0A=20=20= =20=20=20=20=20=20=20=20(goto-char=20(match-end=200)))=0A=20=20=20=20=20=20= =20=20(let=20((skip=20(car=20p)))=0A=20=20=20=20=20=20=20=20=20=20(cond=0A= =20=20=20=20=20=20=20=20=20=20=20((looking-at=20(rx=20(or=20"'"=20"#'"=20= "`"=20","=20",@")))=0A=20=20=20=20=20=20=20=20=20=20=20=20(goto-char=20= (match-end=200))=0A=20=20=20=20=20=20=20=20=20=20=20=20(setq=20skip=20= (1-=20skip)))=0A=20=20=20=20=20=20=20=20=20=20=20((looking-at=20(rx=20= "("))=0A=20=20=20=20=20=20=20=20=20=20=20=20(forward-char=201)))=0A=20=20= =20=20=20=20=20=20=20=20(forward-sexp=20skip)=0A=20=20=20=20=20=20=20=20=20= =20(setq=20p=20(cdr=20p))))=0A=20=20=20=20=20=20(when=20(looking-at=20= (rx=20(1+=20(or=20blank=20"\n"=20"\f"=0A=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (seq=20";"=20(0+=20nonl))))))=0A=20=20=20=20=20=20=20=20(goto-char=20= (match-end=200)))=0A=20=20=20=20=20=20(cons=20(line-number-at-pos=20= (point)=20t)=0A=20=20=20=20=20=20=20=20=20=20=20=20(1+=20= (current-column))))))=0A=0A(defun=20trawl--output-error=20(string)=0A=20=20= (if=20noninteractive=0A=20=20=20=20=20=20(message=20"%s"=20string)=0A=20=20= =20=20(trawl--add-to-error-buffer=20(concat=20string=20"\n"))))=0A=0A= (defun=20trawl--report=20(file=20pos=20path=20message)=0A=20=20(let=20= ((line-col=20(trawl--line-col-from-pos-path=20pos=20path)))=0A=20=20=20=20= (trawl--output-error=0A=20=20=20=20=20(format=20"%s:%d:%d:=20%s"=20file=20= (car=20line-col)=20(cdr=20line-col)=20message)))=0A=20=20(setq=20= trawl--error-count=20(1+=20trawl--error-count)))=0A=0A(defun=20= trawl--quote-string=20(str)=0A=20=20(concat=20"\""=0A=20=20=20=20=20=20=20= =20=20=20(replace-regexp-in-string=0A=20=20=20=20=20=20=20=20=20=20=20= (rx=20(any=20cntrl=20"\177-\377"=20?\\=20?\"))=0A=20=20=20=20=20=20=20=20= =20=20=20(lambda=20(s)=0A=20=20=20=20=20=20=20=20=20=20=20=20=20(let=20= ((c=20(logand=20(string-to-char=20s)=20#xff)))=0A=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20(or=20(cdr=20(assq=20c=0A=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20'((?\"=20= .=20"\\\"")=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20(?\\=20.=20"\\\\")=0A=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20(?\b=20.=20"\\b")=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(?\t=20.=20"\\t")=0A=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20(?\n=20.=20"\\n")=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(?\v=20.=20"\\v")=0A= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20(?\f=20.=20"\\f")=0A=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(?\r=20.=20= "\\r")=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20(?\e=20.=20"\\e"))))=0A=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20(format=20"\\%03o"=20c))))=0A=20=20=20= =20=20=20=20=20=20=20=20str=20t=20t)=0A=20=20=20=20=20=20=20=20=20=20= "\""))=0A=0A(defun=20trawl--caret-string=20(string=20pos)=0A=20=20(let=20= ((quoted-pos=0A=20=20=20=20=20=20=20=20=20(-=20(length=20= (trawl--quote-string=20(substring=20string=200=20pos)))=0A=20=20=20=20=20= =20=20=20=20=20=20=202)))=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20;=20Lop=20off=20quotes=0A=20=20=20=20(concat=20= (make-string=20quoted-pos=20?.)=20"^")))=0A=0A=0A(defconst=20= trawl--report-could-be=20nil)=0A(defconst=20trawl--report-pcase=20nil)=0A= (defconst=20trawl--report-cl-case=20nil)=0A=0A(defun=20= trawl--check-form-recursively=20(form=20file=20pos=20path)=0A=20=20= (pcase=20form=0A=20=20=20=20(`(replace-regexp-in-string=20.=20,_)=0A=20=20= =20=20=20(when=20(>=20(length=20form)=207)=0A=20=20=20=20=20=20=20= (trawl--report=20file=20pos=20path=20"replace-regexp-in-string=20with=20= start")))=0A=0A;;;=20=20=20=20(`(apply=20,(or=20'nconc=20'(quote=20= nconc)=20'(function=20nconc))=20(mapcar=20.=20,_))=0A;;;=20=20=20=20=20= (trawl--report=20file=20pos=20path=0A;;;=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20"use=20mapcan=20instead=20of=20(apply=20nconc=20= (mapcar...))"))=0A;;;=20=20=20=20(`(lambda=20(,var1)=20(,_=20,var2))=0A= ;;;=20=20=20=20=20(when=20(eq=20var1=20var2)=0A;;;=20=20=20=20=20=20=20= (trawl--report=20file=20pos=20path=0A;;;=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20"lambda=20expression=20can=20be=20= =CE=B7-reduced")))=0A;;;=20=20=20=20(`(lambda=20(,var1)=20,var2)=0A;;;=20= =20=20=20=20(when=20(eq=20var1=20var2)=0A;;;=20=20=20=20=20=20=20= (trawl--report=20file=20pos=20path=0A;;;=09=09=20=20=20=20=20=20"lambda=20= expression=20is=20#'identity")))=0A;;;=20=20=20=20(`(,(or=20'defun=20= 'defsubst)=20,name=20,_=20.=20,body)=0A;;;=20=20=20=20=20(let=20((f=20= body))=0A;;;=20=20=20=20=20=20=20(while=20(and=20f=20(consp=20(car=20f))=20= (eq=20(caar=20f)=20'declare))=0A;;;=20=20=20=20=20=20=20=20=20(setq=20f=20= (cdr=20f)))=0A;;;=20=20=20=20=20=20=20(when=20(and=20f=20(consp=20(car=20= f)))=0A;;;=20=20=20=20=20=20=20=20=20(setq=20f=20(cdr=20f))=0A;;;=20=20=20= =20=20=20=20=20=20(while=20(cdr=20f)=0A;;;=20=20=20=20=20=20=20=20=20=20=20= (when=20(stringp=20(car=20f))=0A;;;=20=20=20=20=20=20=20=20=20=20=20=20=20= (trawl--report=20file=20pos=20path=0A;;;=09=09=09=20=20=20=20(format=20= "defun=20%s:=20misplaced=20doc=20string"=20name)))=0A;;;=20=20=20=20=20=20= =20=20=20=20=20(setq=20f=20(cdr=20f))))))=0A=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20)=0A=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20(let=20((index=200))=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20(while=20(consp=20form)=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20(when=20(consp=20(car=20form))=0A=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20(trawl--check-form-recursively=0A= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (car=20form)=20file=20pos=20(cons=20index=20path)))=0A=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20(setq=20form=20(cdr=20form))=0A=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(setq=20index=20= (1+=20index)))))=0A=0A(defun=20trawl--show-errors=20()=0A=20=20(unless=20= noninteractive=0A=20=20=20=20(let=20((pop-up-windows=20t))=0A=20=20=20=20= =20=20(display-buffer=20(trawl--error-buffer))=0A=20=20=20=20=20=20= (sit-for=200))))=0A=0A(defun=20trawl--read-buffer=20(file)=0A=20=20"Read=20= top-level=20forms=20from=20the=20current=20buffer.=0AReturn=20a=20list=20= of=20(FORM=20.=20STARTING-POSITION)."=0A=20=20(goto-char=20(point-min))=0A= =20=20(let=20((pos=20nil)=0A=20=20=20=20=20=20=20=20(keep-going=20t)=0A=20= =20=20=20=20=20=20=20(read-circle=20nil)=0A=20=20=20=20=20=20=20=20= (forms=20nil))=0A=20=20=20=20(while=20keep-going=0A=20=20=20=20=20=20= (setq=20pos=20(point))=0A=20=20=20=20=20=20(let=20((form=20nil))=0A=20=20= =20=20=20=20=20=20(condition-case=20err=0A=20=20=20=20=20=20=20=20=20=20=20= =20(setq=20form=20(read=20(current-buffer)))=0A=20=20=20=20=20=20=20=20=20= =20(end-of-file=0A=20=20=20=20=20=20=20=20=20=20=20(setq=20keep-going=20= nil))=0A=20=20=20=20=20=20=20=20=20=20(invalid-read-syntax=0A=20=20=20=20= =20=20=20=20=20=20=20(cond=0A=20=20=20=20=20=20=20=20=20=20=20=20((equal=20= (cadr=20err)=20"#")=0A=20=20=20=20=20=20=20=20=20=20=20=20=20(goto-char=20= pos)=0A=20=20=20=20=20=20=20=20=20=20=20=20=20(forward-sexp=201))=0A=20=20= =20=20=20=20=20=20=20=20=20=20(t=0A=20=20=20=20=20=20=20=20=20=20=20=20=20= (trawl--report=20file=20(point)=20nil=20(prin1-to-string=20err))=0A=20=20= =20=20=20=20=20=20=20=20=20=20=20(setq=20keep-going=20nil))))=0A=20=20=20= =20=20=20=20=20=20=20(error=0A=20=20=20=20=20=20=20=20=20=20=20= (trawl--report=20file=20(point)=20nil=20(prin1-to-string=20err))=0A=20=20= =20=20=20=20=20=20=20=20=20(setq=20keep-going=20nil)))=0A=20=20=20=20=20=20= =20=20(when=20(consp=20form)=0A=20=20=20=20=20=20=20=20=20=20(push=20= (cons=20form=20pos)=20forms))))=0A=20=20=20=20(nreverse=20forms)))=0A=0A= (defun=20trawl--scan-current-buffer=20(file)=0A=20=20(let=20= ((errors-before=20trawl--error-count))=0A=20=20=20=20(let=20((forms=20= (trawl--read-buffer=20file))=0A=20=20=20=20=20=20=20=20=20=20= (case-fold-search=20nil))=0A=20=20=20=20=20=20(dolist=20(form=20forms)=0A= =20=20=20=20=20=20=20=20(trawl--check-form-recursively=20(car=20form)=20= file=20(cdr=20form)=20nil)))=0A=20=20=20=20(when=20(>=20= trawl--error-count=20errors-before)=0A=20=20=20=20=20=20= (trawl--show-errors))))=0A=0A(defun=20trawl--scan-file=20(file=20= base-dir)=0A=20=20(with-temp-buffer=0A=20=20=20=20(emacs-lisp-mode)=0A=20= =20=20=20(insert-file-contents=20file)=0A=20=20=20=20= (trawl--scan-current-buffer=20(file-relative-name=20file=20base-dir))))=0A= =0A(defvar=20trawl-last-target=20nil=0A=20=20"The=20last=20file,=20= directory=20or=20buffer=20on=20which=20trawl=20was=20run.")=0A=0A(defun=20= trawl--init=20(target=20base-dir)=0A=20=20(if=20noninteractive=0A=20=20=20= =20=20=20(setq=20trawl--error-count=200)=0A=20=20=20=20= (with-current-buffer=20(trawl--error-buffer)=0A=20=20=20=20=20=20(let=20= ((inhibit-read-only=20t))=0A=20=20=20=20=20=20=20=20= (compilation-forget-errors)=0A=20=20=20=20=20=20=20=20(erase-buffer)=0A=20= =20=20=20=20=20=20=20(insert=20(format=20"Trawl=20results=20for=20%s\n"=20= target))=0A=20=20=20=20=20=20=20=20(trawl--show-errors))=0A=20=20=20=20=20= =20(setq=20trawl-last-target=20target)=0A=20=20=20=20=20=20(setq=20= default-directory=20base-dir)=0A=20=20=20=20=20=20(setq=20= trawl--error-count=200))))=0A=0A(defun=20trawl--finish=20()=0A=20=20= (let*=20((errors=20trawl--error-count)=0A=20=20=20=20=20=20=20=20=20(msg=20= (format=20"%d=20error%s"=20errors=20(if=20(=3D=20errors=201)=20""=20= "s"))))=0A=20=20=20=20(unless=20noninteractive=0A=20=20=20=20=20=20= (trawl--add-to-error-buffer=20(format=20"\nFinished=20--=20%s=20= found.\n"=20msg)))=0A=20=20=20=20(message=20"trawl:=20%s=20found."=20= msg)))=0A=0A(defun=20trawl-again=20()=0A=20=20"Re-run=20trawl=20on=20the=20= same=20file,=20directory=20or=20buffer=20as=20last=20time."=0A=20=20= (interactive)=0A=20=20(cond=20((bufferp=20trawl-last-target)=0A=20=20=20=20= =20=20=20=20=20(with-current-buffer=20trawl-last-target=0A=20=20=20=20=20= =20=20=20=20=20=20(trawl-current-buffer)))=0A=20=20=20=20=20=20=20=20= ((file-directory-p=20trawl-last-target)=0A=20=20=20=20=20=20=20=20=20= (trawl-directory=20trawl-last-target))=0A=20=20=20=20=20=20=20=20= ((file-readable-p=20trawl-last-target)=0A=20=20=20=20=20=20=20=20=20= (trawl-file=20trawl-last-target))=0A=20=20=20=20=20=20=20=20(t=20(error=20= "No=20target"))))=0A=0A(defvar=20trawl-mode-map=0A=20=20(let=20((map=20= (make-sparse-keymap)))=0A=20=20=20=20(set-keymap-parent=20map=20= compilation-minor-mode-map)=0A=20=20=20=20(define-key=20map=20"n"=20= 'next-error-no-select)=0A=20=20=20=20(define-key=20map=20"p"=20= 'previous-error-no-select)=0A=20=20=20=20(define-key=20map=20"g"=20= 'trawl-again)=0A=20=20=20=20map)=0A=20=20"Keymap=20for=20trawl=20= buffers.")=0A=0A(define-compilation-mode=20trawl-mode=20"Trawl"=0A=20=20= "Mode=20for=20trawl=20output."=0A=20=20(setq-local=20trawl-last-target=20= nil))=0A=0A(defun=20trawl--scan-files=20(files=20target=20base-dir)=0A=20= =20(trawl--init=20target=20base-dir)=0A=20=20(dolist=20(file=20files)=0A=20= =20=20=20;;(trawl--add-to-error-buffer=20(format=20"Scanning=20%s\n"=20= file))=0A=20=20=20=20(trawl--scan-file=20file=20base-dir))=0A=20=20= (trawl--finish))=0A=0A(defun=20trawl--tree-files=20(dir)=0A=20=20= (directory-files-recursively=0A=20=20=20dir=20(rx=20bos=20(not=20(any=20= "."))=20(*=20anything)=20".el"=20eos)))=0A=0A=0A;;;###autoload=0A(defun=20= trawl-file=20(file)=0A=20=20"Scan=20FILE,=20an=20elisp=20file."=0A=20=20= (interactive=20"fTrawl=20elisp=20file:=20")=0A=20=20(trawl--scan-files=20= (list=20file)=20file=20(file-name-directory=20file)))=0A=0A= ;;;###autoload=0A(defun=20trawl-directory=20(dir)=0A=20=20"Scan=20all=20= *.el=20files=20in=20DIR."=0A=20=20(interactive=20"DTrawl=20directory:=20= ")=0A=20=20(message=20"Finding=20.el=20files=20in=20%s..."=20dir)=0A=20=20= (let=20((files=20(trawl--tree-files=20dir)))=0A=20=20=20=20(message=20= "Scanning=20files...")=0A=20=20=20=20(trawl--scan-files=20files=20dir=20= dir)))=0A=0A;;;###autoload=0A(defun=20trawl-current-buffer=20()=0A=20=20= "Scan=20the=20current=20buffer.=0AThe=20buffer=20must=20be=20in=20= emacs-lisp-mode."=0A=20=20(interactive)=0A=20=20(unless=20(eq=20= major-mode=20'emacs-lisp-mode)=0A=20=20=20=20(error=20"Trawl:=20can=20= only=20scan=20elisp=20code=20(use=20emacs-lisp-mode)"))=0A=20=20= (trawl--init=20(current-buffer)=20default-directory)=0A=20=20= (save-excursion=0A=20=20=20=20(trawl--scan-current-buffer=20= (buffer-name)))=0A=20=20(trawl--finish))=0A=0A=0A(defun=20trawl-batch=20= ()=0A=20=20"Scan=20elisp=20source=20files.=0ACall=20this=20function=20in=20= batch=20mode=20with=20files=20and=20directories=20as=0Acommand-line=20= arguments.=20=20Files=20are=20scanned;=20directories=20are=0Asearched=20= recursively=20for=20*.el=20files=20to=20scan."=0A=20=20(unless=20= noninteractive=0A=20=20=20=20(error=20"`trawl-batch'=20is=20only=20for=20= use=20with=20-batch"))=0A=20=20(trawl--scan-files=20(mapcan=20(lambda=20= (arg)=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20(if=20(file-directory-p=20arg)=0A=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20(trawl--tree-files=20arg)=0A=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (list=20arg)))=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20command-line-args-left)=0A=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20nil=20default-directory)=0A=20= =20(setq=20command-line-args-left=20nil))=0A=0A(provide=20'trawl)=0A=0A= ;;;=20trawl.el=20ends=20here=0A= --Apple-Mail=_4ED47032-99C6-4DB4-80F2-AB922129398F-- From unknown Sat Jun 21 12:28:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#36372: 27.0.50; replace-regexp-in-string skips START first chars in return value [PATCH] Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 26 Jun 2019 17:10:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36372 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Cc: cpitclaudel@gmail.com, larsi@gnus.org, 36372@debbugs.gnu.org Received: via spool by 36372-submit@debbugs.gnu.org id=B36372.156156898112376 (code B ref 36372); Wed, 26 Jun 2019 17:10:02 +0000 Received: (at 36372) by debbugs.gnu.org; 26 Jun 2019 17:09:41 +0000 Received: from localhost ([127.0.0.1]:36971 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hgBQT-0003DY-7w for submit@debbugs.gnu.org; Wed, 26 Jun 2019 13:09:41 -0400 Received: from eggs.gnu.org ([209.51.188.92]:39573) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hgBQR-0003DC-7V for 36372@debbugs.gnu.org; Wed, 26 Jun 2019 13:09:39 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:55956) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hgBQL-0000BD-VN; Wed, 26 Jun 2019 13:09:34 -0400 Received: from [176.228.60.248] (port=2048 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1hgBQK-0007Nu-RD; Wed, 26 Jun 2019 13:09:33 -0400 Date: Wed, 26 Jun 2019 20:09:16 +0300 Message-Id: <83ef3gjmtf.fsf@gnu.org> From: Eli Zaretskii In-reply-to: <4BBC2AEF-642C-40C8-9E28-570C4BA21F18@acm.org> (message from Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= on Wed, 26 Jun 2019 19:03:19 +0200) References: <83tvcdlm8x.fsf@gnu.org> <8336jwl7sa.fsf@gnu.org> <4BBC2AEF-642C-40C8-9E28-570C4BA21F18@acm.org> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Mattias Engdegård > Date: Wed, 26 Jun 2019 19:03:19 +0200 > Cc: Eli Zaretskii , Lars Ingebrigtsen , > 36372@debbugs.gnu.org > > For the manual, I'd expand a bit on this, and explained how to get the > > result you thought you will when using non-nil START (by concatenating > > with the initial substring). > > All right, I added a sentence to that effect. LGTM, thanks. From unknown Sat Jun 21 12:28:46 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Subject: bug#36372: closed (Re: bug#36372: 27.0.50; replace-regexp-in-string skips START first chars in return value [PATCH]) Message-ID: References: X-Gnu-PR-Message: they-closed 36372 X-Gnu-PR-Package: emacs Reply-To: 36372@debbugs.gnu.org Date: Wed, 26 Jun 2019 17:42:04 +0000 Content-Type: multipart/mixed; boundary="----------=_1561570924-15791-1" This is a multi-part message in MIME format... ------------=_1561570924-15791-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 36372@debbugs.gnu.org. --=20 36372: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D36372 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1561570924-15791-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 36372-done) by debbugs.gnu.org; 26 Jun 2019 17:41:21 +0000 Received: from localhost ([127.0.0.1]:37009 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hgBv7-00045c-47 for submit@debbugs.gnu.org; Wed, 26 Jun 2019 13:41:21 -0400 Received: from mail205c50.megamailservers.eu ([91.136.10.215]:34082 helo=mail193c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hgBv5-00045T-7a for 36372-done@debbugs.gnu.org; Wed, 26 Jun 2019 13:41:20 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1561570877; bh=b/tjTY4xnZybSbif8wvuNuQnNto+0DQ3eHE+08uIPjE=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=SrlE6t2koIrrNyczbyYfzB5OLZDiJdpyOF7dj7o5HPEa4vrCL/A5wcr0BKHGHgSTv i92aifqUl8wY0leaY/hzNN/oP2RQDPB0kTZ+I7R2327K+JGKa4cVXD8VVyw4rKEvbo 46bTG+nXZDiqxx9HS2DN+oO+wcg53jFlW0tlsGj0= Feedback-ID: mattiase@acm.or Received: from [192.168.1.65] (c-e636e253.032-75-73746f71.bbcust.telenor.se [83.226.54.230]) (authenticated bits=0) by mail193c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id x5QHfFIg004294; Wed, 26 Jun 2019 17:41:16 +0000 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Subject: Re: bug#36372: 27.0.50; replace-regexp-in-string skips START first chars in return value [PATCH] From: =?utf-8?Q?Mattias_Engdeg=C3=A5rd?= In-Reply-To: <83ef3gjmtf.fsf@gnu.org> Date: Wed, 26 Jun 2019 19:41:14 +0200 Content-Transfer-Encoding: 7bit Message-Id: References: <83tvcdlm8x.fsf@gnu.org> <8336jwl7sa.fsf@gnu.org> <4BBC2AEF-642C-40C8-9E28-570C4BA21F18@acm.org> <83ef3gjmtf.fsf@gnu.org> To: Eli Zaretskii X-Mailer: Apple Mail (2.3445.104.11) X-CTCH-RefID: str=0001.0A0B020E.5D13AE3D.002B, 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-Rules: X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=KsZjJ1eN c=1 sm=1 tr=0 a=M+GU/qJco4WXjv8D6jB2IA==:117 a=M+GU/qJco4WXjv8D6jB2IA==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=kj9zAlcOel0A:10 a=mDV3o1hIAAAA:8 a=5w_1TVFW9u-S_BbfzVwA:9 a=CjuIK1q_8ugA:10 a=ncZ9vwaUYPMA:10 a=_FVE-zBwftR9WsbkzFJk:22 X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 36372-done Cc: =?utf-8?Q?Cl=C3=A9ment_Pit-Claudel?= , Lars Ingebrigtsen , 36372-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) 26 juni 2019 kl. 19.09 skrev Eli Zaretskii : > > LGTM, thanks. That's it then. Thanks for the review; pushed. ------------=_1561570924-15791-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 25 Jun 2019 12:40:20 +0000 Received: from localhost ([127.0.0.1]:58876 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hfkkG-0007eM-CP for submit@debbugs.gnu.org; Tue, 25 Jun 2019 08:40:20 -0400 Received: from lists.gnu.org ([209.51.188.17]:48624) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hfkkD-0007eE-PB for submit@debbugs.gnu.org; Tue, 25 Jun 2019 08:40:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44062) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hfkkB-0007mx-N5 for bug-gnu-emacs@gnu.org; Tue, 25 Jun 2019 08:40:17 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,URIBL_BLOCKED autolearn=disabled version=3.3.2 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hfkkA-0002o4-IH for bug-gnu-emacs@gnu.org; Tue, 25 Jun 2019 08:40:15 -0400 Received: from mail1430c50.megamailservers.eu ([91.136.14.30]:48288 helo=mail118c50.megamailservers.eu) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hfkk9-0002lR-Vo for bug-gnu-emacs@gnu.org; Tue, 25 Jun 2019 08:40:14 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1561464111; bh=1mgz+NPMyEylJgMIPFIvhUxCM0EzDgPa7ocsXOsDsPM=; h=From:Subject:Date:To:From; b=p8qMtXg44sOiS+Paobd/LSTu8PFKkCb4AoKcFu6xsTDL0npHLj6cQlQ0N0LUP70/u DjVRkisncKntFRaJ2KPF7rQc/ME+CGUxJKx2tQ055I4geZfA6tBr83NQcWPfkRyozl 83VJdRtQ3u8N744BlT59/H2SzmRw6vdEUgM4VBFc= Feedback-ID: mattiase@acm.or Received: from [192.168.0.4] ([188.150.171.71]) (authenticated bits=0) by mail118c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id x5PC1oiI009710 for ; Tue, 25 Jun 2019 12:01:51 +0000 From: =?utf-8?Q?Mattias_Engdeg=C3=A5rd?= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Subject: 27.0.50; replace-regexp-in-string skips START first chars in return value Message-Id: Date: Tue, 25 Jun 2019 14:01:49 +0200 To: bug-gnu-emacs@gnu.org X-Mailer: Apple Mail (2.3445.104.11) X-CTCH-RefID: str=0001.0A0B0201.5D120D2F.0060, 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-Rules: X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=JLcVTfCb c=1 sm=1 tr=0 a=SF+I6pRkHZhrawxbOkkvaA==:117 a=SF+I6pRkHZhrawxbOkkvaA==:17 a=IkcTkHD0fZMA:10 a=M6lMmiwvbBaVFJyVF6wA:9 a=QEXdDO2ut3YA:10 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] X-Received-From: 91.136.14.30 X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) =46rom 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-=E2=80=98nil=E2=80=99, 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)) =3D> "abcXb" Bug#15107 is somewhat related. ------------=_1561570924-15791-1--