Re: [PATCH v4 01/16] add util/search-path.{c, h} to test for executables in $PATH
[notmuch-archives.git] / c1 / 7ab396688e260a1ee314235d27b25a89399636
1 Return-Path: <amdragon@mit.edu>\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 E80EA429E27\r
6         for <notmuch@notmuchmail.org>; Fri, 17 May 2013 21:33:08 -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.7\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id qNx0cGONGkaf for <notmuch@notmuchmail.org>;\r
16         Fri, 17 May 2013 21:33:02 -0700 (PDT)\r
17 Received: from dmz-mailsec-scanner-1.mit.edu (DMZ-MAILSEC-SCANNER-1.MIT.EDU\r
18         [18.9.25.12])\r
19         by olra.theworths.org (Postfix) with ESMTP id 4312E429E30\r
20         for <notmuch@notmuchmail.org>; Fri, 17 May 2013 21:32:25 -0700 (PDT)\r
21 X-AuditID: 1209190c-b7f566d000004c69-92-51970458ba7c\r
22 Received: from mailhub-auth-2.mit.edu ( [18.7.62.36])\r
23         by dmz-mailsec-scanner-1.mit.edu (Symantec Messaging Gateway) with SMTP\r
24         id 51.A4.19561.85407915; Sat, 18 May 2013 00:32:24 -0400 (EDT)\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH-1.MIT.EDU [18.9.28.11])\r
26         by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id r4I4WD1t016939; \r
27         Sat, 18 May 2013 00:32:13 -0400\r
28 Received: from drake.dyndns.org\r
29         (216-15-114-40.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com\r
30         [216.15.114.40]) (authenticated bits=0)\r
31         (User authenticated as amdragon@ATHENA.MIT.EDU)\r
32         by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id r4I4WBoQ018837\r
33         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
34         Sat, 18 May 2013 00:32:12 -0400\r
35 Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
36         (envelope-from <amdragon@mit.edu>)\r
37         id 1UdYo1-0001Z2-Lh; Sat, 18 May 2013 00:31:41 -0400\r
38 From: Austin Clements <amdragon@MIT.EDU>\r
39 To: notmuch@notmuchmail.org\r
40 Subject: [PATCH 5/5] emacs: Use streaming S-expr parser for search\r
41 Date: Sat, 18 May 2013 00:31:12 -0400\r
42 Message-Id: <1368851472-5382-6-git-send-email-amdragon@mit.edu>\r
43 X-Mailer: git-send-email 1.7.10.4\r
44 In-Reply-To: <1368851472-5382-1-git-send-email-amdragon@mit.edu>\r
45 References: <1368851472-5382-1-git-send-email-amdragon@mit.edu>\r
46 X-Brightmail-Tracker:\r
47  H4sIAAAAAAAAA+NgFtrFIsWRmVeSWpSXmKPExsUixG6nohvBMj3Q4GKnocXquTwW12/OZHZg\r
48         8tg56y67x7NVt5gDmKK4bFJSczLLUov07RK4Mp7PVSq4Ll/x/vBVxgbGt5JdjJwcEgImElse\r
49         t7JA2GISF+6tZwOxhQT2MUqsX5cLYW9klFj617iLkQvIvsMksWLhI2YIZy6jxJqGO+wgVWwC\r
50         GhLb9i9nBLFFBKQldt6dzQpiMws4SnzevwhsqrCAk8Tsf//AbBYBVYnd5/6C2bwC9hIvvj1n\r
51         h7hCUaL72QSwOKeAg8Th+cegLrKX6Lpwk20CI/8CRoZVjLIpuVW6uYmZOcWpybrFyYl5ealF\r
52         uoZ6uZkleqkppZsYQUHEKcmzg/HNQaVDjAIcjEo8vB9cpwUKsSaWFVfmHmKU5GBSEuU1+QcU\r
53         4kvKT6nMSCzOiC8qzUktPsQowcGsJML7vBgox5uSWFmVWpQPk5LmYFES572cctNfSCA9sSQ1\r
54         OzW1ILUIJivDwaEkwVvEPD1QSLAoNT21Ii0zpwQhzcTBCTKcB2i4FUgNb3FBYm5xZjpE/hSj\r
55         opQ4bzFIQgAkkVGaB9cLi/JXjOJArwjzSoNU8QATBFz3K6DBTECDWa9NBRlckoiQkmpg3BHc\r
56         bRz5yvsX/47W9CcG+fHf1TMVyv+sYZmlb2iv8usAg3uc5JNJQK9N3GWgOJk3f7XeDM7YJZ6J\r
57         iff+hDtfZ/lTW7Gr6Vh2tNPM+9NUlgqHKDuFWNiumy9y+w1nzErW64KHeD2KeFONOLuLlq6c\r
58         nRLUe/RkQ1z3RYaoJa8OGVvfdlnleEmJpTgj0VCLuag4EQC3mWWVzQIAAA==\r
59 X-BeenThere: notmuch@notmuchmail.org\r
60 X-Mailman-Version: 2.1.13\r
61 Precedence: list\r
62 List-Id: "Use and development of the notmuch mail system."\r
63         <notmuch.notmuchmail.org>\r
64 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
65         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
66 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
67 List-Post: <mailto:notmuch@notmuchmail.org>\r
68 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
69 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
70         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
71 X-List-Received-Date: Sat, 18 May 2013 04:33:09 -0000\r
72 \r
73 In addition to being the Right Thing to do, this noticeably improves\r
74 the time taken to display the first page of search results, since it's\r
75 roughly an order of magnitude faster than the JSON parser.\r
76 Interestingly, it does *not* significantly improve the time to\r
77 completely fill a large search buffer because for large search\r
78 buffers, the cost of creating author invisibility overlays and\r
79 inserting text (which slows down with more overlays) dominates.\r
80 However, the time required to display the first page of results is\r
81 generally more important to the user experience.\r
82 ---\r
83  emacs/notmuch.el |   13 +++----------\r
84  test/emacs       |   10 +++-------\r
85  2 files changed, 6 insertions(+), 17 deletions(-)\r
86 \r
87 diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
88 index b8d9c44..5a8c957 100644\r
89 --- a/emacs/notmuch.el\r
90 +++ b/emacs/notmuch.el\r
91 @@ -58,6 +58,7 @@\r
92  (require 'notmuch-hello)\r
93  (require 'notmuch-maildir-fcc)\r
94  (require 'notmuch-message)\r
95 +(require 'notmuch-parser)\r
96  \r
97  (defcustom notmuch-search-result-format\r
98    `(("date" . "%12s ")\r
99 @@ -809,13 +810,6 @@ non-authors is found, assume that all of the authors match."\r
100         (setq notmuch-search-target-thread "found")\r
101         (goto-char beg)))))\r
102  \r
103 -(defun notmuch-search-show-error (string &rest objects)\r
104 -  (save-excursion\r
105 -    (goto-char (point-max))\r
106 -    (insert "Error: Unexpected output from notmuch search:\n")\r
107 -    (insert (apply #'format string objects))\r
108 -    (insert "\n")))\r
109 -\r
110  (defun notmuch-search-process-filter (proc string)\r
111    "Process and filter the output of \"notmuch search\""\r
112    (let ((results-buf (process-buffer proc))\r
113 @@ -829,8 +823,7 @@ non-authors is found, assume that all of the authors match."\r
114         (save-excursion\r
115           (goto-char (point-max))\r
116           (insert string))\r
117 -       (notmuch-json-parse-partial-list 'notmuch-search-show-result\r
118 -                                        'notmuch-search-show-error\r
119 +       (notmuch-sexp-parse-partial-list 'notmuch-search-show-result\r
120                                          results-buf)))))\r
121  \r
122  (defun notmuch-search-tag-all (&optional tag-changes)\r
123 @@ -933,7 +926,7 @@ Other optional parameters are used as follows:\r
124        (save-excursion\r
125         (let ((proc (notmuch-start-notmuch\r
126                      "notmuch-search" buffer #'notmuch-search-process-sentinel\r
127 -                    "search" "--format=json" "--format-version=1"\r
128 +                    "search" "--format=sexp" "--format-version=1"\r
129                      (if oldest-first\r
130                          "--sort=oldest-first"\r
131                        "--sort=newest-first")\r
132 diff --git a/test/emacs b/test/emacs\r
133 index d38ae8c..7d42abf 100755\r
134 --- a/test/emacs\r
135 +++ b/test/emacs\r
136 @@ -856,7 +856,7 @@ test_expect_success "Rendering HTML mail with images" \\r
137  test_begin_subtest "Search handles subprocess error exit codes"\r
138  cat > notmuch_fail <<EOF\r
139  #!/bin/sh\r
140 -echo This is output\r
141 +echo '()'\r
142  exit 1\r
143  EOF\r
144  chmod a+x notmuch_fail\r
145 @@ -871,21 +871,19 @@ test_emacs "(let ((notmuch-command \"$PWD/notmuch_fail\"))\r
146                (test-output))"\r
147  sed -i -e 's/^\[.*\]$/[XXX]/' ERROR\r
148  test_expect_equal "$(cat OUTPUT; echo ---; cat MESSAGES; echo ---; cat ERROR)" "\\r
149 -Error: Unexpected output from notmuch search:\r
150 -This is output\r
151  End of search results.\r
152  ---\r
153  $PWD/notmuch_fail exited with status 1 (see *Notmuch errors* for more details)\r
154  ---\r
155  [XXX]\r
156  $PWD/notmuch_fail exited with status 1\r
157 -command: $PWD/notmuch_fail search --format\=json --format-version\=1 --sort\=newest-first tag\:inbox\r
158 +command: $PWD/notmuch_fail search --format\=sexp --format-version\=1 --sort\=newest-first tag\:inbox\r
159  exit status: 1"\r
160  \r
161  test_begin_subtest "Search handles subprocess warnings"\r
162  cat > notmuch_fail <<EOF\r
163  #!/bin/sh\r
164 -echo This is output\r
165 +echo '()'\r
166  echo This is a warning >&2\r
167  echo This is another warning >&2\r
168  exit 0\r
169 @@ -903,8 +901,6 @@ test_emacs "(let ((notmuch-command \"$PWD/notmuch_fail\"))\r
170                (test-output))"\r
171  sed -i -e 's/^\[.*\]$/[XXX]/' ERROR\r
172  test_expect_equal "$(cat OUTPUT; echo ---; cat MESSAGES; echo ---; cat ERROR)" "\\r
173 -Error: Unexpected output from notmuch search:\r
174 -This is output\r
175  End of search results.\r
176  ---\r
177  This is a warning (see *Notmuch errors* for more details)\r
178 -- \r
179 1.7.10.4\r
180 \r