emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/peg 90c9004a83 2/2: Fix syntax-class PEX to move point;


From: Eric Abrahamsen
Subject: [elpa] externals/peg 90c9004a83 2/2: Fix syntax-class PEX to move point; release 1.0.1
Date: Tue, 29 Nov 2022 11:10:13 -0500 (EST)

branch: externals/peg
commit 90c9004a8347209f94a37c8d9506425721098402
Author: Eric Abrahamsen <eric@ericabrahamsen.net>
Commit: Eric Abrahamsen <eric@ericabrahamsen.net>

    Fix syntax-class PEX to move point; release 1.0.1
    
    * peg.el (peg--translate): This method was only testing buffer text
    after point, it needs to actually move point over the matched text.
    * peg-tests.el (peg-test): Add to tests.
---
 peg-tests.el | 5 +++++
 peg.el       | 6 ++++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/peg-tests.el b/peg-tests.el
index bb47968a87..cedccd7eaa 100644
--- a/peg-tests.el
+++ b/peg-tests.el
@@ -154,6 +154,11 @@ resp. succeded instead of signaling an error."
     (should-not (peg-run (peg "to")))
     (should (peg-run (peg "ro")))
     (should (eobp)))
+  (with-temp-buffer
+    (insert "   ")
+    (goto-char (point-min))
+    (peg-run (peg (+ (syntax-class whitespace))))
+    (should (eobp)))
   )
 
 ;;; Examples:
diff --git a/peg.el b/peg.el
index 0e4221eeb7..ff765bd58b 100644
--- a/peg.el
+++ b/peg.el
@@ -5,7 +5,7 @@
 ;; Author: Helmut Eller <eller.helmut@gmail.com>
 ;; Maintainer: Stefan Monnier <monnier@iro.umontreal.ca>
 ;; Package-Requires: ((emacs "25"))
-;; Version: 1.0
+;; Version: 1.0.1
 ;;
 ;; This program is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
@@ -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))))))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]