unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] contrib: pick: use async parser from lib
@ 2012-10-28 13:37 Mark Walters
  2012-11-30  0:02 ` David Bremner
  2012-12-01 12:26 ` David Bremner
  0 siblings, 2 replies; 3+ messages in thread
From: Mark Walters @ 2012-10-28 13:37 UTC (permalink / raw)
  To: notmuch

This moves notmuch-pick to use the newly split out async json parser
from notmuch-lib.el. 

---

I hadn't expected the split out json parser to go in so quickly: this
moves notmuch-pick to use the new function. 

Best wishes

Mark



 contrib/notmuch-pick/notmuch-pick.el |   52 +++------------------------------
 1 files changed, 5 insertions(+), 47 deletions(-)

diff --git a/contrib/notmuch-pick/notmuch-pick.el b/contrib/notmuch-pick/notmuch-pick.el
index be6a91a..15ac5e8 100644
--- a/contrib/notmuch-pick/notmuch-pick.el
+++ b/contrib/notmuch-pick/notmuch-pick.el
@@ -435,7 +435,7 @@ Does NOT change the database."
   (unless (notmuch-pick-get-match)
     (notmuch-pick-next-matching-message))
   (while (and (not (notmuch-pick-get-match))
-	      (not (eq notmuch-pick-process-state 'end)))
+	      (get-buffer-process (current-buffer)))
     (message "waiting for message")
     (sit-for 0.1)
     (goto-char (point-min))
@@ -733,9 +733,6 @@ Complete list of currently available key bindings:
     (insert "\n")))
 
 
-(defvar notmuch-pick-json-parser nil
-  "Incremental JSON parser for the search process filter.")
-
 (defun notmuch-pick-process-filter (proc string)
   "Process and filter the output of \"notmuch show\" (for pick)"
   (let ((results-buf (process-buffer proc))
@@ -748,46 +745,10 @@ Complete list of currently available key bindings:
         ;; Insert new data
         (save-excursion
           (goto-char (point-max))
-          (insert string)))
-      (with-current-buffer results-buf
-	(save-excursion
-	  (goto-char (point-max))
-	  (while (not done)
-	    (condition-case nil
-		(case notmuch-pick-process-state
-		      ((begin)
-		       ;; Enter the results list
-		       (if (eq (notmuch-json-begin-compound
-				notmuch-pick-json-parser) 'retry)
-			   (setq done t)
-			 (setq notmuch-pick-process-state 'result)))
-		      ((result)
-		       ;; Parse a result
-		       (let ((result (notmuch-json-read notmuch-pick-json-parser)))
-			 (case result
-			       ((retry) (setq done t))
-			       ((end) (setq notmuch-pick-process-state 'end))
-			       (otherwise (notmuch-pick-insert-forest-thread result)))))
-		      ((end)
-		       ;; Any trailing data is unexpected
-		       (with-current-buffer parse-buf
-			 (skip-chars-forward " \t\r\n")
-			 (if (eobp)
-			     (setq done t)
-			   (signal 'json-error nil)))))
-	      (json-error
-	       ;; Do our best to resynchronize and ensure forward
-	       ;; progress
-	       (notmuch-pick-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))))))))
+          (insert string))
+	(notmuch-json-parse-partial-list 'notmuch-pick-insert-forest-thread
+					 'notmuch-pick-show-error
+					 results-buf)))))
 
 (defun notmuch-pick-worker (basic-query &optional query-context buffer)
   (interactive)
@@ -815,9 +776,6 @@ Complete list of currently available key bindings:
               ;; This buffer will be killed by the sentinel, which
               ;; should be called no matter how the process dies.
               (parse-buf (generate-new-buffer " *notmuch pick parse*")))
-          (set (make-local-variable 'notmuch-pick-process-state) 'begin)
-          (set (make-local-variable 'notmuch-pick-json-parser)
-               (notmuch-json-create-parser parse-buf))
           (process-put proc 'parse-buf parse-buf)
 	  (set-process-sentinel proc 'notmuch-pick-process-sentinel)
 	  (set-process-filter proc 'notmuch-pick-process-filter)
-- 
1.7.9.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] contrib: pick: use async parser from lib
  2012-10-28 13:37 [PATCH] contrib: pick: use async parser from lib Mark Walters
@ 2012-11-30  0:02 ` David Bremner
  2012-12-01 12:26 ` David Bremner
  1 sibling, 0 replies; 3+ messages in thread
From: David Bremner @ 2012-11-30  0:02 UTC (permalink / raw)
  To: Mark Walters, notmuch

Mark Walters <markwalters1009@gmail.com> writes:

> This moves notmuch-pick to use the newly split out async json parser
> from notmuch-lib.el. 

This looks fine and seems to work; I'm marking it ready.

d

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] contrib: pick: use async parser from lib
  2012-10-28 13:37 [PATCH] contrib: pick: use async parser from lib Mark Walters
  2012-11-30  0:02 ` David Bremner
@ 2012-12-01 12:26 ` David Bremner
  1 sibling, 0 replies; 3+ messages in thread
From: David Bremner @ 2012-12-01 12:26 UTC (permalink / raw)
  To: Mark Walters, notmuch

Mark Walters <markwalters1009@gmail.com> writes:

> This moves notmuch-pick to use the newly split out async json parser
> from notmuch-lib.el. 
>

pushed, 

d

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-12-01 12:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-28 13:37 [PATCH] contrib: pick: use async parser from lib Mark Walters
2012-11-30  0:02 ` David Bremner
2012-12-01 12:26 ` David Bremner

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).