From: Mark Walters Date: Sat, 27 Oct 2012 09:34:11 +0000 (+0100) Subject: [PATCH v4 2/3] emacs: Rename incremental JSON internal variables X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=c00a02887d94155afeebede08af34082600d5127;p=notmuch-archives.git [PATCH v4 2/3] emacs: Rename incremental JSON internal variables --- diff --git a/5e/41740c0fd93a2f955e883c810fef683fdfc638 b/5e/41740c0fd93a2f955e883c810fef683fdfc638 new file mode 100644 index 000000000..ff0ddaa5b --- /dev/null +++ b/5e/41740c0fd93a2f955e883c810fef683fdfc638 @@ -0,0 +1,163 @@ +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 4A53B429E27 + for ; Sat, 27 Oct 2012 02:34:28 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0.201 +X-Spam-Level: +X-Spam-Status: No, score=0.201 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001, + RCVD_IN_DNSWL_LOW=-0.7] 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 dLgfNPBtyTxn for ; + Sat, 27 Oct 2012 02:34:26 -0700 (PDT) +Received: from mail-wg0-f41.google.com (mail-wg0-f41.google.com + [74.125.82.41]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client + certificate requested) by olra.theworths.org (Postfix) with ESMTPS id + 28D87431FAE for ; Sat, 27 Oct 2012 02:34:23 -0700 + (PDT) +Received: by mail-wg0-f41.google.com with SMTP id ds1so721318wgb.2 + for ; Sat, 27 Oct 2012 02:34:22 -0700 (PDT) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; + bh=1cL/z/hzz5Z8WshrioNvUn9w7QoptCGVFOept9pPM3Q=; + b=ZvSX9/uyrxdOmJtmfIYdOnG0pKjudoXINRaOcBQ3FF6RZvHD5kFAmcJsPtPRTHZ00G + DuNeARXWhjaykm88s6i8QSaFYArG/6EdBaSc/qu5W9lfgkNdzNsblceRHXLLUogDlDpI + 0pT69sXjemOf/ZfoEXbDqMVkAXgdZBm+ymoM2XnHexA5rG8WgyisUHNWecNxljQwscz7 + ixwDSP6tvV3O4y8HD3kEvSiSapVPHyXRIt5FBTXeFpdty5NkLDkTcbS9FG8FvpKjaE6n + c1iy81xpBHETn6ByTujfE/JScbZumPmk4DnchBIXHeCVavT25DpwIW/ivKCSPwMgmhxJ + U9SA== +Received: by 10.216.220.38 with SMTP id n38mr13386078wep.56.1351330462000; + Sat, 27 Oct 2012 02:34:22 -0700 (PDT) +Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31]) + by mx.google.com with ESMTPS id dm2sm1560669wib.4.2012.10.27.02.34.20 + (version=TLSv1/SSLv3 cipher=OTHER); + Sat, 27 Oct 2012 02:34:21 -0700 (PDT) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [PATCH v4 2/3] emacs: Rename incremental JSON internal variables +Date: Sat, 27 Oct 2012 10:34:11 +0100 +Message-Id: <1351330452-8348-3-git-send-email-markwalters1009@gmail.com> +X-Mailer: git-send-email 1.7.9.1 +In-Reply-To: <1351330452-8348-1-git-send-email-markwalters1009@gmail.com> +References: <1351330452-8348-1-git-send-email-markwalters1009@gmail.com> +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: Sat, 27 Oct 2012 09:34:28 -0000 + +This patch just renames the internal variables for the JSON parser now +it is no longer specific to search mode. It also fixes up the white +space after the previous patch. There should be no functional changes. +--- + emacs/notmuch.el | 56 ++++++++++++++++++++++++++++++----------------------- + 1 files changed, 32 insertions(+), 24 deletions(-) + +diff --git a/emacs/notmuch.el b/emacs/notmuch.el +index 799c621..e3610d6 100644 +--- a/emacs/notmuch.el ++++ b/emacs/notmuch.el +@@ -820,11 +820,15 @@ non-authors is found, assume that all of the authors match." + (insert (apply #'format string objects)) + (insert "\n"))) + +-(defvar notmuch-search-process-state nil +- "Parsing state of the search process filter.") ++;; These two variables are internal variables to the parsing ++;; routines. They are always used buffer local but need to be declared ++;; globally to avoid compiler warnings. + +-(defvar notmuch-search-json-parser nil +- "Incremental JSON parser for the search process filter.") ++(defvar notmuch-json-state nil ++ "Internal incremental JSON parser object: local to the buffer being parsed.") ++ ++(defvar notmuch-json-parser nil ++ "State of the internal JSON parser: local to the buffer being parsed.") + + (defun notmuch-search-process-filter (proc string) + "Process and filter the output of \"notmuch search\"" +@@ -854,42 +858,46 @@ data. + + If there is a syntax error, this will attempt to resynchronize + with the input and will apply ERROR-FUNCTION in buffer +-RESULT-BUFFER to any input that was skipped." ++RESULT-BUFFER to any input that was skipped. ++ ++It sets up all the needed internal variables: the caller just ++needs to call it with point in the same place that the parser ++left it." + (let (done) +- (unless (local-variable-p 'notmuch-search-json-parser) +- (set (make-local-variable 'notmuch-search-json-parser) ++ (unless (local-variable-p 'notmuch-json-parser) ++ (set (make-local-variable 'notmuch-json-parser) + (notmuch-json-create-parser (current-buffer))) +- (set (make-local-variable 'notmuch-search-process-state) 'begin)) +- (while (not done) +- (condition-case nil +- (case notmuch-search-process-state ++ (set (make-local-variable 'notmuch-json-state) 'begin)) ++ (while (not done) ++ (condition-case nil ++ (case notmuch-json-state + ((begin) + ;; Enter the results list + (if (eq (notmuch-json-begin-compound +- notmuch-search-json-parser) 'retry) ++ notmuch-json-parser) 'retry) + (setq done t) +- (setq notmuch-search-process-state 'result))) ++ (setq notmuch-json-state 'result))) + ((result) + ;; Parse a result +- (let ((result (notmuch-json-read notmuch-search-json-parser))) ++ (let ((result (notmuch-json-read notmuch-json-parser))) + (case result +- ((retry) (setq done t)) +- ((end) (setq notmuch-search-process-state 'end)) ++ ((retry) (setq done t)) ++ ((end) (setq notmuch-json-state 'end)) + (otherwise (with-current-buffer results-buf + (funcall result-function result)))))) + ((end) + ;; Any trailing data is unexpected +- (notmuch-json-eof notmuch-search-json-parser) ++ (notmuch-json-eof notmuch-json-parser) + (setq done t))) +- (json-error +- ;; Do our best to resynchronize and ensure forward +- ;; progress +- (let ((bad (buffer-substring (line-beginning-position) +- (line-end-position)))) +- (forward-line) ++ (json-error ++ ;; Do our best to resynchronize and ensure forward ++ ;; progress ++ (let ((bad (buffer-substring (line-beginning-position) ++ (line-end-position)))) ++ (forward-line) + (with-current-buffer results-buf + (funcall error-function "%s" bad)))))) +- ;; Clear out what we've parsed ++ ;; Clear out what we've parsed + (delete-region (point-min) (point)))) + + (defun notmuch-search-tag-all (&optional tag-changes) +-- +1.7.9.1 +