Subject: Re: bug#59345: 28.2; peg.el: syntax-class PEX does not advance point

From: Eric Abrahamsen <[email-masked]>
Date: Mon, 28 Nov 2022 14:40:20 -0800

Eric Abrahamsen <[email-masked]> writes:

> Michael Heerdegen <[email-masked]> writes:
>
>> Helmut Eller <[email-masked]> writes:
>>
>>> >> In version 1.0 of peg.el, there is a PEX to match the syntax class of
>>> >> the character at point. I expected it to advance the point after
>>> >> recognizing the correct class, but it seems that it does not.
>>
>>> Yes, looks like an oversight.
>>> [...]
>>> I may be the original author (long ago), but the current maintainer is
>>> Sefan Monnier.
>>
>> Ok, thanks for confirming, Helmut.  Then I CC Stefan.
>
> I'm finally getting around to adding this package to core, so I'll
> stick myself in the Cc.

I guess the fix would look like the attached?

diff --git a/peg.el b/peg.el
index 0e4221eeb7..3f86a0bf19 100644
--- a/peg.el
+++ b/peg.el
@@ -588,7 +588,9 @@ of PEG expressions, implicitly combined with `and'."
 
 (cl-defmethod peg--translate ((_ (eql syntax-class)) class)
   (let ((probe (assoc class peg-syntax-classes)))
-    (cond (probe `(looking-at ,(format "\\s%c" (cadr probe))))
+    (cond (probe `(when (looking-at ,(format "\\s%c" (cadr probe)))
+                    (forward-char)
+                    t)
 	  (t (error "Invalid syntax class: %S\nMust be one of: %s" class
 		    (mapcar #'car peg-syntax-classes))))))