[PATCH] This patch is a little finger excercise for working with git. I found a piece...
[notmuch-archives.git] / 2e / ece307348c01999ba14916fb3d35ece5769c87
1 Return-Path: <markwalters1009@gmail.com>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 9236F431FCF\r
6         for <notmuch@notmuchmail.org>; Sun, 28 Oct 2012 06:37:17 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0.201\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
14         RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
15 Received: from olra.theworths.org ([127.0.0.1])\r
16         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
17         with ESMTP id lNl8o1TE9-e9 for <notmuch@notmuchmail.org>;\r
18         Sun, 28 Oct 2012 06:37:17 -0700 (PDT)\r
19 Received: from mail-wi0-f173.google.com (mail-wi0-f173.google.com\r
20         [209.85.212.173]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
21         (No client certificate requested)\r
22         by olra.theworths.org (Postfix) with ESMTPS id D3BFA431FAF\r
23         for <notmuch@notmuchmail.org>; Sun, 28 Oct 2012 06:37:16 -0700 (PDT)\r
24 Received: by mail-wi0-f173.google.com with SMTP id hm4so1231150wib.2\r
25         for <notmuch@notmuchmail.org>; Sun, 28 Oct 2012 06:37:15 -0700 (PDT)\r
26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
27         h=from:to:cc:subject:date:message-id:x-mailer;\r
28         bh=VAp1I7ti0Vnq+/HbGWGGOkWZ9e9YLHtXkonTs3C2i6E=;\r
29         b=Ak2CNrDnqGH67O4f6SAYTzPlvENWH/z6GlwYQatvxXpR3rRITYAzGcwlBNjQGr3jvB\r
30         dWXRUU5OwFKcdKKRMvRrUKA2AyQQbo0HLkBlAj+ahvS2ARafXEg3ke0JpshJMWAIuiqR\r
31         hhD2Lj3TOtIIOm54KXwYP0OSET/Rh2jGy8Lpnh4HwoKHm8mH1tpHSwwoQ+nwsN379aOC\r
32         6Lt5tS9tFt233/RHNz9f0AsjLwDj8ihiq0kxrcSevqPuJ78ahfyCxD5jq8nxGOb6Ea2q\r
33         sqQWT2p5yNxKYUxgIjXm/tzPtEDRvdnTDMAjsmEl22S86M0n18A3ZCikMmyfo4vJAZVu\r
34         GgiA==\r
35 Received: by 10.180.8.134 with SMTP id r6mr11475074wia.18.1351431435519;\r
36         Sun, 28 Oct 2012 06:37:15 -0700 (PDT)\r
37 Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])\r
38         by mx.google.com with ESMTPS id bf6sm3156751wib.3.2012.10.28.06.37.13\r
39         (version=TLSv1/SSLv3 cipher=OTHER);\r
40         Sun, 28 Oct 2012 06:37:14 -0700 (PDT)\r
41 From: Mark Walters <markwalters1009@gmail.com>\r
42 To: notmuch@notmuchmail.org\r
43 Subject: [PATCH] contrib: pick: use async parser from lib\r
44 Date: Sun, 28 Oct 2012 13:37:10 +0000\r
45 Message-Id: <1351431430-5308-1-git-send-email-markwalters1009@gmail.com>\r
46 X-Mailer: git-send-email 1.7.9.1\r
47 X-BeenThere: notmuch@notmuchmail.org\r
48 X-Mailman-Version: 2.1.13\r
49 Precedence: list\r
50 List-Id: "Use and development of the notmuch mail system."\r
51         <notmuch.notmuchmail.org>\r
52 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
53         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
54 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
55 List-Post: <mailto:notmuch@notmuchmail.org>\r
56 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
57 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
58         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
59 X-List-Received-Date: Sun, 28 Oct 2012 13:37:17 -0000\r
60 \r
61 This moves notmuch-pick to use the newly split out async json parser\r
62 from notmuch-lib.el. \r
63 \r
64 ---\r
65 \r
66 I hadn't expected the split out json parser to go in so quickly: this\r
67 moves notmuch-pick to use the new function. \r
68 \r
69 Best wishes\r
70 \r
71 Mark\r
72 \r
73 \r
74 \r
75  contrib/notmuch-pick/notmuch-pick.el |   52 +++------------------------------\r
76  1 files changed, 5 insertions(+), 47 deletions(-)\r
77 \r
78 diff --git a/contrib/notmuch-pick/notmuch-pick.el b/contrib/notmuch-pick/notmuch-pick.el\r
79 index be6a91a..15ac5e8 100644\r
80 --- a/contrib/notmuch-pick/notmuch-pick.el\r
81 +++ b/contrib/notmuch-pick/notmuch-pick.el\r
82 @@ -435,7 +435,7 @@ Does NOT change the database."\r
83    (unless (notmuch-pick-get-match)\r
84      (notmuch-pick-next-matching-message))\r
85    (while (and (not (notmuch-pick-get-match))\r
86 -             (not (eq notmuch-pick-process-state 'end)))\r
87 +             (get-buffer-process (current-buffer)))\r
88      (message "waiting for message")\r
89      (sit-for 0.1)\r
90      (goto-char (point-min))\r
91 @@ -733,9 +733,6 @@ Complete list of currently available key bindings:\r
92      (insert "\n")))\r
93  \r
94  \r
95 -(defvar notmuch-pick-json-parser nil\r
96 -  "Incremental JSON parser for the search process filter.")\r
97 -\r
98  (defun notmuch-pick-process-filter (proc string)\r
99    "Process and filter the output of \"notmuch show\" (for pick)"\r
100    (let ((results-buf (process-buffer proc))\r
101 @@ -748,46 +745,10 @@ Complete list of currently available key bindings:\r
102          ;; Insert new data\r
103          (save-excursion\r
104            (goto-char (point-max))\r
105 -          (insert string)))\r
106 -      (with-current-buffer results-buf\r
107 -       (save-excursion\r
108 -         (goto-char (point-max))\r
109 -         (while (not done)\r
110 -           (condition-case nil\r
111 -               (case notmuch-pick-process-state\r
112 -                     ((begin)\r
113 -                      ;; Enter the results list\r
114 -                      (if (eq (notmuch-json-begin-compound\r
115 -                               notmuch-pick-json-parser) 'retry)\r
116 -                          (setq done t)\r
117 -                        (setq notmuch-pick-process-state 'result)))\r
118 -                     ((result)\r
119 -                      ;; Parse a result\r
120 -                      (let ((result (notmuch-json-read notmuch-pick-json-parser)))\r
121 -                        (case result\r
122 -                              ((retry) (setq done t))\r
123 -                              ((end) (setq notmuch-pick-process-state 'end))\r
124 -                              (otherwise (notmuch-pick-insert-forest-thread result)))))\r
125 -                     ((end)\r
126 -                      ;; Any trailing data is unexpected\r
127 -                      (with-current-buffer parse-buf\r
128 -                        (skip-chars-forward " \t\r\n")\r
129 -                        (if (eobp)\r
130 -                            (setq done t)\r
131 -                          (signal 'json-error nil)))))\r
132 -             (json-error\r
133 -              ;; Do our best to resynchronize and ensure forward\r
134 -              ;; progress\r
135 -              (notmuch-pick-show-error\r
136 -               "%s"\r
137 -               (with-current-buffer parse-buf\r
138 -                 (let ((bad (buffer-substring (line-beginning-position)\r
139 -                                              (line-end-position))))\r
140 -                   (forward-line)\r
141 -                   bad))))))\r
142 -         ;; Clear out what we've parsed\r
143 -         (with-current-buffer parse-buf\r
144 -           (delete-region (point-min) (point))))))))\r
145 +          (insert string))\r
146 +       (notmuch-json-parse-partial-list 'notmuch-pick-insert-forest-thread\r
147 +                                        'notmuch-pick-show-error\r
148 +                                        results-buf)))))\r
149  \r
150  (defun notmuch-pick-worker (basic-query &optional query-context buffer)\r
151    (interactive)\r
152 @@ -815,9 +776,6 @@ Complete list of currently available key bindings:\r
153                ;; This buffer will be killed by the sentinel, which\r
154                ;; should be called no matter how the process dies.\r
155                (parse-buf (generate-new-buffer " *notmuch pick parse*")))\r
156 -          (set (make-local-variable 'notmuch-pick-process-state) 'begin)\r
157 -          (set (make-local-variable 'notmuch-pick-json-parser)\r
158 -               (notmuch-json-create-parser parse-buf))\r
159            (process-put proc 'parse-buf parse-buf)\r
160           (set-process-sentinel proc 'notmuch-pick-process-sentinel)\r
161           (set-process-filter proc 'notmuch-pick-process-filter)\r
162 -- \r
163 1.7.9.1\r
164 \r