In addition to being the Right Thing to do, this noticeably improves
the time taken to display the first page of search results, since it's
roughly an order of magnitude faster than the JSON parser.
Interestingly, it does *not* significantly improve the time to
completely fill a large search buffer because for large search
buffers, the cost of creating author invisibility overlays and
inserting text (which slows down with more overlays) dominates.
However, the time required to display the first page of results is
generally more important to the user experience.
(require 'notmuch-hello)
(require 'notmuch-maildir-fcc)
(require 'notmuch-message)
(require 'notmuch-hello)
(require 'notmuch-maildir-fcc)
(require 'notmuch-message)
+(require 'notmuch-parser)
(defcustom notmuch-search-result-format
`(("date" . "%12s ")
(defcustom notmuch-search-result-format
`(("date" . "%12s ")
(setq notmuch-search-target-thread "found")
(goto-char beg)))))
(setq notmuch-search-target-thread "found")
(goto-char beg)))))
-(defun notmuch-search-show-error (string &rest objects)
- (save-excursion
- (goto-char (point-max))
- (insert "Error: Unexpected output from notmuch search:\n")
- (insert (apply #'format string objects))
- (insert "\n")))
-
(defun notmuch-search-process-filter (proc string)
"Process and filter the output of \"notmuch search\""
(let ((results-buf (process-buffer proc))
(defun notmuch-search-process-filter (proc string)
"Process and filter the output of \"notmuch search\""
(let ((results-buf (process-buffer proc))
(save-excursion
(goto-char (point-max))
(insert string))
(save-excursion
(goto-char (point-max))
(insert string))
- (notmuch-json-parse-partial-list 'notmuch-search-show-result
- 'notmuch-search-show-error
+ (notmuch-sexp-parse-partial-list 'notmuch-search-show-result
results-buf)))))
(defun notmuch-search-tag-all (&optional tag-changes)
results-buf)))))
(defun notmuch-search-tag-all (&optional tag-changes)
(save-excursion
(let ((proc (notmuch-start-notmuch
"notmuch-search" buffer #'notmuch-search-process-sentinel
(save-excursion
(let ((proc (notmuch-start-notmuch
"notmuch-search" buffer #'notmuch-search-process-sentinel
- "search" "--format=json" "--format-version=1"
+ "search" "--format=sexp" "--format-version=1"
(if oldest-first
"--sort=oldest-first"
"--sort=newest-first")
(if oldest-first
"--sort=oldest-first"
"--sort=newest-first")
test_begin_subtest "Search handles subprocess error exit codes"
cat > notmuch_fail <<EOF
#!/bin/sh
test_begin_subtest "Search handles subprocess error exit codes"
cat > notmuch_fail <<EOF
#!/bin/sh
exit 1
EOF
chmod a+x notmuch_fail
exit 1
EOF
chmod a+x notmuch_fail
(test-output))"
sed -i -e 's/^\[.*\]$/[XXX]/' ERROR
test_expect_equal "$(cat OUTPUT; echo ---; cat MESSAGES; echo ---; cat ERROR)" "\
(test-output))"
sed -i -e 's/^\[.*\]$/[XXX]/' ERROR
test_expect_equal "$(cat OUTPUT; echo ---; cat MESSAGES; echo ---; cat ERROR)" "\
-Error: Unexpected output from notmuch search:
-This is output
End of search results.
---
$PWD/notmuch_fail exited with status 1 (see *Notmuch errors* for more details)
---
[XXX]
$PWD/notmuch_fail exited with status 1
End of search results.
---
$PWD/notmuch_fail exited with status 1 (see *Notmuch errors* for more details)
---
[XXX]
$PWD/notmuch_fail exited with status 1
-command: $PWD/notmuch_fail search --format\=json --format-version\=1 --sort\=newest-first tag\:inbox
+command: $PWD/notmuch_fail search --format\=sexp --format-version\=1 --sort\=newest-first tag\:inbox
exit status: 1"
test_begin_subtest "Search handles subprocess warnings"
cat > notmuch_fail <<EOF
#!/bin/sh
exit status: 1"
test_begin_subtest "Search handles subprocess warnings"
cat > notmuch_fail <<EOF
#!/bin/sh
echo This is a warning >&2
echo This is another warning >&2
exit 0
echo This is a warning >&2
echo This is another warning >&2
exit 0
(test-output))"
sed -i -e 's/^\[.*\]$/[XXX]/' ERROR
test_expect_equal "$(cat OUTPUT; echo ---; cat MESSAGES; echo ---; cat ERROR)" "\
(test-output))"
sed -i -e 's/^\[.*\]$/[XXX]/' ERROR
test_expect_equal "$(cat OUTPUT; echo ---; cat MESSAGES; echo ---; cat ERROR)" "\
-Error: Unexpected output from notmuch search:
-This is output
End of search results.
---
This is a warning (see *Notmuch errors* for more details)
End of search results.
---
This is a warning (see *Notmuch errors* for more details)