[PATCH v2 14/36] emacs: inline notmuch-sexp-eof into only caller

Subject: [PATCH v2 14/36] emacs: inline notmuch-sexp-eof into only caller

Date: Sun, 10 Jan 2021 15:00:50 +0100

To: notmuch@notmuchmail.org


From: Jonas Bernoulli

This function had a few issues.
- Neither its name nor the old comment before it is called made it
  clear what it does.
- It took one argument but didn't do anything with it.
- It's doc-string made a few claims, which are untrue and generally
  focused on details instead of that its purpose is.
 emacs/notmuch-parser.el | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/emacs/notmuch-parser.el b/emacs/notmuch-parser.el
index b8c3fd2c..294e0544 100644
--- a/emacs/notmuch-parser.el
+++ b/emacs/notmuch-parser.el
@@ -140,15 +140,6 @@ (defun notmuch-sexp-begin-list (sp)
 	 (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 +178,11 @@ (defun notmuch-sexp-parse-partial-list (result-function result-buffer)
 	     (t     (with-current-buffer result-buffer
 		      (funcall result-function result))))))
-	 ;; 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)))
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org