branch: externals/peg commit 90c9004a8347209f94a37c8d9506425721098402 Author: Eric Abrahamsen <e...@ericabrahamsen.net> Commit: Eric Abrahamsen <e...@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.hel...@gmail.com> ;; Maintainer: Stefan Monnier <monn...@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))))))