Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 44FDE41A547 for ; Tue, 30 Nov 2010 03:00:41 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 1.363 X-Spam-Level: * X-Spam-Status: No, score=1.363 tagged_above=-999 required=5 tests=[RDNS_DYNAMIC=0.363, TO_NO_BRKTS_DYNIP=1] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id F35gGCu46gRD for ; Tue, 30 Nov 2010 03:00:40 -0800 (PST) Received: from ut.hh.sledj.net (host81-149-164-25.in-addr.btopenworld.com [81.149.164.25]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id D2A80431FB6 for ; Tue, 30 Nov 2010 03:00:39 -0800 (PST) Received: by ut.hh.sledj.net (Postfix, from userid 1000) id 6CA1A59422B; Tue, 30 Nov 2010 11:00:29 +0000 (GMT) From: David Edmondson To: notmuch@notmuchmail.org Subject: [PATCH 4/4] emacs: Fix indentation, add comments. Date: Tue, 30 Nov 2010 11:00:25 +0000 Message-Id: <1291114825-3513-4-git-send-email-dme@dme.org> X-Mailer: git-send-email 1.7.2.3 In-Reply-To: <1291026599-14795-4-git-send-email-dme@dme.org> References: <1291026599-14795-4-git-send-email-dme@dme.org> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Nov 2010 11:00:41 -0000 `inhibit-redisplay' makes debugging hard - note this in a comment. --- emacs/notmuch.el | 81 ++++++++++++++++++++++++++++-------------------------- 1 files changed, 42 insertions(+), 39 deletions(-) diff --git a/emacs/notmuch.el b/emacs/notmuch.el index d561c6e..20d954b 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -722,10 +722,13 @@ foreground and blue background." (defun notmuch-search-process-insert (proc buffer string) (with-current-buffer buffer (let ((inhibit-read-only t) + ;; Comment out this next line to allow useful single-step + ;; during debugging. (inhibit-redisplay t) ;; Vectors are not as useful here. (json-array-type 'list) (json-object-type 'plist)) + (save-excursion ;; Insert the text, advancing the process marker (goto-char (point-max)) @@ -739,46 +742,46 @@ foreground and blue background." (save-excursion (goto-char notmuch-search-parse-start) - (while - (let ((next-char (json-peek))) - (cond - ;; No more data (yet). - ((eq next-char :json-eof) - nil) - - ;; Opening bracket or comma separator between - ;; objects. - ((or (char-equal next-char ?\[) - (char-equal next-char ?\,)) - (json-advance) - (delete-region notmuch-search-parse-start (point)) - t) - - ;; Closing array. - ((char-equal next-char ?\]) - ;; Consume both the closing bracket and any trailing - ;; whitespace (typically a carriage return). - (json-advance) - (json-skip-whitespace) - (delete-region notmuch-search-parse-start (point)) - nil) - - ;; Single object. - ((condition-case nil - (let ((object (json-read-object))) - ;; Delete the object that we consumed. - (delete-region notmuch-search-parse-start (point)) - ;; Insert the corresponding results. - (notmuch-search-process-insert-object object) - t) - (error nil))))) - - ;; Consume any white space between terms. - (let ((p (point))) + (while + (let ((next-char (json-peek))) + (cond + ;; No more data (yet). + ((eq next-char :json-eof) + nil) + + ;; Opening bracket or comma separator between + ;; objects. + ((or (char-equal next-char ?\[) + (char-equal next-char ?\,)) + (json-advance) + (delete-region notmuch-search-parse-start (point)) + t) + + ;; Closing array. + ((char-equal next-char ?\]) + ;; Consume both the closing bracket and any trailing + ;; whitespace (typically a carriage return). + (json-advance) (json-skip-whitespace) - (delete-region p (point))) - ;; Remember where we got up to. - (setq notmuch-search-parse-start (point))))))) + (delete-region notmuch-search-parse-start (point)) + nil) + + ;; Single object. + ((condition-case nil + (let ((object (json-read-object))) + ;; Delete the object that we consumed. + (delete-region notmuch-search-parse-start (point)) + ;; Insert the corresponding results. + (notmuch-search-process-insert-object object) + t) + (error nil))))) + + ;; Consume any white space between terms. + (let ((p (point))) + (json-skip-whitespace) + (delete-region p (point))) + ;; Remember where we got up to. + (setq notmuch-search-parse-start (point))))))) (defun notmuch-search-process-filter (proc string) "Process and filter the output of `notmuch search'." -- 1.7.2.3