GNU bug report logs - #81970
peg.el: "if" construct moves point

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Jeff Trull <edaskel@HIDDEN>; dated Thu, 1 Oct 2026 20:17:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 81970 <at> debbugs.gnu.org:


Received: (at 81970) by debbugs.gnu.org; 12 Oct 2026 06:02:48 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Oct 12 02:02:48 2026
Received: from localhost ([127.0.0.1]:59261 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1xG97X-0002E9-PH
	for submit <at> debbugs.gnu.org; Mon, 12 Oct 2026 02:02:48 -0400
Received: from sonic306-23.consmr.mail.ne1.yahoo.com ([66.163.189.85]:36658)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <edaskel@HIDDEN>) id 1xG97T-0002DK-Mc
 for 81970 <at> debbugs.gnu.org; Mon, 12 Oct 2026 02:02:45 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=att.net; s=s1024;
 t=1791784956; bh=c5iZPPEMoadyUAlXmzG8iZAn2UZGwtwWL98E+cFerJQ=;
 h=Date:From:To:Cc:In-Reply-To:References:Subject:From:Subject:Reply-To;
 b=f1p79h8jBJkgZmyYXjtwAwH7YGmNzOwJTFCpIYkwkP3g5zehSpqoC75CFo0gMbNsuHR6EfgGhTpqp0oe8rlxiqc66S+w2+8y3DlLR4ERcNNwdkp3FxkMUeK98ggB1+5V/EGQFt5L1I5ttiaOtHua806o8E0fFtXbOCx/jU/d1Lg=
X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048;
 t=1791784956; bh=stLMuYw/kthFhHzDavvIvDvQMmM75+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q6QcTdyVFURu2zfz6Qxm7w.CCLcdCfrMSLE_3DL4guKv.
 xGYAaf9eFttJyInny7wP51I7bdNEY4jotTzr1C120Lk2IqYKomTSnHFu1Qf3Z2GXp8f.5rJANdX7
 Yeb1niD_1mV24NgxZadV7FmELzvvH0fxSQZZMwHTZOT0bJ_40o645jPRYWD_mCANxGyVnZZz4GBA
 K6fi.CRG512lgrEgNibtYX2dPB3zlXtdaWSxnYQTpm0g6iSat.L4faaslYd_yTn7cfkgzLr3iz6P
 klHpX5NPsJb9ASXM9.XfWAnux45TWEmpdvUGgBGShtrPORfaKiw3VhvGH_hELyeymsSHseDKay8u
 q9JDwIBvYuEmR7p1gPM5W9LC.HeDkrdwCmRItMSInTQy1.rMp75AtPsCZtJhQR.3u7MNSD2v1cYG
 P2i8IHNVclWTqBd19Ztr6ru5AVIzUh_F5YdjnmI.tXPQv0PtWa4mm81ar5jo_qTStmqhX7LqD9cq
 qvmNFWNATy_5V7o93fnLg_S85Hmr6ZY_VB45drIe5X7hEC3q_EyxKcSD.IvUBP_eN8xrHk7yfmZV
 SX2fTEvUoJ_5Zq1TPcojuuUYELMGPUrS8czoGHvFMoAq9GkuFHkJvXgzyV9wiVUH.I9Sv.gd6qg-
 -
X-Sonic-MF: <edaskel@HIDDEN>
X-Sonic-ID: 7e6050f0-2cd9-45b2-9b4f-e09c8d14a2ca
Received: from sonic.gate.mail.ne1.yahoo.com by
 sonic306.consmr.mail.ne1.yahoo.com with HTTP; Mon, 12 Oct 2026 06:02:36 +0000
Date: Mon, 12 Oct 2026 06:01:54 +0000 (UTC)
From: Jeff Trull <edaskel@HIDDEN>
To: Stefan Monnier <monnier@HIDDEN>
Message-ID: <60095290.2294282.1791784914561@HIDDEN>
In-Reply-To: <jwvtsmtd2iz.fsf-monnier+emacs@HIDDEN>
References: <CAF_DUeFtCcdvkNP_R9NOzzBpAcpxOgkVsxyEApn9DJmjxDoy7A.ref@HIDDEN>
 <CAF_DUeFtCcdvkNP_R9NOzzBpAcpxOgkVsxyEApn9DJmjxDoy7A@HIDDEN>
 <jwvik3gf9b8.fsf-monnier+emacs@HIDDEN>
 <1148247025.642123.1791230562417@HIDDEN>
 <jwvik3feuj9.fsf-monnier+emacs@HIDDEN>
 <400612322.697142.1791241954903@HIDDEN>
 <jwvld8bk09e.fsf-monnier+emacs@HIDDEN>
 <630576132.930893.1791304998806@HIDDEN>
 <jwvpkxl2wwr.fsf-monnier+emacs@HIDDEN>
 <1424475815.1803501.1791590594952@HIDDEN>
 <jwvld86be21.fsf-monnier+emacs@HIDDEN>
 <287350150.1991225.1791594196220@HIDDEN>
 <jwvtsmtd2iz.fsf-monnier+emacs@HIDDEN>
Subject: Re: bug#81970: peg.el: "if" construct moves point
MIME-Version: 1.0
Content-Type: multipart/alternative; 
 boundary="----=_Part_2294281_506474041.1791784914559"
X-Mailer: WebService/1.1.26668 YMailNorrin
Content-Length: 10410
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 81970
Cc: "81970 <at> debbugs.gnu.org" <81970 <at> debbugs.gnu.org>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

------=_Part_2294281_506474041.1791784914559
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

 > Thanks, Jeff.=C2=A0 Now comes the harder part: how to change the docs to=
 make
> it more clear.=C2=A0 I feel like talking about the behavior of `peg-run` =
in
> the documentation of `if` would be too weird, so I suggest the
> patch below.

> Would it have helped you?
Yes! Thank you. And if I may make a drive-by suggestion for the manual whil=
eyou're in there, I think that this (37):
(with-peg-rules number-grammar
=C2=A0 (peg-run (peg number)))

was probably meant to be:

(with-peg-rules (number-grammar)
=C2=A0 (peg-run (peg number)))

i.e., the with-peg-rules argument should be a list.

Jeff


    On Saturday, October 10, 2026 at 08:23:22 AM PDT, Stefan Monnier <monni=
er@HIDDEN> wrote: =20
=20
 >>So, IIUC, your confusion is in the difference between the point-motion
>>of primitives like `if` during the parse and how that (fails to)
>>relate(s) to the overall point-motion of `peg-run`?
> That sounds like a fair description. I thought that `if` and `not` someho=
w
> exempted the userfrom *all* point movement, including that in peg-run's
> error handling. I still feel like themanual suggests that.

Thanks, Jeff.=C2=A0 Now comes the harder part: how to change the docs to ma=
ke
it more clear.=C2=A0 I feel like talking about the behavior of `peg-run` in
the documentation of `if` would be too weird, so I suggest the
patch below.

Would it have helped you?


=3D=3D=3D Stefan


diff --git a/doc/lispref/peg.texi b/doc/lispref/peg.texi
index 0c851f15ade..b6b44eeda90 100644
--- a/doc/lispref/peg.texi
+++ b/doc/lispref/peg.texi
@@ -81,10 +81,15 @@ Parsing Expression Grammars
 succeeded or not.=C2=A0 If @var{success-function} is provided, it should b=
e a
 function that receives as its only argument an anonymous function that
 runs all the actions collected on the stack during parsing.=C2=A0 By defau=
lt
-this anonymous function is simply executed.=C2=A0 If parsing fails, a
-function provided as @var{failure-function} will be called with a list
-of @acronym{PEG} expressions that failed during parsing.=C2=A0 By default
-this list is discarded.
+this anonymous function is simply executed, with point where
+@var{peg-matcher} left it.
+
+If parsing fails, on the other hand, regardless where @var{peg-matcher}
+left point, point is moved to the furthest position the parser managed
+to reach, which is often a good guess of the ``error location''.
+Then the function provided as @var{failure-function} is called with
+a list of @acronym{PEG} expressions that failed during parsing.
+By default this list is discarded.
 @end defun
=20
 The @var{peg-matcher} passed to @code{peg-run} is produced by a call to
diff --git a/lisp/progmodes/peg.el b/lisp/progmodes/peg.el
index 73029d7a223..787053cc7fb 100644
--- a/lisp/progmodes/peg.el
+++ b/lisp/progmodes/peg.el
@@ -352,8 +352,9 @@ peg
=20
 (defun peg-run (peg-matcher &optional failure-function success-function)
=C2=A0 "Parse with PEG-MATCHER at point and run the success/failure functio=
n.
-If a match was found, move to the end of the match and call SUCCESS-FUNCTI=
ON
-with one argument: a function which will perform all the actions collected
+If a match was found, run SUCCESS-FUNCTION with point where PEG-MATCHER
+left it (usually, the end of the parse), calling it with one argument,
+a function which will perform all the actions collected
 during the parse and then return the resulting stack (or t if empty).
 If no match was found, move to the (rightmost) point of parse failure and =
call
 FAILURE-FUNCTION with one argument, which is a list of PEG expressions tha=
t

 =20
------=_Part_2294281_506474041.1791784914559
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<html><head></head><body><div class=3D"ydped5b292fyahoo-style-wrap" style=
=3D"font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:13px=
;"><div></div>
        <div dir=3D"ltr" data-setdir=3D"false"><div><div dir=3D"ltr">&gt; T=
hanks, Jeff.&nbsp; Now comes the harder part: how to change the docs to mak=
e<br></div><div dir=3D"ltr">&gt; it more clear.&nbsp; I feel like talking a=
bout the behavior of `peg-run` in<br></div><div dir=3D"ltr">&gt; the docume=
ntation of `if` would be too weird, so I suggest the<br></div><div dir=3D"l=
tr">&gt; patch below.<br></div><div dir=3D"ltr"><br></div><div dir=3D"ltr">=
&gt; Would it have helped you?</div></div><br></div><div dir=3D"ltr" data-s=
etdir=3D"false">Yes! Thank you. And if I may make a drive-by suggestion for=
 the manual while</div><div dir=3D"ltr" data-setdir=3D"false">you're in the=
re, I think that this (37):</div><div dir=3D"ltr" data-setdir=3D"false"><br=
></div><div dir=3D"ltr" data-setdir=3D"false"><div dir=3D"ltr" data-setdir=
=3D"false">(with-peg-rules number-grammar<br>&nbsp; (peg-run (peg number)))=
<br><br>was probably meant to be:<br><br>(with-peg-rules (number-grammar)<b=
r>&nbsp; (peg-run (peg number)))<br><br>i.e., the with-peg-rules argument s=
hould be a list.<br><br></div>Jeff</div><div dir=3D"ltr" data-setdir=3D"fal=
se"><br></div><div dir=3D"ltr" data-setdir=3D"false"><br></div><div><br></d=
iv>
       =20
        </div><div id=3D"ydpfc08201byahoo_quoted_2329594084" class=3D"ydpfc=
08201byahoo_quoted">
            <div style=3D"font-family:'Helvetica Neue', Helvetica, Arial, s=
ans-serif;font-size:13px;color:#26282a;">
               =20
                <div>
                        On Saturday, October 10, 2026 at 08:23:22 AM PDT, S=
tefan Monnier &lt;monnier@HIDDEN&gt; wrote:
                    </div>
                    <div><br></div>
                    <div><br></div>
               =20
               =20
                <div><div dir=3D"ltr">&gt;&gt;So, IIUC, your confusion is i=
n the difference between the point-motion<br></div><div dir=3D"ltr">&gt;&gt=
;of primitives like `if` during the parse and how that (fails to)<br></div>=
<div dir=3D"ltr">&gt;&gt;relate(s) to the overall point-motion of `peg-run`=
?<br></div><div dir=3D"ltr">&gt; That sounds like a fair description. I tho=
ught that `if` and `not` somehow<br></div><div dir=3D"ltr">&gt; exempted th=
e userfrom *all* point movement, including that in peg-run's<br></div><div =
dir=3D"ltr">&gt; error handling. I still feel like themanual suggests that.=
<br></div><div dir=3D"ltr"><br></div><div dir=3D"ltr">Thanks, Jeff.&nbsp; N=
ow comes the harder part: how to change the docs to make<br></div><div dir=
=3D"ltr">it more clear.&nbsp; I feel like talking about the behavior of `pe=
g-run` in<br></div><div dir=3D"ltr">the documentation of `if` would be too =
weird, so I suggest the<br></div><div dir=3D"ltr">patch below.<br></div><di=
v dir=3D"ltr"><br></div><div dir=3D"ltr">Would it have helped you?<br></div=
><div dir=3D"ltr"><br></div><div dir=3D"ltr"><br></div><div dir=3D"ltr">=3D=
=3D=3D Stefan<br></div><div dir=3D"ltr"><br></div><div dir=3D"ltr"><br></di=
v><div dir=3D"ltr">diff --git a/doc/lispref/peg.texi b/doc/lispref/peg.texi=
<br></div><div dir=3D"ltr">index 0c851f15ade..b6b44eeda90 100644<br></div><=
div dir=3D"ltr">--- a/doc/lispref/peg.texi<br></div><div dir=3D"ltr">+++ b/=
doc/lispref/peg.texi<br></div><div dir=3D"ltr">@@ -81,10 +81,15 @@ Parsing =
Expression Grammars<br></div><div dir=3D"ltr"> succeeded or not.&nbsp; If @=
var{success-function} is provided, it should be a<br></div><div dir=3D"ltr"=
> function that receives as its only argument an anonymous function that<br=
></div><div dir=3D"ltr"> runs all the actions collected on the stack during=
 parsing.&nbsp; By default<br></div><div dir=3D"ltr">-this anonymous functi=
on is simply executed.&nbsp; If parsing fails, a<br></div><div dir=3D"ltr">=
-function provided as @var{failure-function} will be called with a list<br>=
</div><div dir=3D"ltr">-of @acronym{PEG} expressions that failed during par=
sing.&nbsp; By default<br></div><div dir=3D"ltr">-this list is discarded.<b=
r></div><div dir=3D"ltr">+this anonymous function is simply executed, with =
point where<br></div><div dir=3D"ltr">+@var{peg-matcher} left it.<br></div>=
<div dir=3D"ltr">+<br></div><div dir=3D"ltr">+If parsing fails, on the othe=
r hand, regardless where @var{peg-matcher}<br></div><div dir=3D"ltr">+left =
point, point is moved to the furthest position the parser managed<br></div>=
<div dir=3D"ltr">+to reach, which is often a good guess of the ``error loca=
tion''.<br></div><div dir=3D"ltr">+Then the function provided as @var{failu=
re-function} is called with<br></div><div dir=3D"ltr">+a list of @acronym{P=
EG} expressions that failed during parsing.<br></div><div dir=3D"ltr">+By d=
efault this list is discarded.<br></div><div dir=3D"ltr"> @end defun<br></d=
iv><div dir=3D"ltr"> <br></div><div dir=3D"ltr"> The @var{peg-matcher} pass=
ed to @code{peg-run} is produced by a call to<br></div><div dir=3D"ltr">dif=
f --git a/lisp/progmodes/peg.el b/lisp/progmodes/peg.el<br></div><div dir=
=3D"ltr">index 73029d7a223..787053cc7fb 100644<br></div><div dir=3D"ltr">--=
- a/lisp/progmodes/peg.el<br></div><div dir=3D"ltr">+++ b/lisp/progmodes/pe=
g.el<br></div><div dir=3D"ltr">@@ -352,8 +352,9 @@ peg<br></div><div dir=3D=
"ltr"> <br></div><div dir=3D"ltr"> (defun peg-run (peg-matcher &amp;optiona=
l failure-function success-function)<br></div><div dir=3D"ltr">&nbsp;  "Par=
se with PEG-MATCHER at point and run the success/failure function.<br></div=
><div dir=3D"ltr">-If a match was found, move to the end of the match and c=
all SUCCESS-FUNCTION<br></div><div dir=3D"ltr">-with one argument: a functi=
on which will perform all the actions collected<br></div><div dir=3D"ltr">+=
If a match was found, run SUCCESS-FUNCTION with point where PEG-MATCHER<br>=
</div><div dir=3D"ltr">+left it (usually, the end of the parse), calling it=
 with one argument,<br></div><div dir=3D"ltr">+a function which will perfor=
m all the actions collected<br></div><div dir=3D"ltr"> during the parse and=
 then return the resulting stack (or t if empty).<br></div><div dir=3D"ltr"=
> If no match was found, move to the (rightmost) point of parse failure and=
 call<br></div><div dir=3D"ltr"> FAILURE-FUNCTION with one argument, which =
is a list of PEG expressions that<br></div><div dir=3D"ltr"><br></div></div=
>
            </div>
        </div></body></html>
------=_Part_2294281_506474041.1791784914559--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#81970; Package emacs. Full text available.

Message received at 81970 <at> debbugs.gnu.org:


Received: (at 81970) by debbugs.gnu.org; 10 Oct 2026 15:23:31 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Oct 10 11:23:31 2026
Received: from localhost ([127.0.0.1]:45547 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1xFYv4-0007Tl-4P
	for submit <at> debbugs.gnu.org; Sat, 10 Oct 2026 11:23:31 -0400
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:51509)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <monnier@HIDDEN>)
 id 1xFYv1-0007Sw-K4
 for 81970 <at> debbugs.gnu.org; Sat, 10 Oct 2026 11:23:28 -0400
Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1])
 by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id B2A3E4408A0;
 Sat, 10 Oct 2026 11:23:21 -0400 (EDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1791645800;
 bh=j+RmLmJKIEziTsV24NZewCYAe2mWHdUr9zdYX4DeNUo=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=MiHb7uMIbKsM6TCJCycJoQkqF7h/8jmfk5cbfgfU9dpL50NHux2Wtx9aMc++wGRmq
 HVgH+ilv9H58gd9vQcmxRAy9Zzz7+NrFRUchfcHcxGQwoWzZF3n3IfxzQWU29N9L4z
 /RqGAs/EbCYituNVYOJg+UMAbeogwaZTrhWt0iyIaeaTk6/MHb6pkRfOj8ilpqlqkf
 viXWjkOdfZzhC7BrYjeYmz9cxHEdGeHXK4kSPC6Kg0qXt1kMOpF8VuQp6xRJXC49of
 UdYtejf+RR7iPDfEvVyhWtWEQj+fnBlU0Xkf9EXJPHO6+kb1q9TiSv5pXSg/GI6X/p
 X9x8X6p560Hcg==
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 498434405D2;
 Sat, 10 Oct 2026 11:23:20 -0400 (EDT)
Received: from pastel (104-195-232-75.cpe.teksavvy.com [104.195.232.75])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 1886B120352;
 Sat, 10 Oct 2026 11:23:20 -0400 (EDT)
From: Stefan Monnier <monnier@HIDDEN>
To: Jeff Trull <edaskel@HIDDEN>
Subject: Re: bug#81970: peg.el: "if" construct moves point
In-Reply-To: <287350150.1991225.1791594196220@HIDDEN>
Message-ID: <jwvtsmtd2iz.fsf-monnier+emacs@HIDDEN>
References: <CAF_DUeFtCcdvkNP_R9NOzzBpAcpxOgkVsxyEApn9DJmjxDoy7A.ref@HIDDEN>
 <CAF_DUeFtCcdvkNP_R9NOzzBpAcpxOgkVsxyEApn9DJmjxDoy7A@HIDDEN>
 <jwvik3gf9b8.fsf-monnier+emacs@HIDDEN>
 <1148247025.642123.1791230562417@HIDDEN>
 <jwvik3feuj9.fsf-monnier+emacs@HIDDEN>
 <400612322.697142.1791241954903@HIDDEN>
 <jwvld8bk09e.fsf-monnier+emacs@HIDDEN>
 <630576132.930893.1791304998806@HIDDEN>
 <jwvpkxl2wwr.fsf-monnier+emacs@HIDDEN>
 <1424475815.1803501.1791590594952@HIDDEN>
 <jwvld86be21.fsf-monnier+emacs@HIDDEN>
 <287350150.1991225.1791594196220@HIDDEN>
Date: Sat, 10 Oct 2026 11:23:11 -0400
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-SPAM-INFO: Spam detection results:  0
 ALL_TRUSTED                -1 Passed through trusted hosts only via SMTP
 AWL 0.151 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DKIM_SIGNED               0.1 Message has a DKIM or DK signature,
 not necessarily valid
 DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
 DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
 domain
 DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from
 domain
X-SPAM-LEVEL: 
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 81970
Cc: "81970 <at> debbugs.gnu.org" <81970 <at> debbugs.gnu.org>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

>>So, IIUC, your confusion is in the difference between the point-motion
>>of primitives like `if` during the parse and how that (fails to)
>>relate(s) to the overall point-motion of `peg-run`?
> That sounds like a fair description. I thought that `if` and `not` somehow
> exempted the userfrom *all* point movement, including that in peg-run's
> error handling. I still feel like themanual suggests that.

Thanks, Jeff.  Now comes the harder part: how to change the docs to make
it more clear.  I feel like talking about the behavior of `peg-run` in
the documentation of `if` would be too weird, so I suggest the
patch below.

Would it have helped you?


=== Stefan


diff --git a/doc/lispref/peg.texi b/doc/lispref/peg.texi
index 0c851f15ade..b6b44eeda90 100644
--- a/doc/lispref/peg.texi
+++ b/doc/lispref/peg.texi
@@ -81,10 +81,15 @@ Parsing Expression Grammars
 succeeded or not.  If @var{success-function} is provided, it should be a
 function that receives as its only argument an anonymous function that
 runs all the actions collected on the stack during parsing.  By default
-this anonymous function is simply executed.  If parsing fails, a
-function provided as @var{failure-function} will be called with a list
-of @acronym{PEG} expressions that failed during parsing.  By default
-this list is discarded.
+this anonymous function is simply executed, with point where
+@var{peg-matcher} left it.
+
+If parsing fails, on the other hand, regardless where @var{peg-matcher}
+left point, point is moved to the furthest position the parser managed
+to reach, which is often a good guess of the ``error location''.
+Then the function provided as @var{failure-function} is called with
+a list of @acronym{PEG} expressions that failed during parsing.
+By default this list is discarded.
 @end defun
 
 The @var{peg-matcher} passed to @code{peg-run} is produced by a call to
diff --git a/lisp/progmodes/peg.el b/lisp/progmodes/peg.el
index 73029d7a223..787053cc7fb 100644
--- a/lisp/progmodes/peg.el
+++ b/lisp/progmodes/peg.el
@@ -352,8 +352,9 @@ peg
 
 (defun peg-run (peg-matcher &optional failure-function success-function)
   "Parse with PEG-MATCHER at point and run the success/failure function.
-If a match was found, move to the end of the match and call SUCCESS-FUNCTION
-with one argument: a function which will perform all the actions collected
+If a match was found, run SUCCESS-FUNCTION with point where PEG-MATCHER
+left it (usually, the end of the parse), calling it with one argument,
+a function which will perform all the actions collected
 during the parse and then return the resulting stack (or t if empty).
 If no match was found, move to the (rightmost) point of parse failure and call
 FAILURE-FUNCTION with one argument, which is a list of PEG expressions that





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#81970; Package emacs. Full text available.

Message received at 81970 <at> debbugs.gnu.org:


Received: (at 81970) by debbugs.gnu.org; 10 Oct 2026 01:03:45 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Oct 09 21:03:45 2026
Received: from localhost ([127.0.0.1]:57232 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1xFLV2-0005q8-Ie
	for submit <at> debbugs.gnu.org; Fri, 09 Oct 2026 21:03:45 -0400
Received: from sonic302-23.consmr.mail.ne1.yahoo.com ([66.163.186.149]:36756)
 by debbugs.gnu.org with esmtps
 (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2)
 (envelope-from <edaskel@HIDDEN>) id 1xFLUz-0005pO-OD
 for 81970 <at> debbugs.gnu.org; Fri, 09 Oct 2026 21:03:42 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=att.net; s=s1024;
 t=1791594214; bh=0nyPslqOnVV8OZG+1Du/KNQ1kW1QpPQBY9JANX34NEQ=;
 h=Date:From:To:Cc:In-Reply-To:References:Subject:From:Subject:Reply-To;
 b=g8LVcjQDz3TD5roGLx1L8Bto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O.Jx8jakqzuSQ95L.ihAuqmUe5OOjcHMFl01DtZ4NVBvh
 I_0DzpKjIx.9FtmwN2KhLJKUuq0XP72qvOCR.KRoGG0R9sYV7ubQlmmwERNYhyKtcAZ15TPEIcxj
 vlPsVCsl.w7wNb8r6JMp_u6jtBr8gSpmMgMXmAM3b6b4BNwrch.uzHQgqqEaDY5AR2r8lzbbZvMg
 e03Y5jU3xErNas4X0cTv37ME4.8Ep._80RB792aeo12465iYO6QqgZOAumR8ofk__r568yjNrvHR
 S9TaLasoV_aaLXdXAzZZ31uE_n3xumaMGLxV7wJYfakMHavZ..CG1lJVo5McQ8aJ_yM66lLg0co1
 B37BpeMzG.B23dNAZ6UH6gn9NKvayJASWQsc.r._yQ3XsVDq6KqBp0yAUh_PLxwlquW5kh7z4tsi
 Utdv3kz.MxvBh91JBu.ZZfGwWHUbGOLvnM81GGBHFS1Bsp_Pbl4ZWEhxERzS0XjT8IImrIgX5iqC
 tUR5MCe4Jn3jHqtdwsOMEd2cET_BphuuyCK4seU3pChWCDBo.RanW5mWk_t25XamHrBhRHuP2LoX
 .bQyyKzCrdGM_wsxKa3tJ.kqmynxWXBYGX23YkFVko_WzxFIbbObk0grChon4cZBDn6iGUHBBLAg
 7r4cl_NJwZQse90FJ18bxQwEy0enuHmgRTdpg_yjB1GznEGCqanUs_COWQgUFKzpDGTASOk5Tujc
 8RqrEX6j9cqNSFavjEGtTFwTr5rc5HxUJ2cDvZ11BAPEUembT.F3oN5DRJedFFtwNTPOHdIAy6V5
 5KZLyzPe1kb2Mg_F97yifS2XM68Wu3yjixMtCPBJdaOsIGUfMGn.ArQxgALFY0MIxM8YYfbUr2kk
 -
X-Sonic-MF: <edaskel@HIDDEN>
X-Sonic-ID: 2a362782-e9a6-4539-a57c-7153dff0eb0d
Received: from sonic.gate.mail.ne1.yahoo.com by
 sonic302.consmr.mail.ne1.yahoo.com with HTTP; Sat, 10 Oct 2026 01:03:34 +0000
Date: Sat, 10 Oct 2026 01:03:16 +0000 (UTC)
From: Jeff Trull <edaskel@HIDDEN>
To: Stefan Monnier <monnier@HIDDEN>
Message-ID: <287350150.1991225.1791594196220@HIDDEN>
In-Reply-To: <jwvld86be21.fsf-monnier+emacs@HIDDEN>
References: <CAF_DUeFtCcdvkNP_R9NOzzBpAcpxOgkVsxyEApn9DJmjxDoy7A.ref@HIDDEN>
 <CAF_DUeFtCcdvkNP_R9NOzzBpAcpxOgkVsxyEApn9DJmjxDoy7A@HIDDEN>
 <jwvik3gf9b8.fsf-monnier+emacs@HIDDEN>
 <1148247025.642123.1791230562417@HIDDEN>
 <jwvik3feuj9.fsf-monnier+emacs@HIDDEN>
 <400612322.697142.1791241954903@HIDDEN>
 <jwvld8bk09e.fsf-monnier+emacs@HIDDEN>
 <630576132.930893.1791304998806@HIDDEN>
 <jwvpkxl2wwr.fsf-monnier+emacs@HIDDEN>
 <1424475815.1803501.1791590594952@HIDDEN>
 <jwvld86be21.fsf-monnier+emacs@HIDDEN>
Subject: Re: bug#81970: peg.el: "if" construct moves point
MIME-Version: 1.0
Content-Type: multipart/alternative; 
 boundary="----=_Part_1991224_1862206977.1791594196219"
X-Mailer: WebService/1.1.26668 YMailNorrin
Content-Length: 5179
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 81970
Cc: "81970 <at> debbugs.gnu.org" <81970 <at> debbugs.gnu.org>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

------=_Part_1991224_1862206977.1791594196219
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

 > On Friday, October 9, 2026 at 05:29:33 PM PDT, Stefan Monnier <monnier@i=
ro.umontreal.ca> wrote:
>
>So, IIUC, your confusion is in the difference between the point-motion
>of primitives like `if` during the parse and how that (fails to)
>relate(s) to the overall point-motion of `peg-run`?
That sounds like a fair description. I thought that `if` and `not` somehow =
exempted the userfrom *all* point movement, including that in peg-run's err=
or handling. I still feel like themanual suggests that.
>
>The point-motion of `peg-run` when the parsing fails is independent of
>the point motion that happened during the parse, so it's "the same" for
>all parsing operators.
Agreed.
>
>IOW, during the parse, a failure always means that point is not moved, but=
 at
>the end of the parse, if the overall parsing failed, `peg-run` will move
>point to its best guess of the place where the parsing failed.
Yes.
>
>> Usage with my original testcase:
>> (with-temp-buffer
>>=C2=A0 =C2=A0 (insert "foobar")
>>=C2=A0 =C2=A0 (goto-char (point-min))
>>=C2=A0 =C2=A0 (peg-looking-at (and "foo" "baz"))=C2=A0 =C2=A0; do not mov=
e point regardless of pass/fail
>>=C2=A0 =C2=A0 (point))=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ; position 1 (where parse started) despite =
fail
>
>Why not use `save-excursion`?

That's a fair question. My actual situation is more complicated, and=C2=A0t=
his made fora clear testcase. But maybe I will end up just using save-excur=
sion.
In any event, doing peg-looking-at as an exercise helped me better grasp ho=
w tocontrol point movement via peg expressions.
  Jeff
 =20
------=_Part_1991224_1862206977.1791594196219
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<html><head></head><body><div class=3D"ydp1e50227yahoo-style-wrap" style=3D=
"font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:13px;">=
<div></div>
        <div dir=3D"ltr" data-setdir=3D"false"><div>&gt; On Friday, October=
 9, 2026 at 05:29:33 PM PDT, Stefan Monnier &lt;monnier@HIDDEN&gt=
; wrote:<br>&gt;</div><div><br>&gt;So, IIUC, your confusion is in the diffe=
rence between the point-motion<br>&gt;of primitives like `if` during the pa=
rse and how that (fails to)<br>&gt;relate(s) to the overall point-motion of=
 `peg-run`?</div><div><br></div><div dir=3D"ltr" data-setdir=3D"false">That=
 sounds like a fair description. I thought that `if` and `not` somehow exem=
pted the user</div><div dir=3D"ltr" data-setdir=3D"false">from *all* point =
movement, including that in peg-run's error handling. I still feel like the=
</div><div dir=3D"ltr" data-setdir=3D"false">manual suggests that.</div><di=
v dir=3D"ltr" data-setdir=3D"false"><br>&gt;<br>&gt;The point-motion of `pe=
g-run` when the parsing fails is independent of<br>&gt;the point motion tha=
t happened during the parse, so it's "the same" for<br>&gt;all parsing oper=
ators.</div><div dir=3D"ltr" data-setdir=3D"false"><br></div><div dir=3D"lt=
r" data-setdir=3D"false">Agreed.</div><div dir=3D"ltr" data-setdir=3D"false=
"><br>&gt;<br>&gt;IOW, during the parse, a failure always means that point =
is not moved, but at<br>&gt;the end of the parse, if the overall parsing fa=
iled, `peg-run` will move<br>&gt;point to its best guess of the place where=
 the parsing failed.</div><div dir=3D"ltr" data-setdir=3D"false"><br></div>=
<div dir=3D"ltr" data-setdir=3D"false">Yes.</div><div dir=3D"ltr" data-setd=
ir=3D"false"><br>&gt;<br>&gt;&gt; Usage with my original testcase:<br>&gt;&=
gt; (with-temp-buffer<br>&gt;&gt;&nbsp; &nbsp; (insert "foobar")<br>&gt;&gt=
;&nbsp; &nbsp; (goto-char (point-min))<br>&gt;&gt;&nbsp; &nbsp; (peg-lookin=
g-at (and "foo" "baz"))&nbsp; &nbsp;; do not move point regardless of pass/=
fail<br>&gt;&gt;&nbsp; &nbsp; (point))&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &n=
bsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ; position 1 (where parse started=
) despite fail<br>&gt;<br>&gt;Why not use `save-excursion`?<br><br></div>Th=
at's a fair question. My actual situation is more complicated, and&nbsp;thi=
s made for</div><div dir=3D"ltr" data-setdir=3D"false">a clear testcase. Bu=
t maybe I will end up just using save-excursion.</div><div dir=3D"ltr" data=
-setdir=3D"false"><br></div><div dir=3D"ltr" data-setdir=3D"false">In any e=
vent, doing peg-looking-at as an exercise helped me better grasp how to</di=
v><div dir=3D"ltr" data-setdir=3D"false">control point movement via peg exp=
ressions.</div><div><br></div>
       =20
        </div><div id=3D"ydpebf7952yahoo_quoted_1685759211" class=3D"ydpebf=
7952yahoo_quoted">
            <div style=3D"font-family:'Helvetica Neue', Helvetica, Arial, s=
ans-serif;font-size:13px;color:#26282a;"><div><div dir=3D"ltr">Jeff</div><d=
iv dir=3D"ltr"><br></div></div>
            </div>
        </div></body></html>
------=_Part_1991224_1862206977.1791594196219--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#81970; Package emacs. Full text available.

Message received at 81970 <at> debbugs.gnu.org:


Received: (at 81970) by debbugs.gnu.org; 10 Oct 2026 00:29:42 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Oct 09 20:29:42 2026
Received: from localhost ([127.0.0.1]:52696 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1xFKy5-0003BC-Cu
	for submit <at> debbugs.gnu.org; Fri, 09 Oct 2026 20:29:42 -0400
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:21394)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <monnier@HIDDEN>)
 id 1xFKy2-0003Ab-3C
 for 81970 <at> debbugs.gnu.org; Fri, 09 Oct 2026 20:29:39 -0400
Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1])
 by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 5421D1001A6;
 Fri, 09 Oct 2026 20:29:31 -0400 (EDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1791592169;
 bh=N0uvzB8q4BoPEuBxfZerdnfusRplTdMCQI0Zhi6U29k=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=OP3Lt+XTJZWJar+bhyxpBCV6rmElawPTjARnSdwEcEwq7h/ItHHSDUMIjHF4bKKJp
 DC1qKWmBgn03fyNKgK6pVJ9SYsr9/EQZp8EELYky4VanrOJ7Q+q4dOlQ0mzQi23o0M
 zN5ChTzyGtXrJmRVFGCpa23FEimXGd3HrPmz/OgaTN14y2QiSY3gfwoIJRob72kiWc
 k/aEJWrNW9+PKeCjsUmCwHzatt4nQMFAhtuFO4rZPPyFLHfswEO07yKMSMghynd815
 IfXZSARVQxKnJke0b25qtjEpQsrECWuPG7ivP0co/Ivial4Qut3vbFo6Lk1S65VAZQ
 BliDnt0+qw7yQ==
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 4042210016C;
 Fri, 09 Oct 2026 20:29:29 -0400 (EDT)
Received: from alfajor (104-195-241-63.cpe.teksavvy.com [104.195.241.63])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 117ED1203CE;
 Fri,  9 Oct 2026 20:29:29 -0400 (EDT)
From: Stefan Monnier <monnier@HIDDEN>
To: Jeff Trull <edaskel@HIDDEN>
Subject: Re: bug#81970: peg.el: "if" construct moves point
In-Reply-To: <1424475815.1803501.1791590594952@HIDDEN>
Message-ID: <jwvld86be21.fsf-monnier+emacs@HIDDEN>
References: <CAF_DUeFtCcdvkNP_R9NOzzBpAcpxOgkVsxyEApn9DJmjxDoy7A.ref@HIDDEN>
 <CAF_DUeFtCcdvkNP_R9NOzzBpAcpxOgkVsxyEApn9DJmjxDoy7A@HIDDEN>
 <jwvik3gf9b8.fsf-monnier+emacs@HIDDEN>
 <1148247025.642123.1791230562417@HIDDEN>
 <jwvik3feuj9.fsf-monnier+emacs@HIDDEN>
 <400612322.697142.1791241954903@HIDDEN>
 <jwvld8bk09e.fsf-monnier+emacs@HIDDEN>
 <630576132.930893.1791304998806@HIDDEN>
 <jwvpkxl2wwr.fsf-monnier+emacs@HIDDEN>
 <1424475815.1803501.1791590594952@HIDDEN>
Date: Fri, 09 Oct 2026 20:29:28 -0400
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
X-SPAM-INFO: Spam detection results:  0
 ALL_TRUSTED                -1 Passed through trusted hosts only via SMTP
 AWL 0.115 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DKIM_SIGNED               0.1 Message has a DKIM or DK signature,
 not necessarily valid
 DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
 DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
 domain
 DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from
 domain
X-SPAM-LEVEL: 
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 81970
Cc: "81970 <at> debbugs.gnu.org" <81970 <at> debbugs.gnu.org>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

>>Hmm... now you lost me: what makes you think that's not the case?
>
> If parsing e returns nil, (if e) will fail, and peg-run will move point to
> the location of the failure,not the point where it started. This is the
> normal behavior that surprised me in the specific caseof `if` and what
> I thought the manual implied it, along with `not`, would not do.

So, IIUC, your confusion is in the difference between the point-motion
of primitives like `if` during the parse and how that (fails to)
relate(s) to the overall point-motion of `peg-run`?

The point-motion of `peg-run` when the parsing fails is independent of
the point motion that happened during the parse, so it's "the same" for
all parsing operators.

IOW, during the parse, a failure always means that point is not moved, but =
at
the end of the parse, if the overall parsing failed, `peg-run` will move
point to its best guess of the place where the parsing failed.

> Usage with my original testcase:
> (with-temp-buffer
> =A0 =A0(insert "foobar")
> =A0 =A0(goto-char (point-min))
> =A0 =A0(peg-looking-at (and "foo" "baz"))=A0 =A0; do not move point regar=
dless of pass/fail
> =A0 =A0(point))=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ; position 1 (where parse started) despite =
fail

Why not use `save-excursion`?


=3D=3D=3D Stefan





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#81970; Package emacs. Full text available.

Message received at 81970 <at> debbugs.gnu.org:


Received: (at 81970) by debbugs.gnu.org; 10 Oct 2026 00:04:57 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Oct 09 20:04:57 2026
Received: from localhost ([127.0.0.1]:48978 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1xFKa5-00016E-SX
	for submit <at> debbugs.gnu.org; Fri, 09 Oct 2026 20:04:56 -0400
Received: from sonic306-25.consmr.mail.ne1.yahoo.com ([66.163.189.87]:46687)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <edaskel@HIDDEN>) id 1xFKa0-00015S-0p
 for 81970 <at> debbugs.gnu.org; Fri, 09 Oct 2026 20:04:51 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=att.net; s=s1024;
 t=1791590680; bh=GmwmtuLcHPmmvg2O0ykZyTRdRO290mFe7MU5Grd+OEk=;
 h=Date:From:To:Cc:In-Reply-To:References:Subject:From:Subject:Reply-To;
 b=DNKPorisvfvbvMLjO8Ke8Um92kLZ5cLf/zVO430ebctHmCGZfmEnSR8qBwcaabtk5deSd4y/Oc5qFwVe6bJxA1/MhpiqERkZ6JXSy0j/3BS+ceAQZz1qdJaiS2yU5lZ4irJHKHyz1poULeN3b3Mt9fqDE8Ve3x+zZiyp0qHdVrQ=
X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048;
 t=1791590680; bh=Ob7terkAqOK4MdvK2IaglWbEw24W9MwWro2RCht/jjc=;
 h=X-Sonic-MF:Date:From:To:Subject:From:Subject;
 b=L7eeKk1jGDF5M3pCSAaZq1g7D4E9ZLR42qTsas3ET3hTSdIP6Z3UfqkvZDg5bPKOqu2034l+5Z1hTlnV8w2kcnZ/pvQ+pZ8QATa/C18CRwQRb6aOzyvIMN4R5QFwsnlnheYpoX7qWjNtAzjXlmJZrrqvlxAd5SOlGbKpvfw0PepIzfCJ0vLmnrrp9A7f8Idt1HEzfbiaePTH13elyKecH8q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NWi4_HX5JIxdh51sRQNG3Cc
 LoTE8MW0WKkhDGyk4Q_ZVbY.7UyisDXz8_cqVSob8N6SltHI.1R6_s7kkS6c8zHdvwgx5vay8fXm
 fOVU6Xbs07NPRgb286PsurjORkPsxkgBxlNmpkkc1TfXR1PdBL6M_qtxw6kxAtGM9MtWrctRqEaH
 RoDXpyDUIv_itx4ph4Rli8B2kDsPWpfyLvH2Rt24zmFW8.JvNvCQofs5LO3TDAJgLM9aabv8UP71
 rqEsZ_si.6x8m00jfo6w8yTNqIeN8fVAYT39oIl60lEJvt34pEoZMTNUcr7tCXc3YJeSwUHQS0km
 lWHnuVkHrO52Sc.6rMQdTF_bBs9aIXR13u6ZfOvU__a1fI4xkwtW0yaruE77f3gM2im3eMTET
X-Sonic-MF: <edaskel@HIDDEN>
X-Sonic-ID: 827a6d9a-12f6-4d79-a7b9-cb7ccc7b7724
Received: from sonic.gate.mail.ne1.yahoo.com by
 sonic306.consmr.mail.ne1.yahoo.com with HTTP; Sat, 10 Oct 2026 00:04:40 +0000
Date: Sat, 10 Oct 2026 00:03:14 +0000 (UTC)
From: Jeff Trull <edaskel@HIDDEN>
To: Stefan Monnier <monnier@HIDDEN>
Message-ID: <1424475815.1803501.1791590594952@HIDDEN>
In-Reply-To: <jwvpkxl2wwr.fsf-monnier+emacs@HIDDEN>
References: <CAF_DUeFtCcdvkNP_R9NOzzBpAcpxOgkVsxyEApn9DJmjxDoy7A.ref@HIDDEN>
 <CAF_DUeFtCcdvkNP_R9NOzzBpAcpxOgkVsxyEApn9DJmjxDoy7A@HIDDEN>
 <jwvik3gf9b8.fsf-monnier+emacs@HIDDEN>
 <1148247025.642123.1791230562417@HIDDEN>
 <jwvik3feuj9.fsf-monnier+emacs@HIDDEN>
 <400612322.697142.1791241954903@HIDDEN>
 <jwvld8bk09e.fsf-monnier+emacs@HIDDEN>
 <630576132.930893.1791304998806@HIDDEN>
 <jwvpkxl2wwr.fsf-monnier+emacs@HIDDEN>
Subject: Re: bug#81970: peg.el: "if" construct moves point
MIME-Version: 1.0
Content-Type: multipart/alternative; 
 boundary="----=_Part_1803500_135479716.1791590594951"
X-Mailer: WebService/1.1.26668 YMailNorrin
Content-Length: 7080
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 81970
Cc: "81970 <at> debbugs.gnu.org" <81970 <at> debbugs.gnu.org>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

------=_Part_1803500_135479716.1791590594951
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

>On Wednesday, October 7, 2026 at 11:23:57 AM PDT, Stefan Monnier <monnier@=
iro.umontreal.ca> wrote:
>
>
>>=C2=A0 > On Monday, October 5, 2026 at 07:58:53 PM PDT, Stefan Monnier <m=
onnier@HIDDEN> wrote:
>>>>=C2=A0 >Not really, no: if `if` fails, it does not move point either (t=
hat's
>>>>>case for pretty much all PEG primitives).
>>>> Well... perhaps we can say that `if` conditionally restores point,
>>>No: *all* primitives leave point unchanged when they fail.>And since `if=
`
>>> restores point when it succeeds, it means that `if`>*never* changes poi=
nt.
>> I'm glad you phrased it this way, because this is the exact point it wou=
ld
>> beuseful to clarify in the manual - that `if` is not exempt from the
>> universal rule.The existing phrasing suggests to me that it is:
>> "Returns non-nil if parsing PEX e from point succeeds (point is not move=
d)."
>> I think other readers may reasonably conclude that an `if` expression,
>> alongwith its children, will complete with point where it started,
>> regardless of whethernil was returned
>
>And they'd be right.
>
>> I understand now that it's not the case,
>
>Hmm... now you lost me: what makes you think that's not the case?

If parsing e returns nil, (if e) will fail, and peg-run will move point to =
the location of the failure,not the point where it started. This is the nor=
mal behavior that surprised me in the specific caseof `if` and what I thoug=
ht the manual implied it, along with `not`, would not do. That is what Iund=
erstand now is "not the case" - that `if` and `not` are the same as any oth=
er primitive,and their restoration-of-point property is only for parses tha=
t pass (return t). Those that failget the move-to-farthest-failure behavior=
.
Perhaps I am the only one who had this interpretation. At any rate I have a=
 decent solution nowthat restores point regardless of whether a parse succe=
eded; maybe it will help others in myposition:
(defmacro peg-looking-at (pegexp)
=C2=A0 `(car
=C2=A0 =C2=A0 (peg-run (peg (or (and (if ,pegexp) `(-- 't))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 (and (null) `(-- nil)))))))

Usage with my original testcase:
(with-temp-buffer
=C2=A0 =C2=A0(insert "foobar")
=C2=A0 =C2=A0(goto-char (point-min))
=C2=A0 =C2=A0(peg-looking-at (and "foo" "baz"))=C2=A0 =C2=A0; do not move p=
oint regardless of pass/fail
=C2=A0 =C2=A0(point))=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 ; position 1 (where parse started) despite fail


Jeff
 =20
------=_Part_1803500_135479716.1791590594951
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<html><head></head><body><div class=3D"yahoo-style-wrap" style=3D"font-fami=
ly:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:13px;"><div dir=
=3D"ltr" data-setdir=3D"false"><div>&gt;On Wednesday, October 7, 2026 at 11=
:23:57 AM PDT, Stefan Monnier &lt;monnier@HIDDEN&gt; wrote:<br>&g=
t;<br>&gt;<br>&gt;&gt;&nbsp; &gt; On Monday, October 5, 2026 at 07:58:53 PM=
 PDT, Stefan Monnier &lt;monnier@HIDDEN&gt; wrote:<br>&gt;&gt;&gt=
;&gt;&nbsp; &gt;Not really, no: if `if` fails, it does not move point eithe=
r (that's<br>&gt;&gt;&gt;&gt;&gt;case for pretty much all PEG primitives).<=
br>&gt;&gt;&gt;&gt; Well... perhaps we can say that `if` conditionally rest=
ores point,<br>&gt;&gt;&gt;No: *all* primitives leave point unchanged when =
they fail.&gt;And since `if`<br>&gt;&gt;&gt; restores point when it succeed=
s, it means that `if`&gt;*never* changes point.<br>&gt;&gt; I'm glad you ph=
rased it this way, because this is the exact point it would<br>&gt;&gt; beu=
seful to clarify in the manual - that `if` is not exempt from the<br>&gt;&g=
t; universal rule.The existing phrasing suggests to me that it is:<br>&gt;&=
gt; "Returns non-nil if parsing PEX e from point succeeds (point is not mov=
ed)."<br>&gt;&gt; I think other readers may reasonably conclude that an `if=
` expression,<br>&gt;&gt; alongwith its children, will complete with point =
where it started,<br>&gt;&gt; regardless of whethernil was returned<br>&gt;=
<br>&gt;And they'd be right.<br>&gt;<br>&gt;&gt; I understand now that it's=
 not the case,<br>&gt;<br>&gt;Hmm... now you lost me: what makes you think =
that's not the case?<br><br></div></div><div id=3D"ydpf6ed945ayahoo_quoted_=
2534864131" class=3D"ydpf6ed945ayahoo_quoted"><div style=3D"font-family:'He=
lvetica Neue', Helvetica, Arial, sans-serif;font-size:13px;color:#26282a;">=
<div><div dir=3D"ltr" data-setdir=3D"false">If parsing e returns nil, (if e=
) will fail, and peg-run will move point to the location of the failure,</d=
iv><div dir=3D"ltr" data-setdir=3D"false">not the point where it started. T=
his is the normal behavior that surprised me in the specific case</div><div=
 dir=3D"ltr" data-setdir=3D"false">of `if` and what I thought the manual im=
plied it, along with `not`, would not do. That is what I</div><div dir=3D"l=
tr" data-setdir=3D"false">understand now is "not the case" - that `if` and =
`not` are the same as any other primitive,</div><div dir=3D"ltr" data-setdi=
r=3D"false">and their restoration-of-point property is only for parses that=
 pass (return t). Those that fail</div><div dir=3D"ltr" data-setdir=3D"fals=
e">get the move-to-farthest-failure behavior.</div><div dir=3D"ltr" data-se=
tdir=3D"false"><br></div><div dir=3D"ltr" data-setdir=3D"false">Perhaps I a=
m the only one who had this interpretation. At any rate I have a decent sol=
ution now</div><div dir=3D"ltr" data-setdir=3D"false">that restores point r=
egardless of whether a parse succeeded; maybe it will help others in my</di=
v><div dir=3D"ltr" data-setdir=3D"false">position:</div><div dir=3D"ltr" da=
ta-setdir=3D"false"><br></div><div dir=3D"ltr" data-setdir=3D"false"><div>(=
defmacro peg-looking-at (pegexp)<br>&nbsp; `(car<br>&nbsp; &nbsp; (peg-run =
(peg (or (and (if ,pegexp) `(-- 't))<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (and (null) `(-- nil)))))))<br><b=
r></div>Usage with my original testcase:</div><div dir=3D"ltr" data-setdir=
=3D"false"><br></div><div dir=3D"ltr" data-setdir=3D"false"><div dir=3D"ltr=
" data-setdir=3D"false">(with-temp-buffer<br>&nbsp; &nbsp;(insert "foobar")=
<br>&nbsp; &nbsp;(goto-char (point-min))<br>&nbsp; &nbsp;(peg-looking-at (a=
nd "foo" "baz"))&nbsp; &nbsp;; do not move point regardless of pass/fail<br=
>&nbsp; &nbsp;(point))&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbs=
p; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &n=
bsp; &nbsp; &nbsp; &nbsp; ; position 1 (where parse started) despite fail<b=
r><br></div><div><br></div>Jeff</div><div dir=3D"ltr" data-setdir=3D"false"=
><br></div></div>
            </div>
        </div></div></body></html>
------=_Part_1803500_135479716.1791590594951--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#81970; Package emacs. Full text available.

Message received at 81970 <at> debbugs.gnu.org:


Received: (at 81970) by debbugs.gnu.org; 7 Oct 2026 18:24:15 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Oct 07 14:24:14 2026
Received: from localhost ([127.0.0.1]:56141 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1xEWJG-00031F-1e
	for submit <at> debbugs.gnu.org; Wed, 07 Oct 2026 14:24:14 -0400
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:12818)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <monnier@HIDDEN>)
 id 1xEWJ7-00030W-Ih
 for 81970 <at> debbugs.gnu.org; Wed, 07 Oct 2026 14:24:05 -0400
Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1])
 by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id A3AF610008C;
 Wed, 07 Oct 2026 14:23:54 -0400 (EDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1791397433;
 bh=8DMqlbRUNe41j3nRbkzQjX3Km/O2yrvERfzFQm36gNo=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=NYJ0LjPlHnj7JAjIURITSRq9/ADpGBEeKrNDEyOaRu2hxFJdzZoc9oWV+gSoGsOWM
 ixNTpwLCJafSvi5eu1oJIezdH7IqZWzJHbyDr7sRuTZlYKmntmptTMNnOCkXAnfHD3
 vmzL8dq0JswXIXa8+D8D9Z5MqYnvZMkpXnehpPXLlE9mqWyh3jy/yYMYP5dItkdkiO
 pY+HR5ehLwXcBse41BFo4GKBmsu5FJN5jJxSv9VnOg3j0ZSs0CgTee7+9IUOvXstUG
 GNEh6o35dC/6Pz9k9inhEvRFqxYAhVYEWAhfCcKHIhlInzSZKtLgWqSlCX7Cb2yulh
 +6lTRNitf/FPQ==
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 73FD710006D;
 Wed, 07 Oct 2026 14:23:53 -0400 (EDT)
Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 68E2A120C95;
 Wed,  7 Oct 2026 14:23:53 -0400 (EDT)
From: Stefan Monnier <monnier@HIDDEN>
To: Jeff Trull <edaskel@HIDDEN>
Subject: Re: bug#81970: peg.el: "if" construct moves point
In-Reply-To: <630576132.930893.1791304998806@HIDDEN>
Message-ID: <jwvpkxl2wwr.fsf-monnier+emacs@HIDDEN>
References: <CAF_DUeFtCcdvkNP_R9NOzzBpAcpxOgkVsxyEApn9DJmjxDoy7A.ref@HIDDEN>
 <CAF_DUeFtCcdvkNP_R9NOzzBpAcpxOgkVsxyEApn9DJmjxDoy7A@HIDDEN>
 <jwvik3gf9b8.fsf-monnier+emacs@HIDDEN>
 <1148247025.642123.1791230562417@HIDDEN>
 <jwvik3feuj9.fsf-monnier+emacs@HIDDEN>
 <400612322.697142.1791241954903@HIDDEN>
 <jwvld8bk09e.fsf-monnier+emacs@HIDDEN>
 <630576132.930893.1791304998806@HIDDEN>
Date: Wed, 07 Oct 2026 14:23:53 -0400
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
X-SPAM-INFO: Spam detection results:  0
 ALL_TRUSTED                -1 Passed through trusted hosts only via SMTP
 AWL 0.172 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DKIM_SIGNED               0.1 Message has a DKIM or DK signature,
 not necessarily valid
 DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
 DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
 domain
 DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from
 domain
X-SPAM-LEVEL: 
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 81970
Cc: "81970 <at> debbugs.gnu.org" <81970 <at> debbugs.gnu.org>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

>  > On Monday, October 5, 2026 at 07:58:53 PM PDT, Stefan Monnier <monnier=
@iro.umontreal.ca> wrote:
>>>=A0 >Not really, no: if `if` fails, it does not move point either (that's
>>>>case for pretty much all PEG primitives).
>>> Well... perhaps we can say that `if` conditionally restores point,
>>No: *all* primitives leave point unchanged when they fail.>And since `if`
>> restores point when it succeeds, it means that `if`>*never* changes poin=
t.
> I'm glad you phrased it this way, because this is the exact point it would
> beuseful to clarify in the manual - that `if` is not exempt from the
> universal rule.The existing phrasing suggests to me that it is:
> "Returns non-nil if parsing PEX e from point succeeds (point is not moved=
)."
> I think other readers may reasonably conclude that an `if` expression,
> alongwith its children, will complete with point where it started,
> regardless of whethernil was returned

And they'd be right.

> I understand now that it's not the case,

Hmm... now you lost me: what makes you think that's not the case?


=3D=3D=3D Stefan





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#81970; Package emacs. Full text available.

Message received at 81970 <at> debbugs.gnu.org:


Received: (at 81970) by debbugs.gnu.org; 6 Oct 2026 02:59:18 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Oct 05 22:59:17 2026
Received: from localhost ([127.0.0.1]:33135 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1xDvOY-0005NX-8F
	for submit <at> debbugs.gnu.org; Mon, 05 Oct 2026 22:59:13 -0400
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:33224)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <monnier@HIDDEN>)
 id 1xDvON-0005M4-Tg
 for 81970 <at> debbugs.gnu.org; Mon, 05 Oct 2026 22:59:04 -0400
Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1])
 by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 3AD4110009B;
 Mon, 05 Oct 2026 22:58:51 -0400 (EDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1791255530;
 bh=4CMOPW6yEzI9xj7gHYtuC34mPc9Z4OwO6Oahj9s3VTQ=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=cZwBvXW89oJdNvhsv3Cy7qVCvxwzvUs7SRQmMXD1cjtsfOLtSNfFcONrEH++aNo0M
 TokW9gaUVaGhzp7zXcwOr6MNq99EQ3JgWWCdmc45nh5HZ2ShECPSx29vP0ASXvLa4C
 IF28+/t9IZeDHsStzMA160JNV94/4WBL69JBcbDpCFJn/l/J8kQgGMOqazHqfyZQ6s
 cP5cWf5bxSplRVR9af2/i9oP0p/8uS3o6wKsuixF5Q/gg6ufBueXh+mdTJpCrrXCYA
 8MrlNxZiZTZqHWSNTucWd0GwKhL+As21xKXH/+7lZPoIRoTMhWFl08NCVUTW3xxBbu
 DqhSgA6eCSfUA==
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 1068F100070;
 Mon, 05 Oct 2026 22:58:50 -0400 (EDT)
Received: from pastel (104-195-198-126.cpe.teksavvy.com [104.195.198.126])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id D6815120406;
 Mon,  5 Oct 2026 22:58:49 -0400 (EDT)
From: Stefan Monnier <monnier@HIDDEN>
To: Jeff Trull <edaskel@HIDDEN>
Subject: Re: bug#81970: peg.el: "if" construct moves point
In-Reply-To: <400612322.697142.1791241954903@HIDDEN>
Message-ID: <jwvld8bk09e.fsf-monnier+emacs@HIDDEN>
References: <CAF_DUeFtCcdvkNP_R9NOzzBpAcpxOgkVsxyEApn9DJmjxDoy7A.ref@HIDDEN>
 <CAF_DUeFtCcdvkNP_R9NOzzBpAcpxOgkVsxyEApn9DJmjxDoy7A@HIDDEN>
 <jwvik3gf9b8.fsf-monnier+emacs@HIDDEN>
 <1148247025.642123.1791230562417@HIDDEN>
 <jwvik3feuj9.fsf-monnier+emacs@HIDDEN>
 <400612322.697142.1791241954903@HIDDEN>
Date: Mon, 05 Oct 2026 22:58:47 -0400
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-SPAM-INFO: Spam detection results:  0
 ALL_TRUSTED                -1 Passed through trusted hosts only via SMTP
 AWL 0.113 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DKIM_SIGNED               0.1 Message has a DKIM or DK signature,
 not necessarily valid
 DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
 DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
 domain
 DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from
 domain
X-SPAM-LEVEL: 
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 81970
Cc: "81970 <at> debbugs.gnu.org" <81970 <at> debbugs.gnu.org>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

>  >Not really, no: if `if` fails, it does not move point either (that's
>>case for pretty much all PEG primitives).
> Well... perhaps we can say that `if` conditionally restores point,

No: *all* primitives leave point unchanged when they fail.
And since `if` restores point when it succeeds, it means that `if`
*never* changes point.

>>When `and` fails it also doesn't move point, so when `(if "foo" "bar")`
>>fails, then it behaves exactly like `(and "foo" "bar")`.
> That's exactly what I was surprised by, after having carefully read the
> manual.  To phrase it in terms of the implementation, `if` only restores =
point
> if it passes.

That's because when it fails, there's nothing to "restore".

> I expected it to restore point unconditionally, i.e. be
> different than `and`.

It *is* different from `and` when it succeeds.  But it is like `and`
(and all others) when it fails, i.e. point is not moved in that case.

> Clearly it doesn't, and that's an acceptable choice,
> but I wasn't expecting it.

I think "Clearly" is debatable here =F0=9F=99=82.


=3D=3D=3D Stefan





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#81970; Package emacs. Full text available.

Message received at 81970 <at> debbugs.gnu.org:


Received: (at 81970) by debbugs.gnu.org; 5 Oct 2026 23:13:16 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Oct 05 19:13:15 2026
Received: from localhost ([127.0.0.1]:46031 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1xDrrk-0005mr-IL
	for submit <at> debbugs.gnu.org; Mon, 05 Oct 2026 19:13:14 -0400
Received: from sonic302-25.consmr.mail.ne1.yahoo.com ([66.163.186.151]:36801)
 by debbugs.gnu.org with esmtps
 (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2)
 (envelope-from <edaskel@HIDDEN>) id 1xDrrW-0005ld-Od
 for 81970 <at> debbugs.gnu.org; Mon, 05 Oct 2026 19:13:00 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=att.net; s=s1024;
 t=1791241963; bh=7yyQ0BlSbC759sopGhgU6VroiqgUdbTY88fguzvRAhc=;
 h=Date:From:To:Cc:In-Reply-To:References:Subject:From:Subject:Reply-To;
 b=xdX5yY84+K/J8B6z7LCppEYNRIOuRU1HVXGTNZZPeKP1nYsPKlF8EIo2sqcFo8KUGJGTR4XwRs6tVvYrbU+wnMKcORMbY61UaK7HHNFfWq6kk3UoBBCd+XmChvLqeDWXElxFglHNbxidvZUnwB3rH8EM7m+X6OwF0ZhfJsSzlYI=
X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048;
 t=1791241963; bh=WIVEo3Rvsze+9zg42hHoYAUnCcSptw+cB6ZnCdtIxpB=;
 h=X-Sonic-MF:Date:From:To:Subject:From:Subject;
 b=B0ZO1yDrOKl5Hmg/KjaT3b5ep0uFn66YdiuzjseTqAO2f/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OdtTBFNnUx9j5NCjpFt3.9ACdYrf.m
 4AHJlb.6zqxTR6yLu_Qx7AFfFf6JVSGTZDqsS4SLrKuW8DxkC2G6l8RsM1FN3ZZiD27E3fIZQYlh
 BdiFwsqd0m9R8N2GDRHhrgExGjurCYK2Vztojwlb7pObCHabgMnE8ThFmbgpIVYyO3q1IKBOiTzD
 dEn2zOA_E9.MhAqMncUYBkN7rq5kdUG93kqAoJaFu_WJt.hCCwUHmhKufTTWmym6zHWIKJ7aRQ1q
 fR6cmTT5uVx03Qs1Gdiqmk.DeP9.RaTbq4AJbquAf6z_FIa3V5dcBC_Yj9NwLL2SHeGu3gTDRHeE
 mII0fVFTsCNON8nVVwpJF8RBZ1XPN1B7ohXVwIERrGgdd21jBuVNXgCskACpc1D8CTRJbOf8SjVz
 NZaYNt.g9rlkGrc0yHlkHjWLVFjfhSE9zTtHJCJ2islaQe.hSsX06JwJjlzl8z1ooFR7Guj7labR
 ZNmUOFEMLr2G9vRypnGIfjEO5ljpXtWJbDnuNcT_olm6EIKkZkc5QhxfQFKsWK4BTpcZxGuEZhaK
 k4EKF
X-Sonic-MF: <edaskel@HIDDEN>
X-Sonic-ID: 98534ac7-37dd-48f3-8526-7a437dfe521f
Received: from sonic.gate.mail.ne1.yahoo.com by
 sonic302.consmr.mail.ne1.yahoo.com with HTTP; Mon, 5 Oct 2026 23:12:43 +0000
Date: Mon, 5 Oct 2026 23:12:34 +0000 (UTC)
From: Jeff Trull <edaskel@HIDDEN>
To: Stefan Monnier <monnier@HIDDEN>
Message-ID: <400612322.697142.1791241954903@HIDDEN>
In-Reply-To: <jwvik3feuj9.fsf-monnier+emacs@HIDDEN>
References: <CAF_DUeFtCcdvkNP_R9NOzzBpAcpxOgkVsxyEApn9DJmjxDoy7A.ref@HIDDEN>
 <CAF_DUeFtCcdvkNP_R9NOzzBpAcpxOgkVsxyEApn9DJmjxDoy7A@HIDDEN>
 <jwvik3gf9b8.fsf-monnier+emacs@HIDDEN>
 <1148247025.642123.1791230562417@HIDDEN>
 <jwvik3feuj9.fsf-monnier+emacs@HIDDEN>
Subject: Re: bug#81970: peg.el: "if" construct moves point
MIME-Version: 1.0
Content-Type: multipart/alternative; 
 boundary="----=_Part_697141_655317935.1791241954901"
X-Mailer: WebService/1.1.26668 YMailNorrin
Content-Length: 11592
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 81970
Cc: "81970 <at> debbugs.gnu.org" <81970 <at> debbugs.gnu.org>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

------=_Part_697141_655317935.1791241954901
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

 >Not really, no: if `if` fails, it does not move point either (that's
>case for pretty much all PEG primitives).
Well... perhaps we can say that `if` conditionally restores point, and`and`=
 does not, since that's the implementation?
But the documentation takes pains to say that `if` and several other primit=
ives"do not move point", so the implied model is:
some primitives move point, and others don't=C2=A0 =C2=A0 =C2=A0 =C2=A0 << =
the manual
vs.
some primitives restore point, and others don't.=C2=A0 =C2=A0 =C2=A0<< the =
code
The former is presumably easier to understand, which is why it's in themanu=
al that way.
>
>>> Hence, my question: what did you expect `(if "foo" "baz")` to do?
>> Fail, and leave point at the beginning of the buffer.
>> Note this is different from what I expected (and "foo" "baz")
>
>When `and` fails it also doesn't move point, so when `(if "foo" "bar")`
>fails, then it behaves exactly like `(and "foo" "bar")`.
That's exactly what I was surprised by, after having carefully read the man=
ual.To phrase it in terms of the implementation, `if` only restores point i=
f it passes.I expected it to restore point unconditionally, i.e. be differe=
nt than `and`.Clearly it doesn't, and that's an acceptable choice, but I wa=
sn't expecting it.
>>=C2=A0
>> > "The if and not operators accept a parsing expression and interpret it
>> > as a boolean,without moving point" sounded to me as though they would
>> > not move point regardless of which boolean value was returned.
>>=C2=A0
>> That's the case.=C2=A0 The point motion you see doesn't come from `if` b=
ut
>> from `peg-run`.
From reading the code, the point motion comes from primitives like `str`, a=
ndpoint restoration (conditionally) comes from primitives like `if`.=C2=A0B=
ut it need not be -and indeed is not - described in the manual this way. In=
stead it speaks of pointmovement by primitives.
I think the manual's choice was a natural one, even if it's not technically=
 correct,since it produces a useful model for the user. I only suggest that=
 the movementbe clearly noted as dependent on whether the primitive passes =
or fails. Specifically,in "PEX Definitions" change:
(if e)
=C2=A0 =C2=A0 Returns non-nil if parsing PEX e from point succeeds (point i=
s not moved).

to:
=C2=A0 =C2=A0 Returns non-nil and does not move point if parsing PEX e from=
 point succeeds
or "and point does not move" if you prefer. Similarly for `not`.
It's consistent with the existing documentation, and it would have reduced =
my confusion.
Thanks,Jeff
    On Monday, October 5, 2026 at 01:58:53 PM PDT, Stefan Monnier <monnier@=
iro.umontreal.ca> wrote: =20
=20
 >>=C2=A0 =C2=A0 =C2=A0(with-temp-buffer
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0(insert "foobar")
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0(goto-char (point-min))
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0(list (peg-run (peg (if "foo") "fooba"))
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(- (point) (point-min))))
>>=C2=A0
>> returns `(t 5)`, which shows that the `if` did not move point.
> Right, because it passes.

Not really, no: if `if` fails, it does not move point either (that's
case for pretty much all PEG primitives).

>> Hence, my question: what did you expect `(if "foo" "baz")` to do?
> Fail, and leave point at the beginning of the buffer.
> Note this is different fromwhat I expected (and "foo" "baz")

When `and` fails it also doesn't move point, so when `(if "foo" "bar")`
fails, then it behaves exactly like `(and "foo" "bar")`.

> "The if and not operators accept a parsing expression andinterpret it
> as a boolean,without moving point" sounded to me as though they would
> not move point regardless of which boolean value wasreturned.

That's the case.=C2=A0 The point motion you see doesn't come from `if` but
from `peg-run`.


=3D=3D=3D Stefan

 =20
------=_Part_697141_655317935.1791241954901
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<html><head></head><body><div class=3D"ydpe96802f8yahoo-style-wrap" style=
=3D"font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:13px=
;"><div></div>
        <div dir=3D"ltr" data-setdir=3D"false"><div>&gt;Not really, no: if =
`if` fails, it does not move point either (that's<br>&gt;case for pretty mu=
ch all PEG primitives).</div><div><br></div><div dir=3D"ltr" data-setdir=3D=
"false">Well... perhaps we can say that `if` conditionally restores point, =
and</div><div dir=3D"ltr" data-setdir=3D"false">`and` does not, since that'=
s the implementation?</div><div dir=3D"ltr" data-setdir=3D"false"><br></div=
><div dir=3D"ltr" data-setdir=3D"false">But the documentation takes pains t=
o say that `if` and several other primitives</div><div dir=3D"ltr" data-set=
dir=3D"false">"do not move point", so the implied model is:</div><div dir=
=3D"ltr" data-setdir=3D"false"><br></div><div dir=3D"ltr" data-setdir=3D"fa=
lse">some primitives move point, and others don't&nbsp; &nbsp; &nbsp; &nbsp=
; &lt;&lt; the manual</div><div dir=3D"ltr" data-setdir=3D"false"><br></div=
><div dir=3D"ltr" data-setdir=3D"false">vs.</div><div dir=3D"ltr" data-setd=
ir=3D"false"><br></div><div dir=3D"ltr" data-setdir=3D"false">some primitiv=
es restore point, and others don't.&nbsp; &nbsp; &nbsp;&lt;&lt; the code</d=
iv><div dir=3D"ltr" data-setdir=3D"false"><br></div><div dir=3D"ltr" data-s=
etdir=3D"false">The former is presumably easier to understand, which is why=
 it's in the</div><div dir=3D"ltr" data-setdir=3D"false">manual that way.</=
div><div dir=3D"ltr" data-setdir=3D"false"><br>&gt;<br>&gt;&gt;&gt; Hence, =
my question: what did you expect `(if "foo" "baz")` to do?<br>&gt;&gt; Fail=
, and leave point at the beginning of the buffer.<br>&gt;&gt; Note this is =
different from what I expected (and "foo" "baz")<br>&gt;<br>&gt;When `and` =
fails it also doesn't move point, so when `(if "foo" "bar")`<br>&gt;fails, =
then it behaves exactly like `(and "foo" "bar")`.</div><div><br></div><div =
dir=3D"ltr" data-setdir=3D"false">That's exactly what I was surprised by, a=
fter having carefully read the manual.</div><div dir=3D"ltr" data-setdir=3D=
"false">To phrase it in terms of the implementation, `if` only restores poi=
nt if it passes.</div><div dir=3D"ltr" data-setdir=3D"false">I expected it =
to restore point unconditionally, i.e. be different than `and`.</div><div d=
ir=3D"ltr" data-setdir=3D"false">Clearly it doesn't, and that's an acceptab=
le choice, but I wasn't expecting it.</div><div dir=3D"ltr" data-setdir=3D"=
false"><br>&gt;&gt;&nbsp;<br>&gt;&gt; &gt; "The if and not operators accept=
 a parsing expression and interpret it<br>&gt;&gt; &gt; as a boolean,withou=
t moving point" sounded to me as though they would<br>&gt;&gt; &gt; not mov=
e point regardless of which boolean value was returned.<br>&gt;&gt;&nbsp;<b=
r>&gt;&gt; That's the case.&nbsp; The point motion you see doesn't come fro=
m `if` but<br>&gt;&gt; from `peg-run`.</div><div dir=3D"ltr" data-setdir=3D=
"false"><br></div><div dir=3D"ltr" data-setdir=3D"false">From reading the c=
ode, the point motion comes from primitives like `str`, and</div><div dir=
=3D"ltr" data-setdir=3D"false">point restoration (conditionally) comes from=
 primitives like `if`.&nbsp;But it need not be -</div><div dir=3D"ltr" data=
-setdir=3D"false">and indeed is not - described in the manual this way. Ins=
tead it speaks of point</div><div dir=3D"ltr" data-setdir=3D"false">movemen=
t by primitives.</div><div dir=3D"ltr" data-setdir=3D"false"><br></div><div=
 dir=3D"ltr" data-setdir=3D"false">I think the manual's choice was a natura=
l one, even if it's not technically correct,</div><div dir=3D"ltr" data-set=
dir=3D"false">since it produces a useful model for the user. I only suggest=
 that the movement</div><div dir=3D"ltr" data-setdir=3D"false">be clearly n=
oted as dependent on whether the primitive passes or fails. Specifically,</=
div><div dir=3D"ltr" data-setdir=3D"false">in "PEX Definitions" change:</di=
v><div dir=3D"ltr" data-setdir=3D"false"><br></div><div dir=3D"ltr" data-se=
tdir=3D"false"><div>(if e)<br>&nbsp; &nbsp; Returns non-nil if parsing PEX =
e from point succeeds (point is not moved).<br><br></div>to:</div><div dir=
=3D"ltr" data-setdir=3D"false"><br>&nbsp; &nbsp; Returns non-nil and does n=
ot move point if parsing PEX e from point succeeds</div><div dir=3D"ltr" da=
ta-setdir=3D"false"><br></div><div dir=3D"ltr" data-setdir=3D"false">or "an=
d point does not move" if you prefer. Similarly for `not`.</div><div dir=3D=
"ltr" data-setdir=3D"false"><br></div>It's consistent with the existing doc=
umentation, and it would have reduced my confusion.</div><div dir=3D"ltr" d=
ata-setdir=3D"false"><br></div><div dir=3D"ltr" data-setdir=3D"false">Thank=
s,</div><div dir=3D"ltr" data-setdir=3D"false">Jeff</div><div dir=3D"ltr" d=
ata-setdir=3D"false"><br></div>
       =20
        </div><div id=3D"yahoo_quoted_1902273786" class=3D"yahoo_quoted">
            <div style=3D"font-family:'Helvetica Neue', Helvetica, Arial, s=
ans-serif;font-size:13px;color:#26282a;">
               =20
                <div>
                        On Monday, October 5, 2026 at 01:58:53 PM PDT, Stef=
an Monnier &lt;monnier@HIDDEN&gt; wrote:
                    </div>
                    <div><br></div>
                    <div><br></div>
               =20
               =20
                <div><div dir=3D"ltr">&gt;&gt;&nbsp; &nbsp; &nbsp;(with-tem=
p-buffer<br></div><div dir=3D"ltr">&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp;(inse=
rt "foobar")<br></div><div dir=3D"ltr">&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp;(=
goto-char (point-min))<br></div><div dir=3D"ltr">&gt;&gt;&nbsp; &nbsp; &nbs=
p; &nbsp;(list (peg-run (peg (if "foo") "fooba"))<br></div><div dir=3D"ltr"=
>&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(- (point) (point-=
min))))<br></div><div dir=3D"ltr">&gt;&gt;&nbsp;<br></div><div dir=3D"ltr">=
&gt;&gt; returns `(t 5)`, which shows that the `if` did not move point.<br>=
</div><div dir=3D"ltr">&gt; Right, because it passes.<br></div><div dir=3D"=
ltr"><br></div><div dir=3D"ltr">Not really, no: if `if` fails, it does not =
move point either (that's<br></div><div dir=3D"ltr">case for pretty much al=
l PEG primitives).<br></div><div dir=3D"ltr"><br></div><div dir=3D"ltr">&gt=
;&gt; Hence, my question: what did you expect `(if "foo" "baz")` to do?<br>=
</div><div dir=3D"ltr">&gt; Fail, and leave point at the beginning of the b=
uffer.<br></div><div dir=3D"ltr">&gt; Note this is different fromwhat I exp=
ected (and "foo" "baz")<br></div><div dir=3D"ltr"><br></div><div dir=3D"ltr=
">When `and` fails it also doesn't move point, so when `(if "foo" "bar")`<b=
r></div><div dir=3D"ltr">fails, then it behaves exactly like `(and "foo" "b=
ar")`.<br></div><div dir=3D"ltr"><br></div><div dir=3D"ltr">&gt; "The if an=
d not operators accept a parsing expression andinterpret it<br></div><div d=
ir=3D"ltr">&gt; as a boolean,without moving point" sounded to me as though =
they would<br></div><div dir=3D"ltr">&gt; not move point regardless of whic=
h boolean value wasreturned.<br></div><div dir=3D"ltr"><br></div><div dir=
=3D"ltr">That's the case.&nbsp; The point motion you see doesn't come from =
`if` but<br></div><div dir=3D"ltr">from `peg-run`.<br></div><div dir=3D"ltr=
"><br></div><div dir=3D"ltr"><br></div><div dir=3D"ltr">=3D=3D=3D Stefan<br=
></div><div dir=3D"ltr"><br></div></div>
            </div>
        </div></body></html>
------=_Part_697141_655317935.1791241954901--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#81970; Package emacs. Full text available.

Message received at 81970 <at> debbugs.gnu.org:


Received: (at 81970) by debbugs.gnu.org; 5 Oct 2026 20:59:10 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Oct 05 16:59:09 2026
Received: from localhost ([127.0.0.1]:54031 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1xDpm5-00049t-Rb
	for submit <at> debbugs.gnu.org; Mon, 05 Oct 2026 16:59:08 -0400
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:48493)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <monnier@HIDDEN>)
 id 1xDply-000493-UR
 for 81970 <at> debbugs.gnu.org; Mon, 05 Oct 2026 16:59:01 -0400
Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1])
 by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 0A1C04423C0;
 Mon, 05 Oct 2026 16:58:52 -0400 (EDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1791233931;
 bh=2zyFJFPPWQNaAgmKQT+aC83OeWe2Bc5FlLCi2cm7JuI=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=PEeRuDEfNne5zLGJHiDc00scStbyubT717VVSgSMb+7c/gaXC2aGeA9e4n3zNxUtK
 Fkab+chFk7uRTVS/EL7CQpeFVPIMAY0mfrIYCHRgMWEKH47E5OPXW4onWAVfHl6QFn
 3j/fESZTG/5ls3Ubxofoo0BORABa9TfpUaqlkr/rfzhZ4pQjQvqt37cHL1whIg28M1
 SUYQ3dP2oRhayyLuBc9rmQYSPngLj+Qr8D8H21PPcAmNm3riZjD7vgyNUOJo8f13fJ
 GpNqe8xSjaFO0b2HXwxQ7dkbTs9nkRBVx0soLtH5YkXQwhDM+eUb0dyG2zvnyLemKm
 QaPpbesMTRrHw==
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id EDABD442398;
 Mon, 05 Oct 2026 16:58:50 -0400 (EDT)
Received: from alfajor (unknown [10.34.230.255])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id D910A120234;
 Mon,  5 Oct 2026 16:58:50 -0400 (EDT)
From: Stefan Monnier <monnier@HIDDEN>
To: Jeff Trull <edaskel@HIDDEN>
Subject: Re: bug#81970: peg.el: "if" construct moves point
In-Reply-To: <1148247025.642123.1791230562417@HIDDEN>
Message-ID: <jwvik3feuj9.fsf-monnier+emacs@HIDDEN>
References: <CAF_DUeFtCcdvkNP_R9NOzzBpAcpxOgkVsxyEApn9DJmjxDoy7A.ref@HIDDEN>
 <CAF_DUeFtCcdvkNP_R9NOzzBpAcpxOgkVsxyEApn9DJmjxDoy7A@HIDDEN>
 <jwvik3gf9b8.fsf-monnier+emacs@HIDDEN>
 <1148247025.642123.1791230562417@HIDDEN>
Date: Mon, 05 Oct 2026 16:58:49 -0400
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
X-SPAM-INFO: Spam detection results:  0
 ALL_TRUSTED                -1 Passed through trusted hosts only via SMTP
 AWL 0.000 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DKIM_SIGNED               0.1 Message has a DKIM or DK signature,
 not necessarily valid
 DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
 DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
 domain
 DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from
 domain
X-SPAM-LEVEL: 
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 81970
Cc: "81970 <at> debbugs.gnu.org" <81970 <at> debbugs.gnu.org>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

>>=A0 =A0 =A0(with-temp-buffer
>>=A0 =A0 =A0 =A0(insert "foobar")
>>=A0 =A0 =A0 =A0(goto-char (point-min))
>>=A0 =A0 =A0 =A0(list (peg-run (peg (if "foo") "fooba"))
>>=A0 =A0 =A0 =A0 =A0 =A0 =A0(- (point) (point-min))))
>>=A0
>> returns `(t 5)`, which shows that the `if` did not move point.
> Right, because it passes.

Not really, no: if `if` fails, it does not move point either (that's
case for pretty much all PEG primitives).

>> Hence, my question: what did you expect `(if "foo" "baz")` to do?
> Fail, and leave point at the beginning of the buffer.
> Note this is different fromwhat I expected (and "foo" "baz")

When `and` fails it also doesn't move point, so when `(if "foo" "bar")`
fails, then it behaves exactly like `(and "foo" "bar")`.

> "The if and not operators accept a parsing expression andinterpret it
> as a boolean,without moving point" sounded to me as though they would
> not move point regardless of which boolean value wasreturned.

That's the case.  The point motion you see doesn't come from `if` but
from `peg-run`.


=3D=3D=3D Stefan





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#81970; Package emacs. Full text available.

Message received at 81970 <at> debbugs.gnu.org:


Received: (at 81970) by debbugs.gnu.org; 5 Oct 2026 20:04:06 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Oct 05 16:04:05 2026
Received: from localhost ([127.0.0.1]:44134 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1xDoug-0008BV-Vk
	for submit <at> debbugs.gnu.org; Mon, 05 Oct 2026 16:04:05 -0400
Received: from sonic302-25.consmr.mail.ne1.yahoo.com ([66.163.186.151]:34416)
 by debbugs.gnu.org with esmtps
 (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2)
 (envelope-from <edaskel@HIDDEN>) id 1xDouT-0008AH-31
 for 81970 <at> debbugs.gnu.org; Mon, 05 Oct 2026 16:03:50 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=att.net; s=s1024;
 t=1791230613; bh=mCKy8qv23FrJfmzV3sezuLL5UxkbuizwqJ1gRXXFq20=;
 h=Date:From:To:Cc:In-Reply-To:References:Subject:From:Subject:Reply-To;
 b=z9eNs/dhhVeDtmXc6PIMDixp6gj+NZhbaMFU7TXh8U99VZeMwVztZG6TcQyGgyXhjt2iuXs4QThOFvSRByVE6w2QA6yLmgoawISjlAm3j7Gobh+AJ5YwJZsHQl0zTpgDzM1/nqx54RXaA5LmrQhyi/lY8P+ORAkAcxfED+5kqM4=
X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048;
 t=1791230613; bh=17HaTMbPI2fr7Gdn3n/Fb4bXFMt17WM54zhHxHcGzvP=;
 h=X-Sonic-MF:Date:From:To:Subject:From:Subject;
 b=fPfPElrnqro0IPstkvVE6Sq1PrPY67MoEoqPqjV+X1MR/lnQMF5Vgivi7S/l5GKDjiAV5pJzar6/toLRxCcb5KbeQiO86P4b0icdWRa79FbJOY7vGy4vTyuUpo5uNOyw6X+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Y0pUbwpkiU0GG633yw5F5r.HaEHCtEf6h7Ow7EWgcyR8Tzj7fXtnUnGqWZWE7ryr2P6WmvTJ
 hMbjfeaInhXNNewTSYZ2ph5FV477kRkcVghELOrBThMYJU8SwTlkV8HrXDk2Yo5eMa7Dq1Mk.xXG
 TZyT0CMVhMX8ac2J0HUR0q78.J1s6vuuZ9_EjESlNAaaLO.NtztZj5lZ8Vl0Qynzv8HtOCRtNohS
 9XKLMbMc4M1VYHV54zmizdVVvPB_holG9L0JHqko8E4muWEqH9UCsz4Dfu33szrbO2q37habyoIm
 iZrLUwGMmyGwxs08YB8v0m0fov1yJqmpVbA6MKN75UV9ymnzh8m3fdMLChuHhaKKqAUA5Uo_Hiok
 iNU16Y2bKkuxjcAC3B9iq8jOmH03Kr6qKREe7Ve5X1j6ryuyMb2joXX7V8uutGIbG1f4j4ZTY
X-Sonic-MF: <edaskel@HIDDEN>
X-Sonic-ID: 3f0f1d2a-fd09-46d6-9278-b4a32e40f0a3
Received: from sonic.gate.mail.ne1.yahoo.com by
 sonic302.consmr.mail.ne1.yahoo.com with HTTP; Mon, 5 Oct 2026 20:03:33 +0000
Date: Mon, 5 Oct 2026 20:02:42 +0000 (UTC)
From: Jeff Trull <edaskel@HIDDEN>
To: Stefan Monnier <monnier@HIDDEN>
Message-ID: <1148247025.642123.1791230562417@HIDDEN>
In-Reply-To: <jwvik3gf9b8.fsf-monnier+emacs@HIDDEN>
References: <CAF_DUeFtCcdvkNP_R9NOzzBpAcpxOgkVsxyEApn9DJmjxDoy7A.ref@HIDDEN>
 <CAF_DUeFtCcdvkNP_R9NOzzBpAcpxOgkVsxyEApn9DJmjxDoy7A@HIDDEN>
 <jwvik3gf9b8.fsf-monnier+emacs@HIDDEN>
Subject: Re: bug#81970: peg.el: "if" construct moves point
MIME-Version: 1.0
Content-Type: multipart/alternative; 
 boundary="----=_Part_642122_923080716.1791230562415"
X-Mailer: WebService/1.1.26668 YMailNorrin
Content-Length: 13617
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 81970
Cc: "81970 <at> debbugs.gnu.org" <81970 <at> debbugs.gnu.org>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

------=_Part_642122_923080716.1791230562415
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

 Hi Stefan! I was hoping you would chime in.
This is my second time using peg.el in a project and I've found it very use=
ful.Clearly my understanding of it is incomplete. I'll describe briefly my =
originalinterpretation of the docs, and then answer your specific questions=
.
Basically, I assumed that in the PEX Definitions page, everything described=
 after
"The following expressions are used as anchors or tests =E2=80=93 they *do =
notmove point*,but return a boolean value which can be used to constrainmat=
ches as a way ofcontrolling the parsing process" [emphasis mine].
This is reemphasized in the descriptions of "if" and "not" ("point is not m=
oved").
In my application this was a useful property, so I wrote some code with "if=
" and"not" assuming that in *all* circumstances, pass or fail, point would =
be in an expectedplace. Root-causing that resulted in this bug report.


   On Monday, October 5, 2026 at 11:49:58 AM EDT, Stefan Monnier <monnier@i=
ro.umontreal.ca> wrote: =20
=20
  > > Returns non-nil if parsing PEX e from point succeeds (point is not mo=
ved)
> > In fact, point may sometimes be moved. Consider this code:
> >
> > (with-temp-buffer
> >=C2=A0 (insert "foobar")
> >=C2=A0 (beginning-of-buffer)
> >=C2=A0 (peg-run (peg (if "foo" "baz")))
> >=C2=A0 (point))
>=C2=A0
> What do you expect this to do?
What I formerly expected it to do is: fail, and not move point. I still kin=
d of preferthat, but I can see that's not how it was intended.
> Notice that `(if "foo" "bar")` here should behave pretty much like
> `(if "foobar")`
>=C2=A0
> > The position 4 (immediately following "foo") is returned.
>=C2=A0
The position 4 is returned by with-temp-buffer, not peg-run. I apologize fo=
r theambiguity. The point (hah!) was for the testcase to show that point ha=
d moved,which I thought was erroneous. I imagined readers would evaluate th=
e fullexpression in e.g. a Lisp buffer.
> As explained by Helmut, this is not the case: nil is returned because
> the parse fails, and point is moved to right after "foo" because that's
> our best guess as to where the parsing failed.
That is consistent with the other expressions and I can see that's what was=
 intended, now.
>=C2=A0
> Notice also that
>=C2=A0
>=C2=A0 =C2=A0 =C2=A0(with-temp-buffer
>=C2=A0 =C2=A0 =C2=A0 =C2=A0(insert "foobar")
>=C2=A0 =C2=A0 =C2=A0 =C2=A0(goto-char (point-min))
>=C2=A0 =C2=A0 =C2=A0 =C2=A0(list (peg-run (peg (if "foo") "fooba"))
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(- (point) (point-min))))
>=C2=A0
> returns `(t 5)`, which shows that the `if` did not move point.
Right, because it passes. I was assuming that was also true when it fails.I=
 thought that "if" and "not" were special in this way, compared to other co=
nstructs.
> So I think the problem here is one of misunderstanding.
For sure.
>=C2=A0
> Hence, my question: what did you expect `(if "foo" "baz")` to do?
Fail, and leave point at the beginning of the buffer. Note this is differen=
t fromwhat I expected
(and "foo" "baz")
to do, which is to fail and leave point after "foo" - as it does.
> Bonus points if you can help us find which part of the doc lead
> you to this misunderstanding.
It's hard to say, given that this confusion is in my own head, and others m=
ay read the docsdifferently. But I think that in the PEX Definitions page, =
the bit about:
"they do notmove point, but return a boolean value which can be used to con=
strainmatches"
and in Writing PEG Rules:
"The if and not operators accept a parsing expression andinterpret it as a =
boolean,without moving point"
sounded to me as though they would not move point regardless of which boole=
an value wasreturned. I understand now that this is only the case for a non=
-nil return value.=C2=A0 I'm not sureif there is a way to express this bett=
er, but maybe de-emphasizing (or qualifying) thenot-moving-point bits would=
 help.
I think this bug can be either closed as user error, or turned into a docum=
entation issue ifyou think that's warranted. Thanks for your help.
Best,Jeff



 =20
------=_Part_642122_923080716.1791230562415
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<html><head></head><body><div class=3D"ydp5d9fcc15yahoo-style-wrap" style=
=3D"font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:13px=
;" dir=3D"ltr" data-setdir=3D"false"><div></div>
        <div dir=3D"ltr" data-setdir=3D"false">Hi Stefan! I was hoping you =
would chime in.</div><div dir=3D"ltr" data-setdir=3D"false"><br></div><div =
dir=3D"ltr" data-setdir=3D"false">This is my second time using peg.el in a =
project and I've found it very useful.</div><div dir=3D"ltr" data-setdir=3D=
"false">Clearly my understanding of it is incomplete. I'll describe briefly=
 my original</div><div dir=3D"ltr" data-setdir=3D"false">interpretation of =
the docs, and then answer your specific questions.</div><div dir=3D"ltr" da=
ta-setdir=3D"false"><br></div><div dir=3D"ltr" data-setdir=3D"false">Basica=
lly, I assumed that in the PEX Definitions page, everything described after=
</div><div dir=3D"ltr" data-setdir=3D"false"><br></div><div dir=3D"ltr" dat=
a-setdir=3D"false">"<span>The following expressions are used as anchors or =
tests =E2=80=93 they *do not
move point*,</span></div><div dir=3D"ltr" data-setdir=3D"false"><span>but r=
eturn a boolean value which can be used to constrain
matches as a way of</span></div><div dir=3D"ltr" data-setdir=3D"false"><spa=
n>controlling the parsing process" [emphasis mine].</span></div><div dir=3D=
"ltr" data-setdir=3D"false"><span><br></span></div><div dir=3D"ltr" data-se=
tdir=3D"false"><span>This is reemphasized in the descriptions of "if" and "=
not" ("point is not moved").</span></div><div dir=3D"ltr" data-setdir=3D"fa=
lse"><span><br></span></div>In my application this was a useful property, s=
o I wrote some code with "if" and</div><div class=3D"ydp5d9fcc15yahoo-style=
-wrap" style=3D"font-family:Helvetica Neue, Helvetica, Arial, sans-serif;fo=
nt-size:13px;" dir=3D"ltr" data-setdir=3D"false">"not" assuming that in *al=
l* circumstances, pass or fail, point would be in an expected</div><div cla=
ss=3D"ydp5d9fcc15yahoo-style-wrap" style=3D"font-family:Helvetica Neue, Hel=
vetica, Arial, sans-serif;font-size:13px;" dir=3D"ltr" data-setdir=3D"false=
">place. Root-causing that resulted in this bug report.</div><div class=3D"=
ydp5d9fcc15yahoo-style-wrap" style=3D"font-family:Helvetica Neue, Helvetica=
, Arial, sans-serif;font-size:13px;" dir=3D"ltr" data-setdir=3D"false"><br>=
</div><div class=3D"ydp5d9fcc15yahoo-style-wrap" style=3D"font-family:Helve=
tica Neue, Helvetica, Arial, sans-serif;font-size:13px;" dir=3D"ltr" data-s=
etdir=3D"false"><br></div><div class=3D"ydp5d9fcc15yahoo-style-wrap" style=
=3D"font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:13px=
;" dir=3D"ltr" data-setdir=3D"false"><br></div><div id=3D"ydp61144ea2yahoo_=
quoted_1457898800" class=3D"ydp61144ea2yahoo_quoted">
            <div style=3D"font-family:'Helvetica Neue', Helvetica, Arial, s=
ans-serif;font-size:13px;color:#26282a;">
               =20
                <div>
                        On Monday, October 5, 2026 at 11:49:58 AM EDT, Stef=
an Monnier &lt;monnier@HIDDEN&gt; wrote:
                    </div>
                    <div><br></div>
                    <div><br></div>
               =20
               =20
                <div dir=3D"ltr" data-setdir=3D"false"> <div>&gt; &gt; Retu=
rns non-nil if parsing PEX e from point succeeds (point is not moved)<br>&g=
t; &gt; In fact, point may sometimes be moved. Consider this code:<br>&gt; =
&gt;<br>&gt; &gt; (with-temp-buffer<br>&gt; &gt;&nbsp; (insert "foobar")<br=
>&gt; &gt;&nbsp; (beginning-of-buffer)<br>&gt; &gt;&nbsp; (peg-run (peg (if=
 "foo" "baz")))<br>&gt; &gt;&nbsp; (point))<br>&gt;&nbsp;<br>&gt; What do y=
ou expect this to do?</div><div><br></div><div dir=3D"ltr" data-setdir=3D"f=
alse">What I formerly expected it to do is: fail, and not move point. I sti=
ll kind of prefer</div><div dir=3D"ltr" data-setdir=3D"false">that, but I c=
an see that's not how it was intended.</div><div dir=3D"ltr" data-setdir=3D=
"false"><br>&gt; Notice that `(if "foo" "bar")` here should behave pretty m=
uch like<br>&gt; `(if "foobar")`<br>&gt;&nbsp;<br>&gt; &gt; The position 4 =
(immediately following "foo") is returned.<br>&gt;&nbsp;</div><div dir=3D"l=
tr" data-setdir=3D"false"><br></div><div dir=3D"ltr" data-setdir=3D"false">=
The position 4 is returned by with-temp-buffer, not peg-run. I apologize fo=
r the</div><div dir=3D"ltr" data-setdir=3D"false">ambiguity. The point (hah=
!) was for the testcase to show that point had moved,</div><div dir=3D"ltr"=
 data-setdir=3D"false">which I thought was erroneous. I imagined readers wo=
uld evaluate the full</div><div dir=3D"ltr" data-setdir=3D"false">expressio=
n in e.g. a Lisp buffer.</div><div dir=3D"ltr" data-setdir=3D"false"><br>&g=
t; As explained by Helmut, this is not the case: nil is returned because<br=
>&gt; the parse fails, and point is moved to right after "foo" because that=
's<br>&gt; our best guess as to where the parsing failed.</div><div dir=3D"=
ltr" data-setdir=3D"false"><br></div><div dir=3D"ltr" data-setdir=3D"false"=
>That is consistent with the other expressions and I can see that's what wa=
s intended, now.<br>&gt;&nbsp;<br>&gt; Notice also that<br>&gt;&nbsp;<br>&g=
t;&nbsp; &nbsp; &nbsp;(with-temp-buffer<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp;(=
insert "foobar")<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp;(goto-char (point-min))<=
br>&gt;&nbsp; &nbsp; &nbsp; &nbsp;(list (peg-run (peg (if "foo") "fooba"))<=
br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(- (point) (point-mi=
n))))<br>&gt;&nbsp;<br>&gt; returns `(t 5)`, which shows that the `if` did =
not move point.</div><div dir=3D"ltr" data-setdir=3D"false"><br></div><div =
dir=3D"ltr" data-setdir=3D"false">Right, because it passes. I was assuming =
that was also true when it fails.</div><div dir=3D"ltr" data-setdir=3D"fals=
e">I thought that "if" and "not" were special in this way, compared to othe=
r constructs.</div><div dir=3D"ltr" data-setdir=3D"false"><br>&gt; So I thi=
nk the problem here is one of misunderstanding.</div><div dir=3D"ltr" data-=
setdir=3D"false"><br></div><div dir=3D"ltr" data-setdir=3D"false">For sure.=
</div><div dir=3D"ltr" data-setdir=3D"false"><br>&gt;&nbsp;<br>&gt; Hence, =
my question: what did you expect `(if "foo" "baz")` to do?</div><div dir=3D=
"ltr" data-setdir=3D"false"><br></div><div dir=3D"ltr" data-setdir=3D"false=
">Fail, and leave point at the beginning of the buffer. Note this is differ=
ent from</div><div dir=3D"ltr" data-setdir=3D"false">what I expected</div><=
div dir=3D"ltr" data-setdir=3D"false"><br></div><div dir=3D"ltr" data-setdi=
r=3D"false">(and "foo" "baz")</div><div dir=3D"ltr" data-setdir=3D"false"><=
br></div><div dir=3D"ltr" data-setdir=3D"false">to do, which is to fail and=
 leave point after "foo" - as it does.</div><div dir=3D"ltr" data-setdir=3D=
"false"><br>&gt; Bonus points if you can help us find which part of the doc=
 lead<br>&gt; you to this misunderstanding.</div><div dir=3D"ltr" data-setd=
ir=3D"false"><br></div><div dir=3D"ltr" data-setdir=3D"false">It's hard to =
say, given that this confusion is in my own head, and others may read the d=
ocs</div><div dir=3D"ltr" data-setdir=3D"false">differently. But I think th=
at in the PEX Definitions page, the bit about:</div><div dir=3D"ltr" data-s=
etdir=3D"false"><br></div><div dir=3D"ltr" data-setdir=3D"false">"<span>the=
y do not
move point, but return a boolean value which can be used to constrain
matches"</span></div><div dir=3D"ltr" data-setdir=3D"false"><span><br></spa=
n></div><div dir=3D"ltr" data-setdir=3D"false"><span>and in Writing PEG Rul=
es:</span></div><div dir=3D"ltr" data-setdir=3D"false"><span><br></span></d=
iv><div dir=3D"ltr" data-setdir=3D"false"><span>"<span>The <code class=3D"y=
dp6f60898dcode">if</code> and <code class=3D"ydp6f60898dcode">not</code> op=
erators accept a parsing expression and
interpret it as a boolean,</span></span></div><div dir=3D"ltr" data-setdir=
=3D"false"><span><span>without moving point</span>"</span></div><div dir=3D=
"ltr" data-setdir=3D"false"><span><br></span></div><div dir=3D"ltr" data-se=
tdir=3D"false">sounded to me as though they would not move point regardless=
 of which boolean value was</div><div dir=3D"ltr" data-setdir=3D"false">ret=
urned. I understand now that this is only the case for a non-nil return val=
ue.&nbsp; I'm not sure</div><div dir=3D"ltr" data-setdir=3D"false">if there=
 is a way to express this better, but maybe de-emphasizing (or qualifying) =
the</div><div dir=3D"ltr" data-setdir=3D"false">not-moving-point bits would=
 help.</div><div dir=3D"ltr" data-setdir=3D"false"><br></div><div dir=3D"lt=
r" data-setdir=3D"false">I think this bug can be either closed as user erro=
r, or turned into a documentation issue if</div><div dir=3D"ltr" data-setdi=
r=3D"false">you think that's warranted. Thanks for your help.</div><div dir=
=3D"ltr" data-setdir=3D"false"><br></div><div dir=3D"ltr" data-setdir=3D"fa=
lse">Best,</div><div dir=3D"ltr" data-setdir=3D"false">Jeff</div><div dir=
=3D"ltr" data-setdir=3D"false"><br></div><div dir=3D"ltr" data-setdir=3D"fa=
lse"><br></div><div dir=3D"ltr" data-setdir=3D"false"><br></div><div dir=3D=
"ltr"><br></div></div>
            </div>
        </div></body></html>
------=_Part_642122_923080716.1791230562415--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#81970; Package emacs. Full text available.

Message received at 81970 <at> debbugs.gnu.org:


Received: (at 81970) by debbugs.gnu.org; 5 Oct 2026 15:50:04 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Oct 05 11:50:04 2026
Received: from localhost ([127.0.0.1]:53708 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1xDkx1-0003N0-Nk
	for submit <at> debbugs.gnu.org; Mon, 05 Oct 2026 11:50:04 -0400
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:30377)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <monnier@HIDDEN>)
 id 1xDkwz-0003M4-02
 for 81970 <at> debbugs.gnu.org; Mon, 05 Oct 2026 11:50:01 -0400
Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1])
 by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 1FAB1441992;
 Mon, 05 Oct 2026 11:49:55 -0400 (EDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1791215394;
 bh=+q9EQjeYKixUWEYKvHZgJSXmoqaqnq4zWQCnXjreGFc=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=bkiDTddy239jlV4uWS3w5ocapgW+PHUEOXuLUXWvqaLSycfRP5g5E+WF9z3jI8M9Z
 /8aVCr4DCRwS4Y4BJIDVbG4y4o8trAILFjrADhB9+5cpaXO5j7tFAQkDrj41WY7mnr
 /KnJ6o9Lm/27JKzZ4gq+eM6NAFi3X/tGz9wmZgKPylbZefvW+Kz0bwo96j5VDdYDJq
 WR2VohPiY1crZx3izFX7gFjBNSD2y2QHujEsOqWlAOq8sJPMzYzCbHFid4fz05ob+i
 7e6wm/IOjbtYEcJ/NcqgczSTA/3tl6EsbJPMaNXIk/AlODNcK6dWUgYz9bApgF1QTC
 c3M+njNmNbg7Q==
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 1430C441A4B;
 Mon, 05 Oct 2026 11:49:54 -0400 (EDT)
Received: from alfajor (modemcable181.99-80-70.mc.videotron.ca [70.80.99.181])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id EA50A1203CE;
 Mon,  5 Oct 2026 11:49:53 -0400 (EDT)
From: Stefan Monnier <monnier@HIDDEN>
To: Jeff Trull <edaskel@HIDDEN>
Subject: Re: bug#81970: peg.el: "if" construct moves point
In-Reply-To: <CAF_DUeFtCcdvkNP_R9NOzzBpAcpxOgkVsxyEApn9DJmjxDoy7A@HIDDEN>
Message-ID: <jwvik3gf9b8.fsf-monnier+emacs@HIDDEN>
References: <CAF_DUeFtCcdvkNP_R9NOzzBpAcpxOgkVsxyEApn9DJmjxDoy7A.ref@HIDDEN>
 <CAF_DUeFtCcdvkNP_R9NOzzBpAcpxOgkVsxyEApn9DJmjxDoy7A@HIDDEN>
Date: Mon, 05 Oct 2026 11:49:53 -0400
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-SPAM-INFO: Spam detection results:  0
 ALL_TRUSTED                -1 Passed through trusted hosts only via SMTP
 AWL 0.148 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DKIM_SIGNED               0.1 Message has a DKIM or DK signature,
 not necessarily valid
 DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
 DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
 domain
 DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from
 domain
X-SPAM-LEVEL: 
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 81970
Cc: 81970 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Returns non-nil if parsing PEX e from point succeeds (point is not moved)
> In fact, point may sometimes be moved. Consider this code:
>
> (with-temp-buffer
>   (insert "foobar")
>   (beginning-of-buffer)
>   (peg-run (peg (if "foo" "baz")))
>   (point))

What do you expect this to do?
Notice that `(if "foo" "bar")` here should behave pretty much like
`(if "foobar")`

> The position 4 (immediately following "foo") is returned.

As explained by Helmut, this is not the case: nil is returned because
the parse fails, and point is moved to right after "foo" because that's
our best guess as to where the parsing failed.

Notice also that

    (with-temp-buffer
      (insert "foobar")
      (goto-char (point-min))
      (list (peg-run (peg (if "foo") "fooba"))
            (- (point) (point-min))))

returns `(t 5)`, which shows that the `if` did not move point.
So I think the problem here is one of misunderstanding.

Hence, my question: what did you expect `(if "foo" "baz")` to do?
Bonus points if you can help us find which part of the doc lead
you to this misunderstanding.


=== Stefan





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#81970; Package emacs. Full text available.

Message received at 81970 <at> debbugs.gnu.org:


Received: (at 81970) by debbugs.gnu.org; 3 Oct 2026 08:14:47 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Oct 03 04:14:45 2026
Received: from localhost ([127.0.0.1]:46404 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1xCutD-0003kr-6A
	for submit <at> debbugs.gnu.org; Sat, 03 Oct 2026 04:14:42 -0400
Received: from mail-wr2-x10.google.com ([2a00:1450:4864:30::10]:47599)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <eller.helmut@HIDDEN>)
 id 1xCut6-0003kK-Ei
 for 81970 <at> debbugs.gnu.org; Sat, 03 Oct 2026 04:14:35 -0400
Received: by mail-wr2-x10.google.com with SMTP id
 ffacd0b85a97d-4834977ae75so76218f8f.3
 for <81970 <at> debbugs.gnu.org>; Sat, 03 Oct 2026 01:14:32 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20251104; t=1791015266; x=1791620066; darn=debbugs.gnu.org;
 h=content-transfer-encoding:content-type:mime-version:user-agent
 :message-id:date:references:in-reply-to:subject:cc:to:from:from:to
 :cc:subject:date:message-id:reply-to:content-type;
 bh=EqvuJ83GD8lCfEAacgrxU8QcxyNFesND78queVnhMvU=;
 b=XKcpK98GiPbLdpFad8GPkCE4m4268V0t5NNvA6VpKV54Vl4pxWFwfF9xJFT14GfdeP
 pCxoV+inkBjyjSyG2D2bmwHBT101UH0Sd63IXCGc0rqThBz21L0J1eo5Cfx0nqo/bvJ0
 xOxOGsadWdz6nj2gNkQvCq4PGUSsCPlx/kdljTXiCdhdbFRlheRLDU2MmwFygiBF0Fs4
 9cYi89h2C8b1snV3GULrjXzIghBwSHc2oR7+d9SzJzboHCr2M12F3nqIHPc+so+3JkgA
 1P/qz0ptLPuACWudUtK0LQ4QfrMTPiwOPDSS8e44cxRJBVhedQWeJfXzFN5U3+gyoyjk
 Py4Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20260707; t=1791015266; x=1791620066;
 h=content-transfer-encoding:content-type:mime-version:user-agent
 :message-id:date:references:in-reply-to:subject:cc:to:from:x-gm-gg
 :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to
 :content-type;
 bh=EqvuJ83GD8lCfEAacgrxU8QcxyNFesND78queVnhMvU=;
 b=rlHxfc7A9eyYV3DfGcxvK/o6enRxHXUCuolzOpKe/FC7VvALH24XKpRM2GrW0jTR6Y
 TeSpUPBWE5Lccr8tTGIKGoVAR+B1I4pO/ipqgQh/cx2wGtKw7yo6f32KTo1SP8pGkYw4
 2cnlbWCEQ04X/MpDW2YayG+1zXVlBUlszGbUGbQmMoRaDtZl+7OjSy13q3/0p0vzCnbx
 YzNgFBVRHOgPkQzsraDDltF3yYcBLa6l8KB84/N/EMCtNltzfGHCJLj7M7GHECDzKb7u
 zYpFtfEWSdnDKp13f9DG9zGsrmMXSdJXJ7u0IANWQiJqIqEihzv4T1zoS1YChu7iwE/S
 p/og==
X-Gm-Message-State: AFq9FYLsqi7MTF6OEv4Q1Aq0PGlAHnr4IXdpzLlxY/5LtrBv1Fll03MQ
 0C1iTKO+olP4J8efFvfiQ2ajR609NBgY++73GEY8RHh7bVLhxNOhwPkEptgP+w==
X-Gm-Gg: AYBFou1hr7TMbO6CI6njf3s2a9CjINpgCWarhByWJcmIS6qCNcWu8w6HyDHrgcydTPK
 rec3tUKWzYgq7GAaP+6famGZwD66YpBQ40k5/jb59hxLoLxFXfVKS6pzIKe/3F5Z0R7XqXuEgaL
 khZHS4IPZAuhfY/WgWV65dl0LLF/RlI5ooZWfcX7CDJRaeGGFzYY7dLjg+qAA7UnkDOtjz+dJ5o
 4iuA0cUp6Qfp+q0k1sm1vhqHjWpmSvI1TJOB2l4iXOqxxrrpV0yvXd4deEwOZCXPphmgR5x6WpV
 42KU73Nf8TBVglnNG1qJGYoUajhjgdHrDpj3g0UnoJJqcRVh12XghoQAGWpJ7R0BihYPaVnPxnh
 lk8JDyMgqI2gTF98ffYEMk1VulySEN0y/oge4wyyVebLyK5vPc/6okte3X4c3u0mQ7ejYw3yoAi
 2VaZTUuCvp0/V6yWkTsAv7Slzkdt7ZF+hIHivSNiPaX+tqgm5NnM3dCCKdJG2742SHh0Vr8lumC
 AcKvbxAYw37LefBhNWGFfd8XaX0
X-Received: by 2002:a05:6000:981:b0:487:40a:5ba8 with SMTP id
 ffacd0b85a97d-48b12739890mr8831760f8f.15.1791015265878; 
 Sat, 03 Oct 2026 01:14:25 -0700 (PDT)
Received: from hessra (dial-189137.pool.broadband44.net. [212.46.189.137])
 by smtp.gmail.com with ESMTPSA id
 ffacd0b85a97d-48b382f9bc0sm10964561f8f.41.2026.10.03.01.14.25
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 03 Oct 2026 01:14:25 -0700 (PDT)
From: Helmut Eller <eller.helmut@HIDDEN>
To: Jeff Trull <edaskel@HIDDEN>
Subject: Re: bug#81970: peg.el: "if" construct moves point
In-Reply-To: <CAF_DUeH4dSeH60B9qtT2ETYJW12qCk3fz5VO5VPwRfifDVTbyw@HIDDEN>
References: <CAF_DUeFtCcdvkNP_R9NOzzBpAcpxOgkVsxyEApn9DJmjxDoy7A.ref@HIDDEN>
 <CAF_DUeFtCcdvkNP_R9NOzzBpAcpxOgkVsxyEApn9DJmjxDoy7A@HIDDEN>
 <87bj9c8450.fsf@HIDDEN>
 <CAF_DUeFczpGNNga=Up-NVydy6DhATt3JxTJMfqC4xQUZB3rTZA@HIDDEN>
 <CAF_DUeH4dSeH60B9qtT2ETYJW12qCk3fz5VO5VPwRfifDVTbyw@HIDDEN>
Date: Sat, 03 Oct 2026 10:14:24 +0200
Message-ID: <8733un8alb.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: 81970
Cc: 81970 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.0 (/)

On Fri, Oct 02 2026, Jeff Trull wrote:

> On Fri, Oct 2, 2026, 5:18=E2=80=AFPM Jeff Trull <edaskel@HIDDEN> wrote:
>
>  On Fri, Oct 2, 2026, 12:21=E2=80=AFPM Helmut Eller <eller.helmut@HIDDEN=
om>
>  wrote:
>
>  On Thu, Oct 01 2026, Jeff Trull via "Bug reports for GNU Emacs, the
>  Swiss army knife of text editors" wrote:
>
>  > In PEG, an "if" expression is defined in the Elisp manual as:
>  >
>  > Returns non-nil if parsing PEX e from point succeeds (point is not
>  moved)
>  >
>  > In fact, point may sometimes be moved. Consider this code:
>  >
>  > (with-temp-buffer
>  >   (insert "foobar")
>  >   (beginning-of-buffer)
>  >   (peg-run (peg (if "foo" "baz")))
>  >   (point))
>  >
>  > The position 4 (immediately following "foo") is returned.
>
>  Note that in this example peg-run returns nil.  That means that the
>  part
>  of the documentation that you quoted does not apply.
>
>  If a match fails (as in the example), peg-run leaves point where the
>  parse failed.
>
>  In other words: the example works as intended.
>
>  Helmut
>
>  Can you check again? In my session (31.1) peg-run returns 4 (the
>  position following the partial match), not nil.
>
> Apologies yes, peg-run returns nil in this case. But point is left at 4, =
the
> position following the partial match. peg-run is behaving properly - "if"=
 is
> not.

I don't know how to explain why "if" is correct other than repeat
myself.  The docstring of peg-run says:

  If no match was found, move to the (rightmost) point of parse failure
  and call FAILURE-FUNCTION with one argument, which is a list of PEG
  expressions that failed at this point.

Helmut




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#81970; Package emacs. Full text available.

Message received at 81970 <at> debbugs.gnu.org:


Received: (at 81970) by debbugs.gnu.org; 2 Oct 2026 21:22:35 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Oct 02 17:22:35 2026
Received: from localhost ([127.0.0.1]:41593 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1xCkiB-0007S0-AJ
	for submit <at> debbugs.gnu.org; Fri, 02 Oct 2026 17:22:35 -0400
Received: from sonic314-24.consmr.mail.ne1.yahoo.com ([66.163.189.150]:40884)
 by debbugs.gnu.org with esmtps
 (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2)
 (envelope-from <edaskel@HIDDEN>) id 1xCki8-0007Rf-OB
 for 81970 <at> debbugs.gnu.org; Fri, 02 Oct 2026 17:22:33 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=att.net; s=s1024;
 t=1790976146; bh=FqRbqxiJJV6VyylEHKXAEcIY2gxqYQUxkbv/AjEkmZs=;
 h=References:In-Reply-To:From:Date:Subject:To:Cc:From:Subject:Reply-To;
 b=lKwoTTJrgZG443luS9bx2Zv+TCQsmShPS/cBWAEx0F8h3X/HGA4o3BeiBch0QQC9k4c57QKQSWIte2mrtJ6OvtwTLtrs+OlxNHVU8L0zGpK3U6G31nAvK4Z3sZ1vIaHYu943YVP1uaiTv0oA+EFXfSwjK9vs+6SBo7TPv25ADy0=
X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048;
 t=1790976146; bh=+IoSaDwgVOxX8/1+dW08gUp5LP4k7RNartuhGrl7mbH=;
 h=X-Sonic-MF:From:Date:Subject:To:From:Subject;
 b=NyCbRwkiFZ8AA5DIbejoz2BniarN6xcE40xVW+SmZHDwqpRkG4dYqVrxOr7sPQe1OgvxSIzgbeozeakghv5MQgZMskTg7myRe9cGUnoSr1LW7gCUexTC4boQXxeWqHOqMfH9XrelYWv3FSsY5emhm+pG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8W_sOavEcO1mJD8I3zMfBO60gjAM4lqHdo48G0OQ7bmMHTZEo63LHBkia6m
 6qsZLjPlnp3VIW5xGzlfcU7JfRaE5M3gqK2Ab5dKPZennrf7wBc7v7l2H4qq0A3q0xGti7.0ZP09
 cxTJOnDBcI6ZzNXwLDftqJRJW_fx26kITKufqe3WT8Zp4cKKkRkmhVWJpnXjOFjrq1zbfliwgitt
 8w.yjfz5w11FPPqCf4.U3z2B4yam.IKRTFZDqxAZN4c.2ZI.Lh2MgKtOvz25E9ZTlxN_VlCzvMh8
 _Z.Z5Y10MhBvjAOSfesjtawg9jVnYbFcm3QZcS_1sSI_FTr9ErHpTaY5.f10wYwSkwn3r62IoiU6
 aJxIZO6LQM5S83HKnu9D4REmBZETWfC5shs3Zx1GDsuqjSfYfF8DQIzkzuWbVqOrRqeF53_O_qFC
 MWoQ-
X-Sonic-MF: <edaskel@HIDDEN>
X-Sonic-ID: 85bbff5c-926d-4489-ab7d-b43ae37c4c9c
Received: from sonic.gate.mail.ne1.yahoo.com by
 sonic314.consmr.mail.ne1.yahoo.com with HTTP; Fri, 2 Oct 2026 21:22:26 +0000
Received: by hermes--production-bf1-6d6877594b-7khjh (Yahoo Inc. Hermes SMTP
 Server) with ESMTPA ID 02da19eea20783523587ad02fde2c596; 
 Fri, 02 Oct 2026 21:22:22 +0000 (UTC)
Received: by mail-yx2-f43.google.com with SMTP id
 00721157ae682-895353e9051so103267b3.0
 for <81970 <at> debbugs.gnu.org>; Fri, 02 Oct 2026 14:22:22 -0700 (PDT)
X-Gm-Message-State: AFq9FYLXnWP/Hc7cNyDXJth7+a/lgUYR+JNBbc4aMXj2fTQzcLaEC5WT
 XptezOckql5F1H268ro57uMd0Rg1pDFwDkQ+gZR+/hlwVfIbstZKcZJEdhXYen2IWUEaiUDiSL/
 6v2Naa2eleik+ZOR/RcyNMKu3WFV1bZQ=
X-Received: by 2002:a05:690c:c50f:b0:8a8:4931:6198 with SMTP id
 00721157ae682-8ae39c149d9mr20067657b3.43.1790976141498; Fri, 02 Oct 2026
 14:22:21 -0700 (PDT)
MIME-Version: 1.0
References: <CAF_DUeFtCcdvkNP_R9NOzzBpAcpxOgkVsxyEApn9DJmjxDoy7A.ref@HIDDEN>
 <CAF_DUeFtCcdvkNP_R9NOzzBpAcpxOgkVsxyEApn9DJmjxDoy7A@HIDDEN>
 <87bj9c8450.fsf@HIDDEN>
 <CAF_DUeFczpGNNga=Up-NVydy6DhATt3JxTJMfqC4xQUZB3rTZA@HIDDEN>
In-Reply-To: <CAF_DUeFczpGNNga=Up-NVydy6DhATt3JxTJMfqC4xQUZB3rTZA@HIDDEN>
From: Jeff Trull <edaskel@HIDDEN>
Date: Fri, 2 Oct 2026 17:22:11 -0400
X-Gmail-Original-Message-ID: <CAF_DUeH4dSeH60B9qtT2ETYJW12qCk3fz5VO5VPwRfifDVTbyw@HIDDEN>
X-Gm-Features: AclHuK9KZRNLXZtAHSp4TQnsq50BZsPQIelWkinfA2n1G6HZTkUcIIhozjOt8hg
Message-ID: <CAF_DUeH4dSeH60B9qtT2ETYJW12qCk3fz5VO5VPwRfifDVTbyw@HIDDEN>
Subject: Re: bug#81970: peg.el: "if" construct moves point
To: Helmut Eller <eller.helmut@HIDDEN>
Content-Type: multipart/alternative; boundary="000000000000b7223a065ce220f1"
X-Mailer: WebService/1.1.26668
 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo
Content-Length: 4251
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 81970
Cc: 81970 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

--000000000000b7223a065ce220f1
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Fri, Oct 2, 2026, 5:18=E2=80=AFPM Jeff Trull <edaskel@HIDDEN> wrote:

>
>
> On Fri, Oct 2, 2026, 12:21=E2=80=AFPM Helmut Eller <eller.helmut@HIDDEN=
m> wrote:
>
>> On Thu, Oct 01 2026, Jeff Trull via "Bug reports for GNU Emacs, the Swis=
s
>> army knife of text editors" wrote:
>>
>> > In PEG, an "if" expression is defined in the Elisp manual as:
>> >
>> > Returns non-nil if parsing PEX e from point succeeds (point is not
>> moved)
>> >
>> > In fact, point may sometimes be moved. Consider this code:
>> >
>> > (with-temp-buffer
>> >   (insert "foobar")
>> >   (beginning-of-buffer)
>> >   (peg-run (peg (if "foo" "baz")))
>> >   (point))
>> >
>> > The position 4 (immediately following "foo") is returned.
>>
>> Note that in this example peg-run returns nil.  That means that the part
>> of the documentation that you quoted does not apply.
>>
>> If a match fails (as in the example), peg-run leaves point where the
>> parse failed.
>>
>> In other words: the example works as intended.
>>
>> Helmut
>>
>
> Can you check again? In my session (31.1) peg-run returns 4 (the position
> following the partial match), not nil.
>

Apologies yes, peg-run returns nil in this case. But point is left at 4,
the position following the partial match. peg-run is behaving properly -
"if" is not.

>

--000000000000b7223a065ce220f1
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"auto"><div><br><div class=3D"gmail_quote"><div dir=3D"ltr" clas=
s=3D"gmail_attr">On Fri, Oct 2, 2026, 5:18=E2=80=AFPM Jeff Trull &lt;<a hre=
f=3D"mailto:edaskel@HIDDEN" rel=3D"noreferrer noreferrer" target=3D"_blank=
">edaskel@HIDDEN</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote"=
 style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><d=
iv dir=3D"auto"><div><br><br><div class=3D"gmail_quote"><div dir=3D"ltr" cl=
ass=3D"gmail_attr">On Fri, Oct 2, 2026, 12:21=E2=80=AFPM Helmut Eller &lt;<=
a href=3D"mailto:eller.helmut@HIDDEN" rel=3D"noreferrer noreferrer noref=
errer" target=3D"_blank">eller.helmut@HIDDEN</a>&gt; wrote:<br></div><bl=
ockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #=
ccc solid;padding-left:1ex">On Thu, Oct 01 2026, Jeff Trull via &quot;Bug r=
eports for GNU Emacs, the Swiss army knife of text editors&quot; wrote:<br>
<br>
&gt; In PEG, an &quot;if&quot; expression is defined in the Elisp manual as=
:<br>
&gt;<br>
&gt; Returns non-nil if parsing PEX e from point succeeds (point is not mov=
ed)<br>
&gt;<br>
&gt; In fact, point may sometimes be moved. Consider this code:<br>
&gt;<br>
&gt; (with-temp-buffer<br>
&gt;=C2=A0 =C2=A0(insert &quot;foobar&quot;)<br>
&gt;=C2=A0 =C2=A0(beginning-of-buffer)<br>
&gt;=C2=A0 =C2=A0(peg-run (peg (if &quot;foo&quot; &quot;baz&quot;)))<br>
&gt;=C2=A0 =C2=A0(point))<br>
&gt;<br>
&gt; The position 4 (immediately following &quot;foo&quot;) is returned.<br=
>
<br>
Note that in this example peg-run returns nil.=C2=A0 That means that the pa=
rt<br>
of the documentation that you quoted does not apply.<br>
<br>
If a match fails (as in the example), peg-run leaves point where the<br>
parse failed.<br>
<br>
In other words: the example works as intended.<br>
<br>
Helmut<br></blockquote></div></div><div dir=3D"auto"><br></div><div dir=3D"=
auto">Can you check again? In my session (31.1) peg-run returns 4 (the posi=
tion following the partial match), not nil.</div></div></blockquote></div><=
/div><div dir=3D"auto"><br></div><div dir=3D"auto">Apologies yes, peg-run r=
eturns nil in this case. But point is left at 4, the position following the=
 partial match. peg-run is behaving properly - &quot;if&quot; is not.</div>=
<div dir=3D"auto"></div><div dir=3D"auto"><div class=3D"gmail_quote"><block=
quote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc=
 solid;padding-left:1ex"><div dir=3D"auto"><div dir=3D"auto"><div class=3D"=
gmail_quote"><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;b=
order-left:1px #ccc solid;padding-left:1ex">
</blockquote></div></div></div>
</blockquote></div>
</div></div>

--000000000000b7223a065ce220f1--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#81970; Package emacs. Full text available.

Message received at 81970 <at> debbugs.gnu.org:


Received: (at 81970) by debbugs.gnu.org; 2 Oct 2026 21:18:44 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Oct 02 17:18:44 2026
Received: from localhost ([127.0.0.1]:40980 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1xCkeS-00075y-AB
	for submit <at> debbugs.gnu.org; Fri, 02 Oct 2026 17:18:44 -0400
Received: from sonic309-24.consmr.mail.ne1.yahoo.com ([66.163.184.150]:39546)
 by debbugs.gnu.org with esmtps
 (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2)
 (envelope-from <edaskel@HIDDEN>) id 1xCkeQ-00075O-7I
 for 81970 <at> debbugs.gnu.org; Fri, 02 Oct 2026 17:18:42 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=att.net; s=s1024;
 t=1790975914; bh=UsPQiD2FiyeU+eV/cDwyDVCnXDqfHL1qdhOE3YqzVlo=;
 h=References:In-Reply-To:From:Date:Subject:To:Cc:From:Subject:Reply-To;
 b=0+8ujoMFEn3efb9IWvcYN5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j0opRvIpUJQ_Qm2Eyp7hQodPeRLsF5uw7pPHzdfu.Iq34vOMPnFc5o4YRkc5dQjPY
 Zjh1fjTKShn2vHwkjkVCRg2X5OhgEO_Op.nbjOOEb.1TWl8rut7mzIzDTgYKDPXOV1NtrLmZNkg0
 Kc4UiR7pkiAUda7cG52WkC9sn_yYk3oq7vhaDacwtB0gZkKpy7JnxeR8F2mF4JbAh3EBqwass5X8
 0hxsRiIzz7tYhGHJELrJumCvjeqvakeyNih_qnXnn_D6tOvcVUcVjZ5GovzvruORS6KW4sUUo9Md
 3_jxhtt0jeLtWUh0Bz4kHAQ2NEntGlnJ6npAt29IReQ7Po4gC53RnxA83nErLTethTJu4VLw2Pbh
 52Cir8915D2BvErkldWEQvhpx12eZF8xvh_mnRUFvk.mCfQBnUbO00IcoEweWmkFeIlIuJbhGhtd
 vrqElhggzRCob9qOtQKtrMQvcqtK72vzgI5Zyj4X0EH_OnG7O4g49qbGNcmwJV23V5kncLAZtlxD
 GG.Z1NkoMeeT72jBCsK52OLugPeM0SlT7eA6nLwT6DtvC.pJR_.6301ThmUEPrHs3PbI0OjZqceV
 nLZRdoekiORxEHWffDDL.gwzJeQ6bJfsBSaZdVVgyN7R8feEfpWKGHKfggz0VYBsclxQIm8CGyNL
 cjwP1_Ic5B0t0I2h8BjGxXgpmA4hvd6dOVnwYnA6MZCDGuFr3.T0XfpDlzb40HrbU_Ap8pFKE.0C
 iYsUBthgLt0spXtr23P64NY6TFclRE1ocVlKXyiBA1frW8WjPBtDpz.elP228._bWrJyQCOT1PlG
 Q3wtT33rsmVFp2zPzzyrW_.ZbTzKT_UVJoAt6YY.oGzN9lktki38Yv18quH1l1eS5h3AlhJodwsk
 vaDTYzpM-
X-Sonic-MF: <edaskel@HIDDEN>
X-Sonic-ID: 1d008025-d07a-4938-88be-d4ac1ff34cd2
Received: from sonic.gate.mail.ne1.yahoo.com by
 sonic309.consmr.mail.ne1.yahoo.com with HTTP; Fri, 2 Oct 2026 21:18:34 +0000
Received: by hermes--production-bf1-6d6877594b-nlk4k (Yahoo Inc. Hermes SMTP
 Server) with ESMTPA ID a98bb9b6f7ddc07895d871519c08f895; 
 Fri, 02 Oct 2026 21:18:31 +0000 (UTC)
Received: by mail-yw1-f182.google.com with SMTP id
 00721157ae682-8ac9d666d4eso4728917b3.3
 for <81970 <at> debbugs.gnu.org>; Fri, 02 Oct 2026 14:18:31 -0700 (PDT)
X-Gm-Message-State: AFq9FYLqLJkq5mQY7NL5OlrllbZv+3e5nVXPzykL32bY+FOlcbmTjnZs
 y+HJwJlz6WcVJyhrN04N8nDvUPp+iPTVRQkhxFFqdCQ0i42eiaquu8xIGtPEVif99XlqSXGwLQH
 EeTkz1XTmwbMnyPoK08NWhnP5Wgc9KnQ=
X-Received: by 2002:a05:690c:a786:b0:8ae:6740:9ae with SMTP id
 00721157ae682-8ae950f8e54mr3200297b3.79.1790975910484; Fri, 02 Oct 2026
 14:18:30 -0700 (PDT)
MIME-Version: 1.0
References: <CAF_DUeFtCcdvkNP_R9NOzzBpAcpxOgkVsxyEApn9DJmjxDoy7A.ref@HIDDEN>
 <CAF_DUeFtCcdvkNP_R9NOzzBpAcpxOgkVsxyEApn9DJmjxDoy7A@HIDDEN>
 <87bj9c8450.fsf@HIDDEN>
In-Reply-To: <87bj9c8450.fsf@HIDDEN>
From: Jeff Trull <edaskel@HIDDEN>
Date: Fri, 2 Oct 2026 17:18:21 -0400
X-Gmail-Original-Message-ID: <CAF_DUeFczpGNNga=Up-NVydy6DhATt3JxTJMfqC4xQUZB3rTZA@HIDDEN>
X-Gm-Features: AclHuK8nDifEmX1DY3A41_KqH9YVI3-FJ4u_h4I-doIKFlJfKr53I_LQ7CGmmnA
Message-ID: <CAF_DUeFczpGNNga=Up-NVydy6DhATt3JxTJMfqC4xQUZB3rTZA@HIDDEN>
Subject: Re: bug#81970: peg.el: "if" construct moves point
To: Helmut Eller <eller.helmut@HIDDEN>
Content-Type: multipart/alternative; boundary="000000000000f221df065ce212bc"
X-Mailer: WebService/1.1.26668
 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo
Content-Length: 3113
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 81970
Cc: 81970 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

--000000000000f221df065ce212bc
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Fri, Oct 2, 2026, 12:21=E2=80=AFPM Helmut Eller <eller.helmut@HIDDEN>=
 wrote:

> On Thu, Oct 01 2026, Jeff Trull via "Bug reports for GNU Emacs, the Swiss
> army knife of text editors" wrote:
>
> > In PEG, an "if" expression is defined in the Elisp manual as:
> >
> > Returns non-nil if parsing PEX e from point succeeds (point is not move=
d)
> >
> > In fact, point may sometimes be moved. Consider this code:
> >
> > (with-temp-buffer
> >   (insert "foobar")
> >   (beginning-of-buffer)
> >   (peg-run (peg (if "foo" "baz")))
> >   (point))
> >
> > The position 4 (immediately following "foo") is returned.
>
> Note that in this example peg-run returns nil.  That means that the part
> of the documentation that you quoted does not apply.
>
> If a match fails (as in the example), peg-run leaves point where the
> parse failed.
>
> In other words: the example works as intended.
>
> Helmut
>

Can you check again? In my session (31.1) peg-run returns 4 (the position
following the partial match), not nil.

--000000000000f221df065ce212bc
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"auto"><div><br><br><div class=3D"gmail_quote gmail_quote_contai=
ner"><div dir=3D"ltr" class=3D"gmail_attr">On Fri, Oct 2, 2026, 12:21=E2=80=
=AFPM Helmut Eller &lt;<a href=3D"mailto:eller.helmut@HIDDEN">eller.helm=
ut@HIDDEN</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" styl=
e=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Thu,=
 Oct 01 2026, Jeff Trull via &quot;Bug reports for GNU Emacs, the Swiss arm=
y knife of text editors&quot; wrote:<br>
<br>
&gt; In PEG, an &quot;if&quot; expression is defined in the Elisp manual as=
:<br>
&gt;<br>
&gt; Returns non-nil if parsing PEX e from point succeeds (point is not mov=
ed)<br>
&gt;<br>
&gt; In fact, point may sometimes be moved. Consider this code:<br>
&gt;<br>
&gt; (with-temp-buffer<br>
&gt;=C2=A0 =C2=A0(insert &quot;foobar&quot;)<br>
&gt;=C2=A0 =C2=A0(beginning-of-buffer)<br>
&gt;=C2=A0 =C2=A0(peg-run (peg (if &quot;foo&quot; &quot;baz&quot;)))<br>
&gt;=C2=A0 =C2=A0(point))<br>
&gt;<br>
&gt; The position 4 (immediately following &quot;foo&quot;) is returned.<br=
>
<br>
Note that in this example peg-run returns nil.=C2=A0 That means that the pa=
rt<br>
of the documentation that you quoted does not apply.<br>
<br>
If a match fails (as in the example), peg-run leaves point where the<br>
parse failed.<br>
<br>
In other words: the example works as intended.<br>
<br>
Helmut<br></blockquote></div></div><div dir=3D"auto"><br></div><div dir=3D"=
auto">Can you check again? In my session (31.1) peg-run returns 4 (the posi=
tion following the partial match), not nil.</div><div dir=3D"auto"><br></di=
v><div dir=3D"auto"><div class=3D"gmail_quote gmail_quote_container"><block=
quote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc=
 solid;padding-left:1ex">
</blockquote></div></div></div>

--000000000000f221df065ce212bc--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#81970; Package emacs. Full text available.

Message received at 81970 <at> debbugs.gnu.org:


Received: (at 81970) by debbugs.gnu.org; 2 Oct 2026 16:21:51 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Oct 02 12:21:50 2026
Received: from localhost ([127.0.0.1]:48950 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1xCg14-0000RU-WE
	for submit <at> debbugs.gnu.org; Fri, 02 Oct 2026 12:21:50 -0400
Received: from mail-wr2-x0f.google.com ([2a00:1450:4864:30::f]:36462)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <eller.helmut@HIDDEN>)
 id 1xCg0x-0000Pj-LZ
 for 81970 <at> debbugs.gnu.org; Fri, 02 Oct 2026 12:21:42 -0400
Received: by mail-wr2-x0f.google.com with SMTP id
 ffacd0b85a97d-48b042e00f7so55209f8f.0
 for <81970 <at> debbugs.gnu.org>; Fri, 02 Oct 2026 09:21:39 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20251104; t=1790958093; x=1791562893; darn=debbugs.gnu.org;
 h=content-type:mime-version:user-agent:message-id:date:references
 :in-reply-to:subject:cc:to:from:from:to:cc:subject:date:message-id
 :reply-to:content-type;
 bh=bi/2XQymF0CP282MlQ82/jji8eRej4Uj4Dt9O6xoxtI=;
 b=phl09Cr8RMiRkZfOg6oDEkHkbetH1YMF3C28u/ZQ1FPnAs0Q+7uurMh/GcXs+XtViF
 xJSBNH1fds1cciRwgYaEYmhyxeylVQ6t705zgq8NYVrKj7xZEyMgZeEUfbBDPyfaWLmi
 htJ5gKjqHMedWa2RECJNEPEqiLkGxQeRYS0ONFuj8YpTbLxA0mTjsaVRSwj4oAbj4ZJh
 3oFv6ZCYIC7e0PWPxvsLNsGwUKBHkN35DN/i6c/6Br73pMmy0/kO8uJd+ayh5+n3bueF
 /YOuhfsQho0rcG7RQQ+P6fQgUF7aaukJFLo3S6yOwk2GU0PbILgl7zsC+mPwrFUvWlWh
 tIIw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20260707; t=1790958093; x=1791562893;
 h=content-type:mime-version:user-agent:message-id:date:references
 :in-reply-to:subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to
 :cc:subject:date:message-id:reply-to:content-type;
 bh=bi/2XQymF0CP282MlQ82/jji8eRej4Uj4Dt9O6xoxtI=;
 b=SemH1yKmWGj5GB4SoVpuCV4atEh8thFeed5fl0LJjtD+sTmhDps9i9KtKws2VEgc+i
 rMFfsIsGROdBmKslSDQTd5cqq8wh+valkGnLCfcJsF8nEWv7BrBs80inMMYdMSXW9t9k
 6l6cRlHtbTVXNB0qmgRipZNtY95c2a/v0Zj5lHwNTjzFg/eMzIO2Gl09951SEZFTrxP+
 W1JHA5s6bpeWzQKqJX1bggzIUAreDgr7YmkLyE4j9Q9PxuQWUMZM75EcDKKS6S9kxq4m
 TuXCFuddFS9cdoUWwuwYhUG1IRL0mMIQmySZo9OxXUQP6PkbrNpmtdgVcWDumJF1+quO
 kGLg==
X-Gm-Message-State: AFq9FYLxD6E54uLc4RJ1HcQozDQbbjGrPAharnK6uUkysJ2m/Dsd9HW6
 xxmt5hEdOJyPv8wEPolTAUTiXi0hBlyu6fxloCbfTlCX3qTggjqXQz7ZyS4tpw==
X-Gm-Gg: AYBFou0kORVa0/5tbnMpe7qHXZZVs8p3ieKvFYizEQ63nIyD2elUf3S+B/jjmLEgLnE
 bbpQcTlbFoJuVvCBY8VA05J7RM27YZxdV7Y4lL8fVHJFyj8RftKxMWvufmaDoiU3olSf47nC9C9
 QBbTd63KH/MlM0J8voHc2yuJPEf/B5h8moFnKCAWrJGcwE2vh69x3dX81A0OnRkeswJG5I44YVj
 6HeVH/fp5FxIc/dGizN3MCazQfTYDD73wCKajw2VIs69xZdr91RinShkyPfHh90E6EXlBgr+kcJ
 i1/IbChSDnX4RDYau95FSYLi16gnnmurG9Eq6P+DQmbX242q9NKhy1yX2QNdndhW+oFQlpQwm/Y
 RaMpLW7WvTeT8Rwc1dIJ6EXRhiYtZTZ1uSeuMTFwZ/hzyqZheipMCR3xzKgsQjDs4FN/U3jea0X
 EeF22U6xVXZ9+xkRetOWn1oe70kO0nuJkxwl5UlCCemzfCFMQ0UkY+kjCYHkbjfjs8zKdpVt/Zf
 1LzmAfT24YM8ULsQdditcXAo120NQ==
X-Received: by 2002:a05:6000:27cf:b0:48b:119e:dc71 with SMTP id
 ffacd0b85a97d-48b126bdcd1mr4451417f8f.5.1790958093067; 
 Fri, 02 Oct 2026 09:21:33 -0700 (PDT)
Received: from hessra (dial-189137.pool.broadband44.net. [212.46.189.137])
 by smtp.gmail.com with ESMTPSA id
 ffacd0b85a97d-48b38104602sm6946464f8f.26.2026.10.02.09.21.31
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Fri, 02 Oct 2026 09:21:32 -0700 (PDT)
From: Helmut Eller <eller.helmut@HIDDEN>
To: Jeff Trull <edaskel@HIDDEN>
Subject: Re: bug#81970: peg.el: "if" construct moves point
In-Reply-To: <CAF_DUeFtCcdvkNP_R9NOzzBpAcpxOgkVsxyEApn9DJmjxDoy7A@HIDDEN>
References: <CAF_DUeFtCcdvkNP_R9NOzzBpAcpxOgkVsxyEApn9DJmjxDoy7A.ref@HIDDEN>
 <CAF_DUeFtCcdvkNP_R9NOzzBpAcpxOgkVsxyEApn9DJmjxDoy7A@HIDDEN>
Date: Fri, 02 Oct 2026 18:21:31 +0200
Message-ID: <87bj9c8450.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: 81970
Cc: 81970 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.0 (/)

On Thu, Oct 01 2026, Jeff Trull via "Bug reports for GNU Emacs, the Swiss army knife of text editors" wrote:

> In PEG, an "if" expression is defined in the Elisp manual as:
>
> Returns non-nil if parsing PEX e from point succeeds (point is not moved)
>
> In fact, point may sometimes be moved. Consider this code:
>
> (with-temp-buffer
>   (insert "foobar")
>   (beginning-of-buffer)
>   (peg-run (peg (if "foo" "baz")))
>   (point))
>
> The position 4 (immediately following "foo") is returned.

Note that in this example peg-run returns nil.  That means that the part
of the documentation that you quoted does not apply.

If a match fails (as in the example), peg-run leaves point where the
parse failed.

In other words: the example works as intended.

Helmut




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#81970; Package emacs. Full text available.

Message received at 81970 <at> debbugs.gnu.org:


Received: (at 81970) by debbugs.gnu.org; 2 Oct 2026 15:21:41 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Oct 02 11:21:40 2026
Received: from localhost ([127.0.0.1]:37056 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1xCf4n-00051g-D2
	for submit <at> debbugs.gnu.org; Fri, 02 Oct 2026 11:21:39 -0400
Received: from sonic305-24.consmr.mail.ne1.yahoo.com ([66.163.185.150]:40778)
 by debbugs.gnu.org with esmtps
 (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2)
 (envelope-from <edaskel@HIDDEN>) id 1xCf4c-00050m-1L
 for 81970 <at> debbugs.gnu.org; Fri, 02 Oct 2026 11:21:28 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=att.net; s=s1024;
 t=1790954475; bh=4KHNgGefDeQLusFT06Q4SUFupykD1SjKDlSOr6I6jUE=;
 h=References:In-Reply-To:From:Date:Subject:To:Cc:From:Subject:Reply-To;
 b=u9T3ur9iMrxu06aZEU0EKHXxhb4MjCfTQJ96tUyP9uCRAu2ak1AcwDJ5pGv6SD5KyXODkgOjMOcfV0L99Q5lIkg38eGuW2f7kg3iAbBpYGPDUHY8ZKRmbh9sCcxwXwsliesEpIfIeYhMRG9EFThLSQBtRFGNuKWra7ogvv5HnOE=
X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048;
 t=1790954475; bh=rwpvM5AOFnMBL12yo58vgfSipFhRs4VQnslKh0Zf6Zt=;
 h=X-Sonic-MF:From:Date:Subject:To:From:Subject;
 b=Udq5/1tnuaGiT1RlKFz26oAE8NwHawew9RdkyS8xaCh0JeeUAJyuBeg2qoWHDQLqcrmIr08TaGCo8Tn5BMSwuKE5ADBrTRkV80LcbecGzJNwKAq8r4gkZbzMQNtiUh7dEVsx+KHCCkCSxYS0TItzQcaGSJIdpwp2u7FSbm54awqHJSgq6L/kUn3ibHokGiZafLE3cvRsn+EGLvNBKUDOh+X50DZpvTF570GcXFP9EyekMufAElVecvIqtPau+WefTBpQk6MCzl87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4.pPnQVAantGj.r_CDVlcPoygac
 kYQ84niyKgg1rEzW7QwQkT3qSu7qe2l_NuNKmyq11fOr2o1gU58KmZmCQAFZsmzvmVrGp.OWfiit
 CsW1abykpIUndNgv_maJWnhgt0LRhdiKB0V.N.f5dsP3EdZ_Kk0GoNIu2B_5IUn_8XAGFAaOdWQA
 c.M9dIrd.0EuMqGH6IGkB9v2pBIRtS4kpXcoZ88Q4WswtZr0jCx54_rla99wMjONzN8a_1WCG4Ly
 lDCNSFLyba9g4mlgU7N08Ta0o7yUxR3aM64ky05hpVvYjlQqJvYfibZskH5SOuXbeXJF2MNuBGGG
 XAaf7
X-Sonic-MF: <edaskel@HIDDEN>
X-Sonic-ID: e38c193b-6ae4-4ac6-86a4-df5be7583e4e
Received: from sonic.gate.mail.ne1.yahoo.com by
 sonic305.consmr.mail.ne1.yahoo.com with HTTP; Fri, 2 Oct 2026 15:21:15 +0000
Received: by hermes--production-bf1-6d6877594b-jdbq2 (Yahoo Inc. Hermes SMTP
 Server) with ESMTPA ID 56b4cb43acf4e2a55b8ef4062f3934ae; 
 Fri, 02 Oct 2026 15:21:10 +0000 (UTC)
Received: by mail-yw1-f180.google.com with SMTP id
 00721157ae682-8ac8a2ac52bso16607107b3.0
 for <81970 <at> debbugs.gnu.org>; Fri, 02 Oct 2026 08:21:10 -0700 (PDT)
X-Forwarded-Encrypted: i=1;
 AKwUvBxbicd/g3yEB29NTUV5jyml+hH0YuZmcuCYewNAdAlXDSC0H+bW9J27GaxD2FdLeP290Da40Q==@debbugs.gnu.org
X-Gm-Message-State: AFq9FYK4JHmw71/ZY1lk3uZLUhBGjEb2bYu7Ew2ewSXfBXbuWhS+Xstf
 3344mBLgM6ycov/vXwcjTe9VGiB/qaWIXekssNOps0V1nNyzh6i/JEqLtKD03KPwomL88uWxUAc
 Cbbcsp87oQNH3XPvGIv9TcEjqcx95uGw=
X-Received: by 2002:a05:690c:6e83:b0:8a8:316e:5973 with SMTP id
 00721157ae682-8acdae8d683mr33107007b3.14.1790954468657; Fri, 02 Oct 2026
 08:21:08 -0700 (PDT)
MIME-Version: 1.0
References: <CAF_DUeFtCcdvkNP_R9NOzzBpAcpxOgkVsxyEApn9DJmjxDoy7A.ref@HIDDEN>
 <CAF_DUeFtCcdvkNP_R9NOzzBpAcpxOgkVsxyEApn9DJmjxDoy7A@HIDDEN>
 <867bk0vgeg.fsf@HIDDEN> <1811201223.2671614.1790933487996@HIDDEN>
 <86ece8tlzh.fsf@HIDDEN>
In-Reply-To: <86ece8tlzh.fsf@HIDDEN>
From: Jeff Trull <edaskel@HIDDEN>
Date: Fri, 2 Oct 2026 11:20:59 -0400
X-Gmail-Original-Message-ID: <CAF_DUeG1WGeNNQ-zYykzKd1Hp9Mkb29MEYWLVQLRdLO35TJCOg@HIDDEN>
X-Gm-Features: AclHuK9yUT4uCdz35pvqh2yfzwbWYVIrMGQUxn5CIDFK27pzVVxOXbOjdAmtdoY
Message-ID: <CAF_DUeG1WGeNNQ-zYykzKd1Hp9Mkb29MEYWLVQLRdLO35TJCOg@HIDDEN>
Subject: Re: bug#81970: peg.el: "if" construct moves point
To: Eli Zaretskii <eliz@HIDDEN>
Content-Type: multipart/alternative; boundary="000000000000e9d219065cdd143b"
X-Mailer: WebService/1.1.26577
 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo
Content-Length: 5149
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 81970
Cc: 81970 <at> debbugs.gnu.org, monnier@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

--000000000000e9d219065cdd143b
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Fri, Oct 2, 2026, 6:50=E2=80=AFAM Eli Zaretskii <eliz@HIDDEN> wrote:

> > Date: Fri, 2 Oct 2026 09:31:27 +0000 (UTC)
> > From: Jeff Trull <edaskel@HIDDEN>
> > Cc: "81970 <at> debbugs.gnu.org" <81970 <at> debbugs.gnu.org>
> >
> > It's not "peg-run", but "if" that has the bug here. "peg-run" may move
> point if the supplied PEG expression
> > moves point. "if" is documented not to do so. Here's the implementation=
:
> >
> > (cl-defmethod peg--translate ((_ (eql if)) e)
> >   (peg--with-choicepoint cp
> >     `(when ,(peg-translate-exp e)
> >        ,(peg--choicepoint-restore cp)    ; only runs if e succeeds
> (returns non-nil), even if e has moved point
> >        t)))
>
> Sorry, you lost me.  Your reproduction recipe calls peg-run, and looks
> at the value of point after peg-run returns.  And peg-run is documented
> to move point.  What am I missing?
>

peg-run can and will move point the amount of the matched expression. This
is sometimes a problem for writing parsers - you want a "peek" operation
that tells you if the following text matches an expression *without
consuming* it. "if" (along with its sister construct "not") are defined to
do exactly  this as part of a peg expression - to return true (matched) or
false without moving point, as their documentation states. It's like
"looking-at" instead of "re-search-forward", but for PEG.

So peg-run consumes/moves point the amount of input the expression
specifies. "if" and "not" specify zero, so peg-run shouldn't move point
when called that way.

I describe this as a bug with "if" because peg delegates the implementation
of the non-consuming match to each construct, which uses the "choicepoint"
mechanism for this purpose. The one in "if" seems to have a bug - IMO, the
choicepoint should be unconditionally restored.

>

--000000000000e9d219065cdd143b
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"auto"><div><br><br><div class=3D"gmail_quote gmail_quote_contai=
ner"><div dir=3D"ltr" class=3D"gmail_attr">On Fri, Oct 2, 2026, 6:50=E2=80=
=AFAM Eli Zaretskii &lt;<a href=3D"mailto:eliz@HIDDEN">eliz@HIDDEN</a>&gt=
; wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .=
8ex;border-left:1px #ccc solid;padding-left:1ex">&gt; Date: Fri, 2 Oct 2026=
 09:31:27 +0000 (UTC)<br>
&gt; From: Jeff Trull &lt;<a href=3D"mailto:edaskel@HIDDEN" target=3D"_bla=
nk" rel=3D"noreferrer">edaskel@HIDDEN</a>&gt;<br>
&gt; Cc: &quot;<a href=3D"mailto:81970 <at> debbugs.gnu.org" target=3D"_blank" r=
el=3D"noreferrer">81970 <at> debbugs.gnu.org</a>&quot; &lt;<a href=3D"mailto:819=
70 <at> debbugs.gnu.org" target=3D"_blank" rel=3D"noreferrer">81970@HIDDEN=
org</a>&gt;<br>
&gt; <br>
&gt; It&#39;s not &quot;peg-run&quot;, but &quot;if&quot; that has the bug =
here. &quot;peg-run&quot; may move point if the supplied PEG expression<br>
&gt; moves point. &quot;if&quot; is documented not to do so. Here&#39;s the=
 implementation:<br>
&gt; <br>
&gt; (cl-defmethod peg--translate ((_ (eql if)) e)<br>
&gt;=C2=A0 =C2=A0(peg--with-choicepoint cp<br>
&gt;=C2=A0 =C2=A0 =C2=A0`(when ,(peg-translate-exp e)<br>
&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 ,(peg--choicepoint-restore cp)=C2=A0 =C2=A0=
 ; only runs if e succeeds (returns non-nil), even if e has moved point<br>
&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 t)))<br>
<br>
Sorry, you lost me.=C2=A0 Your reproduction recipe calls peg-run, and looks=
<br>
at the value of point after peg-run returns.=C2=A0 And peg-run is documente=
d<br>
to move point.=C2=A0 What am I missing?<br></blockquote></div></div><div di=
r=3D"auto"><br></div><div dir=3D"auto">peg-run can and will move point the =
amount of the matched expression. This is sometimes a problem for writing p=
arsers - you want a &quot;peek&quot; operation that tells you if the follow=
ing text matches an expression *without consuming* it. &quot;if&quot; (alon=
g with its sister construct &quot;not&quot;) are defined to do exactly=C2=
=A0 this as part of a peg expression - to return true (matched) or false wi=
thout moving point, as their documentation states. It&#39;s like &quot;look=
ing-at&quot; instead of &quot;re-search-forward&quot;, but for PEG.</div><d=
iv dir=3D"auto"><br></div><div dir=3D"auto">So peg-run consumes/moves point=
 the amount of input the expression specifies. &quot;if&quot; and &quot;not=
&quot; specify zero, so peg-run shouldn&#39;t move point when called that w=
ay.</div><div dir=3D"auto"><br></div><div dir=3D"auto">I describe this as a=
 bug with &quot;if&quot; because peg delegates the implementation of the no=
n-consuming match to each construct, which uses the &quot;choicepoint&quot;=
 mechanism for this purpose. The one in &quot;if&quot; seems to have a bug =
- IMO, the choicepoint should be unconditionally restored.</div><div dir=3D=
"auto"><div class=3D"gmail_quote gmail_quote_container"><blockquote class=
=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padd=
ing-left:1ex">
</blockquote></div></div></div>

--000000000000e9d219065cdd143b--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#81970; Package emacs. Full text available.

Message received at 81970 <at> debbugs.gnu.org:


Received: (at 81970) by debbugs.gnu.org; 2 Oct 2026 10:50:48 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Oct 02 06:50:47 2026
Received: from localhost ([127.0.0.1]:48234 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1xCaqh-00034h-D3
	for submit <at> debbugs.gnu.org; Fri, 02 Oct 2026 06:50:46 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:36288)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1xCaqa-000344-7x
 for 81970 <at> debbugs.gnu.org; Fri, 02 Oct 2026 06:50:39 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1xCaqT-00076W-4U; Fri, 02 Oct 2026 06:50:29 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=nPVA9br7zF+KJHAt6F6K0nsiTCmkvh+PPmnMhZEgvmI=; b=mX5QK6D8XS6G
 JPvLanHokFSyYaFolpRMNGE2PaRzGwocx5X9jTU8GW87EuyuBWMybRx7jzPmmRpaUhdJH+KivWyB2
 YOQjKktxARSzgerd2apvUl61xhLJjnl3pLTVGy2rdcfdBe8MbKPYl3w0KzELvsDeFG6ROGJyGR83Y
 wk3lIIC9hoAI4Cd0u07aSbSHKhgRMw4Wm3BMnaqsQHz1swyArYSKxIx5RuxR64ufdIdDf3J9YD+et
 9whRVNxYwq0cB82LpLUezfmVttpn5d6jYkhxuMq9KjbrPYkh/Be6alFOcCOjDz0Yk0Cd67Q12UBl8
 VAUB2nlHJgpCmGwp5m+1vw==;
Date: Fri, 02 Oct 2026 13:50:26 +0300
Message-Id: <86ece8tlzh.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Jeff Trull <edaskel@HIDDEN>
In-Reply-To: <1811201223.2671614.1790933487996@HIDDEN> (message from
 Jeff Trull on Fri, 2 Oct 2026 09:31:27 +0000 (UTC))
Subject: Re: bug#81970: peg.el: "if" construct moves point
References: <CAF_DUeFtCcdvkNP_R9NOzzBpAcpxOgkVsxyEApn9DJmjxDoy7A.ref@HIDDEN>
 <CAF_DUeFtCcdvkNP_R9NOzzBpAcpxOgkVsxyEApn9DJmjxDoy7A@HIDDEN>
 <867bk0vgeg.fsf@HIDDEN> <1811201223.2671614.1790933487996@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 81970
Cc: 81970 <at> debbugs.gnu.org, monnier@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Date: Fri, 2 Oct 2026 09:31:27 +0000 (UTC)
> From: Jeff Trull <edaskel@HIDDEN>
> Cc: "81970 <at> debbugs.gnu.org" <81970 <at> debbugs.gnu.org>
> 
> It's not "peg-run", but "if" that has the bug here. "peg-run" may move point if the supplied PEG expression
> moves point. "if" is documented not to do so. Here's the implementation:
> 
> (cl-defmethod peg--translate ((_ (eql if)) e)
>   (peg--with-choicepoint cp
>     `(when ,(peg-translate-exp e)
>        ,(peg--choicepoint-restore cp)    ; only runs if e succeeds (returns non-nil), even if e has moved point
>        t)))

Sorry, you lost me.  Your reproduction recipe calls peg-run, and looks
at the value of point after peg-run returns.  And peg-run is documented
to move point.  What am I missing?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#81970; Package emacs. Full text available.

Message received at 81970 <at> debbugs.gnu.org:


Received: (at 81970) by debbugs.gnu.org; 2 Oct 2026 09:32:03 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Oct 02 05:32:01 2026
Received: from localhost ([127.0.0.1]:35298 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1xCZcR-0006Iw-FI
	for submit <at> debbugs.gnu.org; Fri, 02 Oct 2026 05:32:01 -0400
Received: from sonic305-23.consmr.mail.ne1.yahoo.com ([66.163.185.149]:38745)
 by debbugs.gnu.org with esmtps
 (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2)
 (envelope-from <edaskel@HIDDEN>) id 1xCZcH-0006HY-Gy
 for 81970 <at> debbugs.gnu.org; Fri, 02 Oct 2026 05:31:51 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=att.net; s=s1024;
 t=1790933498; bh=49rVdzvLcrFxknxTjhpZ9/5giDVGKGAN+8lPj8DQjNc=;
 h=Date:From:To:Cc:In-Reply-To:References:Subject:From:Subject:Reply-To;
 b=RsnBSnY9TNnP0FcMmETVjmVWlAxPHo3vnxzbpB9F3NmTvMobs9i09lvJZN4T0J3Ahm1q6LKXdNdzUYeusgUbTs2is3pk43810qP0b8SM8zK7jNeWwYSiP/jKjL73cJPRgCLIMnqWfFej08usVscyp6HUp+lWSwdnmshWS+dnokk=
X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048;
 t=1790933498; bh=U2bEcqLaRVNg3VxMwwjZNjzAYuKl10gM13RVzh3ieD0=;
 h=X-Sonic-MF:Date:From:To:Subject:From:Subject;
 b=I9vlxETOiKKpKIY73EwQxtvKFCP82XVonHH9buEP9EnqkXR5XnPNCwUJdr1Qcd7IXTKaizUSSMDkzP/eTIgQ+zqV/kqA8Jx/Mnu9S5kY4CezKBkx/NABC1mNlL+irnxx1u0ab0sN3jIro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wXjAVDsr4hPIyKw.33r3Sh5fb515kcRJV2eokSh.UDaloSa1HVPXCfkRvuh6qoNV6qu
 MpqXxKsSfKrraQMYy4C4XadDk_8BL.KC2LdsO966WJlu.pFpg9ON.v44_FieIoS6.Ahi2zuwWWpU
 ndl3atsuV2jhwx34x0Bu2P2ZTna4Jos1IbsL4e4Kbol4WVh8w1g6VLLinlP9iVAKv42q.Q4pkEhQ
 XFy6_P9SU8APORhE_CacFRrWUduuV0PGzQbOzFAB3uBDmCepMb_.40LywEHb1qcnPxnJ7ELBhihO
 fdnjweV8XBIlgxYZa7IdNIZzogje3BdgEEWTG.VzOFo7Ws9UjlsNRut3.1ordbYSAmZWHnhNiRBN
 GA5m4sovJjStCgeY4OD9.KciaZ1YhmmDzJXz8W0A-
X-Sonic-MF: <edaskel@HIDDEN>
X-Sonic-ID: 4053df4c-77b1-4430-a3fa-91c9aeb095a4
Received: from sonic.gate.mail.ne1.yahoo.com by
 sonic305.consmr.mail.ne1.yahoo.com with HTTP; Fri, 2 Oct 2026 09:31:38 +0000
Date: Fri, 2 Oct 2026 09:31:27 +0000 (UTC)
From: Jeff Trull <edaskel@HIDDEN>
To: Stefan Monnier <monnier@HIDDEN>, Eli Zaretskii <eliz@HIDDEN>
Message-ID: <1811201223.2671614.1790933487996@HIDDEN>
In-Reply-To: <867bk0vgeg.fsf@HIDDEN>
References: <CAF_DUeFtCcdvkNP_R9NOzzBpAcpxOgkVsxyEApn9DJmjxDoy7A.ref@HIDDEN>
 <CAF_DUeFtCcdvkNP_R9NOzzBpAcpxOgkVsxyEApn9DJmjxDoy7A@HIDDEN>
 <867bk0vgeg.fsf@HIDDEN>
Subject: Re: bug#81970: peg.el: "if" construct moves point
MIME-Version: 1.0
Content-Type: multipart/alternative; 
 boundary="----=_Part_2671613_852163944.1790933487995"
X-Mailer: WebService/1.1.26577 YMailNorrin
Content-Length: 5732
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 81970
Cc: "81970 <at> debbugs.gnu.org" <81970 <at> debbugs.gnu.org>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

------=_Part_2671613_852163944.1790933487995
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

 It's not "peg-run", but "if" that has the bug here. "peg-run" may move poi=
nt if the supplied PEG expression moves point. "if" is documented not to do=
 so. Here's the implementation:
(cl-defmethod peg--translate ((_ (eql if)) e)
=C2=A0 (peg--with-choicepoint cp
=C2=A0 =C2=A0 `(when ,(peg-translate-exp e)
=C2=A0 =C2=A0 =C2=A0 =C2=A0,(peg--choicepoint-restore cp)=C2=A0 =C2=A0 ; on=
ly runs if e succeeds (returns non-nil), even if e has moved point
=C2=A0 =C2=A0 =C2=A0 =C2=A0t)))

The choicepoint is restored only if the expression supplied to "if" passes.=
 In my example this is ("foo" "bar"), which partially succeeds (moving poin=
t) but is overall a failed parse. If the text in the buffer were "foobaz" i=
nstead, the child expression would pass and point would be correctly restor=
ed to 1.
The bug is that in some cases, "if" moves point, despite being documented n=
ot to.
    On Friday, October 2, 2026 at 01:08:13 AM EDT, Eli Zaretskii <eliz@gnu.=
org> wrote: =20
=20
 > Date: Thu, 1 Oct 2026 13:15:53 -0700
> From: Jeff Trull via "Bug reports for GNU Emacs,
>=C2=A0 the Swiss army knife of text editors" <bug-gnu-emacs@HIDDEN>
>=20
> In PEG, an "if" expression is defined in the Elisp manual as:
>=20
> Returns non-nil if parsing PEX e from point succeeds (point is not moved)
>=20
> In fact, point may sometimes be moved. Consider this code:
>=20
> (with-temp-buffer
>=C2=A0 (insert "foobar")
>=C2=A0 (beginning-of-buffer)
>=C2=A0 (peg-run (peg (if "foo" "baz")))
>=C2=A0 (point))
>=20
> The position 4 (immediately following "foo") is returned.
>=20
> I think a fix should be straightforward.

So you are saying that the documentation of "if" in PEG is inaccurate
or misleading?=C2=A0 Because the doc string of peg-run explicitly says that
point moves.

Or are you saying something else?
 =20
------=_Part_2671613_852163944.1790933487995
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<html><head></head><body><div class=3D"ydp6a50d154yahoo-style-wrap" style=
=3D"font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:13px=
;"><div></div>
        <div dir=3D"ltr" data-setdir=3D"false">It's not "peg-run", but "if"=
 that has the bug here. "peg-run" may move point if the supplied PEG expres=
sion moves point. "if" is documented not to do so. Here's the implementatio=
n:</div><div dir=3D"ltr" data-setdir=3D"false"><br></div><div dir=3D"ltr" d=
ata-setdir=3D"false"><div dir=3D"ltr" data-setdir=3D"false">(cl-defmethod p=
eg--translate ((_ (eql if)) e)<br>&nbsp; (peg--with-choicepoint cp<br>&nbsp=
; &nbsp; `(when ,(peg-translate-exp e)<br>&nbsp; &nbsp; &nbsp; &nbsp;,(peg-=
-choicepoint-restore cp)&nbsp; &nbsp; ; only runs if e succeeds (returns no=
n-nil), even if e has moved point<br>&nbsp; &nbsp; &nbsp; &nbsp;t)))<br><br=
></div>The choicepoint is restored only if the expression supplied to "if" =
passes. In my example this is ("foo" "bar"), which partially succeeds (movi=
ng point) but is overall a failed parse. If the text in the buffer were "fo=
obaz" instead, the child expression would pass and point would be correctly=
 restored to 1.</div><div dir=3D"ltr" data-setdir=3D"false"><br></div><div =
dir=3D"ltr" data-setdir=3D"false">The bug is that in some cases, "if" moves=
 point, despite being documented not to.</div><div><br></div>
       =20
        </div><div id=3D"yahoo_quoted_1024050014" class=3D"yahoo_quoted">
            <div style=3D"font-family:'Helvetica Neue', Helvetica, Arial, s=
ans-serif;font-size:13px;color:#26282a;">
               =20
                <div>
                        On Friday, October 2, 2026 at 01:08:13 AM EDT, Eli =
Zaretskii &lt;eliz@HIDDEN&gt; wrote:
                    </div>
                    <div><br></div>
                    <div><br></div>
               =20
               =20
                <div><div dir=3D"ltr">&gt; Date: Thu, 1 Oct 2026 13:15:53 -=
0700<br></div><div dir=3D"ltr">&gt; From: Jeff Trull via "Bug reports for G=
NU Emacs,<br></div><div dir=3D"ltr">&gt;&nbsp; the Swiss army knife of text=
 editors" &lt;<a ymailto=3D"mailto:bug-gnu-emacs@HIDDEN" href=3D"mailto:bu=
g-gnu-emacs@HIDDEN">bug-gnu-emacs@HIDDEN</a>&gt;<br></div><div dir=3D"ltr=
">&gt; <br></div><div dir=3D"ltr">&gt; In PEG, an "if" expression is define=
d in the Elisp manual as:<br></div><div dir=3D"ltr">&gt; <br></div><div dir=
=3D"ltr">&gt; Returns non-nil if parsing PEX e from point succeeds (point i=
s not moved)<br></div><div dir=3D"ltr">&gt; <br></div><div dir=3D"ltr">&gt;=
 In fact, point may sometimes be moved. Consider this code:<br></div><div d=
ir=3D"ltr">&gt; <br></div><div dir=3D"ltr">&gt; (with-temp-buffer<br></div>=
<div dir=3D"ltr">&gt;&nbsp;  (insert "foobar")<br></div><div dir=3D"ltr">&g=
t;&nbsp;  (beginning-of-buffer)<br></div><div dir=3D"ltr">&gt;&nbsp;  (peg-=
run (peg (if "foo" "baz")))<br></div><div dir=3D"ltr">&gt;&nbsp;  (point))<=
br></div><div dir=3D"ltr">&gt; <br></div><div dir=3D"ltr">&gt; The position=
 4 (immediately following "foo") is returned.<br></div><div dir=3D"ltr">&gt=
; <br></div><div dir=3D"ltr">&gt; I think a fix should be straightforward.<=
br></div><div dir=3D"ltr"><br></div><div dir=3D"ltr">So you are saying that=
 the documentation of "if" in PEG is inaccurate<br></div><div dir=3D"ltr">o=
r misleading?&nbsp; Because the doc string of peg-run explicitly says that<=
br></div><div dir=3D"ltr">point moves.<br></div><div dir=3D"ltr"><br></div>=
<div dir=3D"ltr">Or are you saying something else?<br></div></div>
            </div>
        </div></body></html>
------=_Part_2671613_852163944.1790933487995--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#81970; Package emacs. Full text available.

Message received at 81970 <at> debbugs.gnu.org:


Received: (at 81970) by debbugs.gnu.org; 2 Oct 2026 05:08:20 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Oct 02 01:08:20 2026
Received: from localhost ([127.0.0.1]:53006 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1xCVVM-00055B-Ez
	for submit <at> debbugs.gnu.org; Fri, 02 Oct 2026 01:08:20 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:34222)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1xCVVJ-00054X-Ni
 for 81970 <at> debbugs.gnu.org; Fri, 02 Oct 2026 01:08:18 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1xCVVE-0006WS-77; Fri, 02 Oct 2026 01:08:12 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=pnHQsTABQaOi0D0idluEVgaS8R5/DD0owSoSmKZa3kM=; b=EZVHPtsNztUz
 1H3Y0lhK9mda7SdPShmWtBj57sccQ+TDw/umTeCmYSPiAyuMsBOoyGFFREvR/utAGhMJH/v5DCcCC
 g2fdMbpgyT0oRmuhyZ6rIlhilD5b1A+7J0uidEJj5qd6DKSpm6EKyfAjjmo2+ltpYY5pODVwSDsld
 4XHy/YxkJZQrY4HDVrs8M4wptaaBaPRKdTGvptQElj9YV9kWnkbdm1uZkYvIttgjGkmX+rwRy1XO9
 uLxmOm+4rzDiuU9EfTzVXGni6MeVLR/UXpyTGXN00+dgyfJGL6lOW8jxr5NaMjIUNUxQDgsSR5bFU
 4EQCovUofgtVmNSeyl0H4w==;
Date: Fri, 02 Oct 2026 08:08:07 +0300
Message-Id: <867bk0vgeg.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Jeff Trull <edaskel@HIDDEN>,
 Stefan Monnier <monnier@HIDDEN>
In-Reply-To: <CAF_DUeFtCcdvkNP_R9NOzzBpAcpxOgkVsxyEApn9DJmjxDoy7A@HIDDEN>
 (bug-gnu-emacs@HIDDEN)
Subject: Re: bug#81970: peg.el: "if" construct moves point
References: <CAF_DUeFtCcdvkNP_R9NOzzBpAcpxOgkVsxyEApn9DJmjxDoy7A.ref@HIDDEN>
 <CAF_DUeFtCcdvkNP_R9NOzzBpAcpxOgkVsxyEApn9DJmjxDoy7A@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 81970
Cc: 81970 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Date: Thu, 1 Oct 2026 13:15:53 -0700
> From: Jeff Trull via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs@HIDDEN>
> 
> In PEG, an "if" expression is defined in the Elisp manual as:
> 
> Returns non-nil if parsing PEX e from point succeeds (point is not moved)
> 
> In fact, point may sometimes be moved. Consider this code:
> 
> (with-temp-buffer
>   (insert "foobar")
>   (beginning-of-buffer)
>   (peg-run (peg (if "foo" "baz")))
>   (point))
> 
> The position 4 (immediately following "foo") is returned.
> 
> I think a fix should be straightforward.

So you are saying that the documentation of "if" in PEG is inaccurate
or misleading?  Because the doc string of peg-run explicitly says that
point moves.

Or are you saying something else?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#81970; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 1 Oct 2026 20:16:44 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Oct 01 16:16:44 2026
Received: from localhost ([127.0.0.1]:49865 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1xCNCt-0002vD-Ni
	for submit <at> debbugs.gnu.org; Thu, 01 Oct 2026 16:16:44 -0400
Received: from lists1p.gnu.org ([2001:470:142::17]:44206)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <edaskel@HIDDEN>) id 1xCNCq-0002uT-F4
 for submit <at> debbugs.gnu.org; Thu, 01 Oct 2026 16:16:41 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <edaskel@HIDDEN>) id 1xCNCT-0002sP-PQ
 for bug-gnu-emacs@HIDDEN; Thu, 01 Oct 2026 16:16:25 -0400
Received: from sonic305-25.consmr.mail.ne1.yahoo.com ([66.163.185.151])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <edaskel@HIDDEN>) id 1xCNCR-0007n4-P4
 for bug-gnu-emacs@HIDDEN; Thu, 01 Oct 2026 16:16:17 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=att.net; s=s1024;
 t=1790885770; bh=qydWiLcy4pJglM/9S9HTM3971MnQV4IlRHazl03axqg=;
 h=From:Date:Subject:To:References:From:Subject:Reply-To;
 b=C6CjZoIu0/0C4fWytZga1fjMQNsxLF7/vMZwSkO0XtSYEYt4BE2GBPeFXq+U5AmQ1lUbbhNrZfurjspLeWiDLBgVYbbVbGMz70nuZdrQ5UksKNse4qXNYJhL03VQJGQNEOUKJ7NQv8JvQJ4nKAgwLuClYrfT4sTL1zljCa+xgYY=
X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048;
 t=1790885770; bh=/eTTwwhyf3eLzYzZpS6mXdwFMEiSXl/i0Ps4Z3ZD59U=;
 h=X-Sonic-MF:From:Date:Subject:To:From:Subject;
 b=JcPPZ9f6EDyRC1V72/JfKCYxDNFLKA7E1yDejI4CXGsRvKP0pLusFbPKZsXxee909iF+GSdp4AuY/fI7ReCYNeiM0HKtIdGDoPUNskkQJSmlxMuU0GkM16kPpHdhCrcEJ1+m20vHkxwFyY5YWSQRlMGmtOjPGOsL0xrMvuWJixhOwJkrF1/sSGr2zmleqpLoHhfd9gwMddyjPe8Bj1jO5cgOJ8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xw
 IVIQG5S3AcQSg8lcfPpzyoSl.GsG_N8MTjeolztJQHLqyoYxMkMyVgk7nyAWBCtJEQIHRfUZYjzm
 qNFbLTYUzk7ti6.E.TVy_I_RHtHBZxf5q146mQmoZNGl8p3h5kdaDh0guiX4A33NNohrI936i5Gf
 AlBxYDao1BnB_h5aMbU37EbMEO8sCqS1nPbGQUar.4qrdfgeBo.Sz1P69Z9u0gXKe0mE6jGvAJTU
 tzpBFBNMigVJA1uINfKsnE6XrRcX8.E9X_ujVnv16e2eg7JE5h120OOebSrBuPFYNA3c8ifIb1KX
 sBKBeRPJ0D2xrpacabmBqwlaTdKJclfIkbIvirGGnekS4_BXNf_UH3U.A
X-Sonic-MF: <edaskel@HIDDEN>
X-Sonic-ID: ad47ced4-8f0d-4546-b251-4976d352da2e
Received: from sonic.gate.mail.ne1.yahoo.com by
 sonic305.consmr.mail.ne1.yahoo.com with HTTP; Thu, 1 Oct 2026 20:16:10 +0000
Received: by hermes--production-bf1-6d6877594b-qr7mx (Yahoo Inc. Hermes SMTP
 Server) with ESMTPA ID a9be4dc229571ff1e875a15824d02f5f; 
 Thu, 01 Oct 2026 20:16:05 +0000 (UTC)
Received: by mail-yx2-f40.google.com with SMTP id
 956f58d0204a3-675686b026dso1524035d50.1
 for <bug-gnu-emacs@HIDDEN>; Thu, 01 Oct 2026 13:16:04 -0700 (PDT)
X-Gm-Message-State: AFq9FYIe62tIQziWBLmQifqurbDfRz8y3dghHjJVsA99LUu3dsiFF+i8
 JtRuxpq9WW+ERRv8JMWnLCgZ+UuET9ext7ecCXU/cEINW3G5XEfolrSp6C5Wv57lKnuHcDiaOn4
 PEcWqdVbifVReGbDorl5fflMYVHdbIWU=
X-Received: by 2002:a05:690c:5681:b0:8a4:af43:6941 with SMTP id
 00721157ae682-8ae3a7e8e51mr1525897b3.20.1790885763983; Thu, 01 Oct 2026
 13:16:03 -0700 (PDT)
MIME-Version: 1.0
From: Jeff Trull <edaskel@HIDDEN>
Date: Thu, 1 Oct 2026 13:15:53 -0700
X-Gmail-Original-Message-ID: <CAF_DUeFtCcdvkNP_R9NOzzBpAcpxOgkVsxyEApn9DJmjxDoy7A@HIDDEN>
X-Gm-Features: AclHuK8xSyhyy1pGt9yBSMHfZuzRNlfyjofT-2YVcAy33T4rdPDxDp6gnAUppe8
Message-ID: <CAF_DUeFtCcdvkNP_R9NOzzBpAcpxOgkVsxyEApn9DJmjxDoy7A@HIDDEN>
Subject: peg.el: "if" construct moves point
To: bug-gnu-emacs@HIDDEN
Content-Type: multipart/alternative; boundary="000000000000cbb29d065ccd1589"
References: <CAF_DUeFtCcdvkNP_R9NOzzBpAcpxOgkVsxyEApn9DJmjxDoy7A.ref@HIDDEN>
X-Mailer: WebService/1.1.26577
 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo
Content-Length: 1480
Received-SPF: pass client-ip=66.163.185.151; envelope-from=edaskel@HIDDEN;
 helo=sonic305-25.consmr.mail.ne1.yahoo.com
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,
 HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001,
 SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)

--000000000000cbb29d065ccd1589
Content-Type: text/plain; charset="UTF-8"

In PEG, an "if" expression is defined in the Elisp manual as:

Returns non-nil if parsing PEX e from point succeeds (point is not moved)

In fact, point may sometimes be moved. Consider this code:

(with-temp-buffer
  (insert "foobar")
  (beginning-of-buffer)
  (peg-run (peg (if "foo" "baz")))
  (point))

The position 4 (immediately following "foo") is returned.

I think a fix should be straightforward.

Thanks,
Jeff Trull

--000000000000cbb29d065ccd1589
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>In PEG, an &quot;if&quot; expression is defined in th=
e Elisp manual as:</div><div><br></div><div>Returns non-<code class=3D"gmai=
l-code">nil</code> if parsing <abbr class=3D"gmail-acronym">PEX</abbr> <var=
 class=3D"gmail-var">e</var> from point
succeeds (point is not moved)</div><div><br></div><div>In fact, point may s=
ometimes be moved. Consider this code:</div><div><br></div><div>(with-temp-=
buffer<br>=C2=A0 (insert &quot;foobar&quot;)<br>=C2=A0 (beginning-of-buffer=
)<br>=C2=A0 (peg-run (peg (if &quot;foo&quot; &quot;baz&quot;)))<br>=C2=A0 =
(point))<br><br></div><div>The position 4 (immediately following &quot;foo&=
quot;) is returned.</div><div><br></div><div>I think a fix should be straig=
htforward.</div><div><br></div><div>Thanks,</div><div>Jeff Trull</div><div>=
<br></div></div>

--000000000000cbb29d065ccd1589--




Acknowledgement sent to Jeff Trull <edaskel@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#81970; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 12 Oct 2026 06:15:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.