X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=emacs%2Fnotmuch-parser.el;h=9749a6be51bd6e2c6577d2d24e3112a014294de4;hb=9ca1f945d9f5030600dc14ffff10d4dad14db4ca;hp=4a437016dc6b47d6e6e6fa33d76c31fa6ac1e5df;hpb=b4ee80dcbdd6702a693110321ad69c380967846d;p=notmuch diff --git a/emacs/notmuch-parser.el b/emacs/notmuch-parser.el index 4a437016..9749a6be 100644 --- a/emacs/notmuch-parser.el +++ b/emacs/notmuch-parser.el @@ -1,4 +1,4 @@ -;;; notmuch-parser.el --- streaming S-expression parser +;;; notmuch-parser.el --- streaming S-expression parser -*- lexical-binding: t -*- ;; ;; Copyright © Austin Clements ;; @@ -21,7 +21,8 @@ ;;; Code: -(eval-when-compile (require 'cl-lib)) +(require 'cl-lib) +(require 'pcase) (defun notmuch-sexp-create-parser () "Return a new streaming S-expression parser. @@ -140,15 +141,6 @@ beginning of a list, throw invalid-read-syntax." (forward-char) (signal 'invalid-read-syntax (list (string (char-before))))))) -(defun notmuch-sexp-eof (sp) - "Signal an error if there is more data in SP's buffer. - -Moves point to the beginning of any trailing data or to the end -of the buffer if there is only trailing whitespace." - (skip-chars-forward " \n\r\t") - (unless (eobp) - (error "Trailing garbage following expression"))) - (defvar notmuch-sexp--parser nil "The buffer-local notmuch-sexp-parser instance. @@ -187,8 +179,11 @@ move point in the input buffer." (t (with-current-buffer result-buffer (funcall result-function result)))))) (end - ;; Any trailing data is unexpected - (notmuch-sexp-eof notmuch-sexp--parser) + ;; Skip over trailing whitespace. + (skip-chars-forward " \n\r\t") + ;; Any trailing data is unexpected. + (unless (eobp) + (error "Trailing garbage following expression")) (setq done t))))) ;; Clear out what we've parsed (delete-region (point-min) (point)))