Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 40 / 118e1904a8b284a2c5baf3f532a003ec4d000e
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 37189431FBC\r
6         for <notmuch@notmuchmail.org>; Sun,  1 Jul 2012 15:44:10 -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 s6NBfQvVZE0z for <notmuch@notmuchmail.org>;\r
17         Sun,  1 Jul 2012 15:44:09 -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 1A4E2431FAF\r
22         for <notmuch@notmuchmail.org>; Sun,  1 Jul 2012 15:44:09 -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 1SlSs6-0005fW-2W; Sun, 01 Jul 2012 23:44:07 +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 1SlSs5-0001Uq-MY; Sun, 01 Jul 2012 23:44:01 +0100\r
32 From: Mark Walters <markwalters1009@gmail.com>\r
33 To: Tomi Ollila <tomi.ollila@iki.fi>, notmuch@notmuchmail.org\r
34 Subject: Re: [PATCH] cli: notmuch-show with framing newlines between threads\r
35         in JSON.\r
36 In-Reply-To: <m24npr8701.fsf@guru.guru-group.fi>\r
37 References: <1341041024-5342-1-git-send-email-markwalters1009@gmail.com>\r
38         <m24npr8701.fsf@guru.guru-group.fi>\r
39 User-Agent: Notmuch/0.13.2+70~gb6a56e7 (http://notmuchmail.org) Emacs/23.4.1\r
40         (x86_64-pc-linux-gnu)\r
41 Date: Sun, 01 Jul 2012 23:43:57 +0100\r
42 Message-ID: <8762a72jbm.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: ca11c5bc5f73be30bedae6124641d972 (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 X-BeenThere: notmuch@notmuchmail.org\r
65 X-Mailman-Version: 2.1.13\r
66 Precedence: list\r
67 List-Id: "Use and development of the notmuch mail system."\r
68         <notmuch.notmuchmail.org>\r
69 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
70         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
71 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
72 List-Post: <mailto:notmuch@notmuchmail.org>\r
73 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
74 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
75         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
76 X-List-Received-Date: Sun, 01 Jul 2012 22:44:10 -0000\r
77 \r
78 On Sun, 01 Jul 2012, Tomi Ollila <tomi.ollila@iki.fi> wrote:\r
79 > On Sat, Jun 30 2012, Mark Walters <markwalters1009@gmail.com> wrote:\r
80 >\r
81 >> Add newlines between complete threads to make asynchronous parsing\r
82 >> of the JSON easier.\r
83 >> ---\r
84 >>\r
85 >> notmuch-pick uses the JSON output of notmuch show but, in many cases,\r
86 >> for many threads. This can take quite a long time when displaying a\r
87 >> large number of messages (say 20 seconds for the 10,000 messages in\r
88 >> the notmuch archive). Thus it is desirable to display results\r
89 >> incrementally in the same way that search currently does.\r
90 >>\r
91 >> To make this easier this patch adds newlines between each toplevel\r
92 >> thread. So the ouput becomes\r
93 >>\r
94 >> [\r
95 >> thread1\r
96 >> , thread2\r
97 >> , thread3\r
98 >> ...\r
99 >> , last_thread\r
100 >> ]\r
101 >>\r
102 >> Thus the parser can easily tell if it has enough data to do some more\r
103 >> parsing.\r
104 >>\r
105 >> Obviously, this changes the JSON output. This should not break any\r
106 >> consumer as the JSON parsers should not mind. However, it does break\r
107 >> several tests. Obviously, I will fix these but I wanted to check if\r
108 >> people were basically happy with the change first.\r
109 >\r
110 > To provide this feature rather than relying on newlines the parser should\r
111 > use it's state to notice when one thread ends. \r
112 >\r
113 > Such a change could be used (privately) for human consumption -- allowing \r
114 > free change of whitespace during inspection (in a debugging session or so).\r
115 > Computer software should not rely (or suffer) from any additional\r
116 > (or lack thereof) whitespace there is...\r
117 >\r
118 > ... or at least a really convicing argument for the chance needs to\r
119 > be presented (before "restricting" the json output notmuch spits out).\r
120 >\r
121 > Btw: AFAIC (json-read) parses the whole json object (ignoring whitespace,\r
122 > including newlines outside strings). So I quess notmuch-pick uses something\r
123 > slightly different (probably using json.el subroutines)..\r
124 \r
125 I was following Austin's suggestion (on irc and\r
126 id:"20120214152114.GQ27039@mit.edu"). The idea is that each thread in\r
127 the JSON output is an entire JSON object. Thus pick skips the first [\r
128 and the waits until there are two \n's in the incoming stream. Then it\r
129 knows that the complete first thread has been received and it parses\r
130 that with json-read as normal. The important thing is that it is trivial\r
131 to tell when a complete (and so parsable) JSON object has arrived.\r
132 \r
133 It seems to work, but I am definitely open to other approaches.\r
134 \r
135 > Btw2: I'm very interested to see notmuch-pick in action -- I just don't\r
136 > see this a way to do this particular support properly.\r
137 >\r
138 > Btw3: is search is ever going to use json we'll face the same problem -- \r
139 > unless writing each line as a separate json object (and starting to use \r
140 > s-expressions for speed)\r
141 >\r
142 >> Also, should devel/schemata be updated? It seems a little unclear as\r
143 >> this is not really a "JSON" change as the JSON does not care about the\r
144 >> newlines.\r
145 >>\r
146 >> Best wishes\r
147 \r
148 \r
149 > and best luck with your notmuch-pick work.\r
150 \r
151 Thanks!\r
152 \r
153 Mark\r
154 \r
155 >>\r
156 >>  notmuch-show.c |    5 +++++\r
157 >>  1 files changed, 5 insertions(+), 0 deletions(-)\r
158 >>\r
159 >> diff --git a/notmuch-show.c b/notmuch-show.c\r
160 >> index 195e318..4a1d699 100644\r
161 >> --- a/notmuch-show.c\r
162 >> +++ b/notmuch-show.c\r
163 >> @@ -942,6 +942,8 @@ do_show (void *ctx,\r
164 >>  \r
165 >>      if (format->message_set_start)\r
166 >>      fputs (format->message_set_start, stdout);\r
167 >> +    if (format == &format_json)\r
168 >> +    fputs ("\n", stdout);\r
169 >>  \r
170 >>      for (threads = notmuch_query_search_threads (query);\r
171 >>       notmuch_threads_valid (threads);\r
172 >> @@ -963,6 +965,9 @@ do_show (void *ctx,\r
173 >>      if (status && !res)\r
174 >>          res = status;\r
175 >>  \r
176 >> +    if (format == &format_json)\r
177 >> +        fputs ("\n", stdout);\r
178 >> +\r
179 >>      notmuch_thread_destroy (thread);\r
180 >>  \r
181 >>      }\r
182 >> -- \r
183 >> 1.7.9.1\r
184 >>\r
185 >> _______________________________________________\r
186 >> notmuch mailing list\r
187 >> notmuch@notmuchmail.org\r
188 >> http://notmuchmail.org/mailman/listinfo/notmuch\r