[PATCH] configure: add --without-api-docs option
[notmuch-archives.git] / 5f / 83ee81ba52510bb93bcdd1271f0b7254ee8ca0
1 Return-Path: <m.walters@qmul.ac.uk>\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 B1D12431FBD\r
6         for <notmuch@notmuchmail.org>; Mon, 30 Jul 2012 13:39:18 -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: -1.098\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5\r
12         tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,\r
13         NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id f39rU0JAFBxS for <notmuch@notmuchmail.org>;\r
17         Mon, 30 Jul 2012 13:39:18 -0700 (PDT)\r
18 Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])\r
19         (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id DD908431FAE\r
22         for <notmuch@notmuchmail.org>; Mon, 30 Jul 2012 13:39:17 -0700 (PDT)\r
23 Received: from smtp.qmul.ac.uk ([138.37.6.40])\r
24         by mail2.qmul.ac.uk with esmtp (Exim 4.71)\r
25         (envelope-from <m.walters@qmul.ac.uk>)\r
26         id 1SvwkG-0002PL-4Q; Mon, 30 Jul 2012 21:39:16 +0100\r
27 Received: from 94-192-233-223.zone6.bethere.co.uk ([94.192.233.223]\r
28         helo=localhost)\r
29         by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69)\r
30         (envelope-from <m.walters@qmul.ac.uk>)\r
31         id 1SvwkF-0002Fs-IZ; Mon, 30 Jul 2012 21:39:15 +0100\r
32 From: Mark Walters <markwalters1009@gmail.com>\r
33 To: Austin Clements <amdragon@MIT.EDU>\r
34 Subject: [PATCH v2 (Draft)] emacs: split async json parser into utility\r
35         function\r
36 In-Reply-To: <87obmxyokt.fsf@qmul.ac.uk>\r
37 References: <87k3xo85tv.fsf@qmul.ac.uk> <20120730013506.GF8502@mit.edu>\r
38         <87obmxyokt.fsf@qmul.ac.uk>\r
39 User-Agent: Notmuch/0.13.2+96~g634443c (http://notmuchmail.org) Emacs/23.4.1\r
40         (x86_64-pc-linux-gnu)\r
41 Date: Mon, 30 Jul 2012 21:39:15 +0100\r
42 Message-ID: <87k3xlyoek.fsf@qmul.ac.uk>\r
43 MIME-Version: 1.0\r
44 Content-Type: text/plain; charset=us-ascii\r
45 X-Sender-Host-Address: 94.192.233.223\r
46 X-QM-SPAM-Info: Sender has good ham record.  :)\r
47 X-QM-Body-MD5: b2244b3c95e352eb68571d6b4d806deb (of first 20000 bytes)\r
48 X-SpamAssassin-Score: -1.8\r
49 X-SpamAssassin-SpamBar: -\r
50 X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
51         determine if it is\r
52         spam. We require at least 5.0 points to mark a message as spam.\r
53         This message scored -1.8 points.\r
54         Summary of the scoring: \r
55         * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/,\r
56         *      medium trust\r
57         *      [138.37.6.40 listed in list.dnswl.org]\r
58         * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\r
59         provider *      (markwalters1009[at]gmail.com)\r
60         * -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay\r
61         *      domain\r
62         *  0.5 AWL AWL: From: address is in the auto white-list\r
63 X-QM-Scan-Virus: ClamAV says the message is clean\r
64 Cc: notmuch@notmuchmail.org\r
65 X-BeenThere: notmuch@notmuchmail.org\r
66 X-Mailman-Version: 2.1.13\r
67 Precedence: list\r
68 List-Id: "Use and development of the notmuch mail system."\r
69         <notmuch.notmuchmail.org>\r
70 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
71         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
72 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
73 List-Post: <mailto:notmuch@notmuchmail.org>\r
74 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
75 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
76         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
77 X-List-Received-Date: Mon, 30 Jul 2012 20:39:18 -0000\r
78 \r
79 \r
80 Split out the json parser into a utility function.\r
81 ---\r
82 \r
83 Most of this patch is code movement: but I don't see how to arrange the\r
84 patch to show that.\r
85 \r
86 Best wishes\r
87 \r
88 Mark\r
89 \r
90  emacs/notmuch.el |  101 +++++++++++++++++++++++++++++++-----------------------\r
91  1 files changed, 58 insertions(+), 43 deletions(-)\r
92 \r
93 diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
94 index fd1836f..23ab499 100644\r
95 --- a/emacs/notmuch.el\r
96 +++ b/emacs/notmuch.el\r
97 @@ -809,11 +809,60 @@ non-authors is found, assume that all of the authors match."\r
98      (insert (apply #'format string objects))\r
99      (insert "\n")))\r
100  \r
101 -(defvar notmuch-search-process-state nil\r
102 -  "Parsing state of the search process filter.")\r
103 -\r
104 -(defvar notmuch-search-json-parser nil\r
105 -  "Incremental JSON parser for the search process filter.")\r
106 +(defvar notmuch-json-state nil\r
107 +  "State of the JSON parser.")\r
108 +\r
109 +(defvar notmuch-json-parser nil\r
110 +  "Incremental JSON parser.")\r
111 +\r
112 +(defun notmuch-json-parse-partial-list (result-function error-function results-buf)\r
113 +  "Parse a partial JSON list from current buffer.\r
114 +\r
115 +This function consumes a JSON list from the current buffer,\r
116 +applying RESULT-FUNCTION in buffer RESULT-BUFFER to each complete\r
117 +value in the list.  It operates incrementally and should be\r
118 +called whenever the buffer has been extended with additional\r
119 +data.\r
120 +\r
121 +If there is a syntax error, this will attempt to resynchronize\r
122 +with the input and will apply ERROR-FUNCTION in buffer\r
123 +RESULT-BUFFER to any input that was skipped."\r
124 +  (let (done)\r
125 +    (unless (local-variable-p 'notmuch-json-parser)\r
126 +      (set (make-local-variable 'notmuch-json-parser)\r
127 +          (notmuch-json-create-parser (current-buffer)))\r
128 +      (set (make-local-variable 'notmuch-json-state) 'begin))\r
129 +    (while (not done)\r
130 +      (condition-case nil\r
131 +         (case notmuch-json-state\r
132 +               ((begin)\r
133 +                ;; Enter the results list\r
134 +                (if (eq (notmuch-json-begin-compound\r
135 +                         notmuch-json-parser) 'retry)\r
136 +                    (setq done t)\r
137 +                  (setq notmuch-json-state 'result)))\r
138 +               ((result)\r
139 +                ;; Parse a result\r
140 +                (let ((result (notmuch-json-read notmuch-json-parser)))\r
141 +                  (case result\r
142 +                        ((retry) (setq done t))\r
143 +                        ((end) (setq notmuch-json-state 'end))\r
144 +                        (otherwise (with-current-buffer results-buf\r
145 +                                     (funcall result-function result))))))\r
146 +               ((end)\r
147 +                ;; Any trailing data is unexpected\r
148 +                (notmuch-json-eof notmuch-json-parser)\r
149 +                (setq done t)))\r
150 +       (json-error\r
151 +        ;; Do our best to resynchronize and ensure forward\r
152 +        ;; progress\r
153 +        (let ((bad (buffer-substring (line-beginning-position)\r
154 +                                     (line-end-position))))\r
155 +          (forward-line)\r
156 +          (with-current-buffer results-buf\r
157 +            (funcall error-function bad))))))\r
158 +    ;; Clear out what we've parsed\r
159 +    (delete-region (point-min) (point))))\r
160  \r
161  (defun notmuch-search-process-filter (proc string)\r
162    "Process and filter the output of \"notmuch search\""\r
163 @@ -827,41 +876,10 @@ non-authors is found, assume that all of the authors match."\r
164         ;; Insert new data\r
165         (save-excursion\r
166           (goto-char (point-max))\r
167 -         (insert string)))\r
168 -      (with-current-buffer results-buf\r
169 -       (while (not done)\r
170 -         (condition-case nil\r
171 -             (case notmuch-search-process-state\r
172 -               ((begin)\r
173 -                ;; Enter the results list\r
174 -                (if (eq (notmuch-json-begin-compound\r
175 -                         notmuch-search-json-parser) 'retry)\r
176 -                    (setq done t)\r
177 -                  (setq notmuch-search-process-state 'result)))\r
178 -               ((result)\r
179 -                ;; Parse a result\r
180 -                (let ((result (notmuch-json-read notmuch-search-json-parser)))\r
181 -                  (case result\r
182 -                    ((retry) (setq done t))\r
183 -                    ((end) (setq notmuch-search-process-state 'end))\r
184 -                    (otherwise (notmuch-search-show-result result)))))\r
185 -               ((end)\r
186 -                ;; Any trailing data is unexpected\r
187 -                (notmuch-json-eof notmuch-search-json-parser)\r
188 -                (setq done t)))\r
189 -           (json-error\r
190 -            ;; Do our best to resynchronize and ensure forward\r
191 -            ;; progress\r
192 -            (notmuch-search-show-error\r
193 -             "%s"\r
194 -             (with-current-buffer parse-buf\r
195 -               (let ((bad (buffer-substring (line-beginning-position)\r
196 -                                            (line-end-position))))\r
197 -                 (forward-line)\r
198 -                 bad))))))\r
199 -       ;; Clear out what we've parsed\r
200 -       (with-current-buffer parse-buf\r
201 -         (delete-region (point-min) (point)))))))\r
202 +         (insert string))\r
203 +       (notmuch-json-parse-partial-list 'notmuch-search-show-result\r
204 +                                        'notmuch-search-show-error\r
205 +                                        results-buf)))))\r
206  \r
207  (defun notmuch-search-tag-all (&optional tag-changes)\r
208    "Add/remove tags from all messages in current search buffer.\r
209 @@ -973,9 +991,6 @@ Other optional parameters are used as follows:\r
210               ;; This buffer will be killed by the sentinel, which\r
211               ;; should be called no matter how the process dies.\r
212               (parse-buf (generate-new-buffer " *notmuch search parse*")))\r
213 -         (set (make-local-variable 'notmuch-search-process-state) 'begin)\r
214 -         (set (make-local-variable 'notmuch-search-json-parser)\r
215 -              (notmuch-json-create-parser parse-buf))\r
216           (process-put proc 'parse-buf parse-buf)\r
217           (set-process-sentinel proc 'notmuch-search-process-sentinel)\r
218           (set-process-filter proc 'notmuch-search-process-filter)\r
219 -- \r
220 1.7.9.1\r
221 \r