--- /dev/null
+Return-Path: <dme@ut.hh.sledj.net>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 70A91431FB6\r
+ for <notmuch@notmuchmail.org>; Tue, 30 Nov 2010 03:00:38 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 1.363\r
+X-Spam-Level: *\r
+X-Spam-Status: No, score=1.363 tagged_above=-999 required=5\r
+ tests=[RDNS_DYNAMIC=0.363, TO_NO_BRKTS_DYNIP=1] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id FsWrmNF+JQ1K for <notmuch@notmuchmail.org>;\r
+ Tue, 30 Nov 2010 03:00:37 -0800 (PST)\r
+Received: from ut.hh.sledj.net (host81-149-164-25.in-addr.btopenworld.com\r
+ [81.149.164.25])\r
+ (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 61375431FB5\r
+ for <notmuch@notmuchmail.org>; Tue, 30 Nov 2010 03:00:37 -0800 (PST)\r
+Received: by ut.hh.sledj.net (Postfix, from userid 1000)\r
+ id E026659422B; Tue, 30 Nov 2010 11:00:26 +0000 (GMT)\r
+From: David Edmondson <dme@dme.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 1/4] emacs: JSON based search improvements.\r
+Date: Tue, 30 Nov 2010 11:00:22 +0000\r
+Message-Id: <1291114825-3513-1-git-send-email-dme@dme.org>\r
+X-Mailer: git-send-email 1.7.2.3\r
+In-Reply-To: <1291026599-14795-4-git-send-email-dme@dme.org>\r
+References: <1291026599-14795-4-git-send-email-dme@dme.org>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Tue, 30 Nov 2010 11:00:38 -0000\r
+\r
+Fix variable name typos.\r
+\r
+Attempt to avoid display flashing by removing newlines from the\r
+inserted string.\r
+\r
+Ease debugging by moving the `condition-case' closer into the code\r
+that it is really intended to cover (the parsing of the JSON object),\r
+allowing errors in the remaining code to still fire correctly. As a\r
+consequence, test for :json-eof when examining the next character to\r
+be parsed, as that throws an error that was previously covered by the\r
+`condition-case'.\r
+---\r
+ emacs/notmuch.el | 74 ++++++++++++++++++++++++++++++-----------------------\r
+ 1 files changed, 42 insertions(+), 32 deletions(-)\r
+\r
+diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
+index bde8c47..f4aefc8 100644\r
+--- a/emacs/notmuch.el\r
++++ b/emacs/notmuch.el\r
+@@ -717,57 +717,67 @@ foreground and blue background."\r
+ (put-text-property beg (point-marker) 'notmuch-search-subject subject)))\r
+ \r
+ (defvar notmuch-search-parse-start nil)\r
+-(make-variable-buffer-local 'notmuch-show-parse-start)\r
++(make-variable-buffer-local 'notmuch-search-parse-start)\r
+ \r
+ (defun notmuch-search-process-insert (proc buffer string)\r
+ (with-current-buffer buffer\r
+ (let ((inhibit-read-only t)\r
+ (inhibit-redisplay t)\r
+ ;; Vectors are not as useful here.\r
+- (json-array-type 'list)\r
+- object)\r
++ (json-array-type 'list))\r
+ (save-excursion\r
+ ;; Insert the text, advancing the process marker\r
+ (goto-char (point-max))\r
+- (insert string)\r
++ ;; Flatten the string (remove newlines) to reduce the flashing\r
++ ;; that occurs when we insert the multi-line object and then\r
++ ;; replace it with a single line summary. This is safe because\r
++ ;; we know that none of the JSON fields can contain newlines -\r
++ ;; only the whitespace between fields.\r
++ (insert (replace-regexp-in-string "\n" "" string))\r
+ (set-marker (process-mark proc) (point)))\r
+ \r
+ (save-excursion\r
+ (goto-char notmuch-search-parse-start)\r
+- (condition-case nil\r
+ (while\r
+- (cond\r
+- ;; Opening bracket or comma separator between\r
+- ;; objects.\r
+- ((or (char-equal (json-peek) ?\[)\r
+- (char-equal (json-peek) ?\,))\r
+- (json-advance)\r
+- (delete-region notmuch-search-parse-start (point))\r
+- t)\r
+-\r
+- ;; Closing array.\r
+- ((char-equal (json-peek) ?\])\r
+- ;; Consume both the closing bracket and any trailing\r
+- ;; whitespace (typically a carriage return).\r
+- (json-advance)\r
+- (json-skip-whitespace)\r
+- (delete-region notmuch-search-parse-start (point))\r
+- nil)\r
+-\r
+- ;; Single object.\r
+- ((setq object (json-read-object))\r
+- ;; Delete the object that we consumed.\r
+- (delete-region notmuch-search-parse-start (point))\r
+- ;; Insert the corresponding results.\r
+- (notmuch-search-process-insert-object object)\r
+- t))\r
++ (let ((next-char (json-peek)))\r
++ (cond\r
++ ;; No more data (yet).\r
++ ((eq next-char :json-eof)\r
++ nil)\r
++\r
++ ;; Opening bracket or comma separator between\r
++ ;; objects.\r
++ ((or (char-equal next-char ?\[)\r
++ (char-equal next-char ?\,))\r
++ (json-advance)\r
++ (delete-region notmuch-search-parse-start (point))\r
++ t)\r
++\r
++ ;; Closing array.\r
++ ((char-equal next-char ?\])\r
++ ;; Consume both the closing bracket and any trailing\r
++ ;; whitespace (typically a carriage return).\r
++ (json-advance)\r
++ (json-skip-whitespace)\r
++ (delete-region notmuch-search-parse-start (point))\r
++ nil)\r
++\r
++ ;; Single object.\r
++ ((condition-case nil\r
++ (let ((object (json-read-object)))\r
++ ;; Delete the object that we consumed.\r
++ (delete-region notmuch-search-parse-start (point))\r
++ ;; Insert the corresponding results.\r
++ (notmuch-search-process-insert-object object)\r
++ t)\r
++ (error nil)))))\r
++\r
+ ;; Consume any white space between terms.\r
+ (let ((p (point)))\r
+ (json-skip-whitespace)\r
+ (delete-region p (point)))\r
+ ;; Remember where we got up to.\r
+- (setq notmuch-search-parse-start (point)))\r
+- (error nil))))))\r
++ (setq notmuch-search-parse-start (point)))))))\r
+ \r
+ (defun notmuch-search-process-filter (proc string)\r
+ "Process and filter the output of `notmuch search'."\r
+-- \r
+1.7.2.3\r
+\r