- (insert string)))
- (with-current-buffer results-buf
- (while (not done)
- (condition-case nil
- (case notmuch-search-process-state
- ((begin)
- ;; Enter the results list
- (if (eq (notmuch-json-begin-compound
- notmuch-search-json-parser) 'retry)
- (setq done t)
- (setq notmuch-search-process-state 'result)))
- ((result)
- ;; Parse a result
- (let ((result (notmuch-json-read notmuch-search-json-parser)))
- (case result
- ((retry) (setq done t))
- ((end) (setq notmuch-search-process-state 'end))
- (otherwise (notmuch-search-show-result result)))))
- ((end)
- ;; Any trailing data is unexpected
- (notmuch-json-eof notmuch-search-json-parser)
- (setq done t)))
- (json-error
- ;; Do our best to resynchronize and ensure forward
- ;; progress
- (notmuch-search-show-error
- "%s"
- (with-current-buffer parse-buf
- (let ((bad (buffer-substring (line-beginning-position)
- (line-end-position))))
- (forward-line)
- bad))))))
- ;; Clear out what we've parsed
- (with-current-buffer parse-buf
- (delete-region (point-min) (point)))))))