[PATCH v4 2/3] emacs: Rename incremental JSON internal variables
authorMark Walters <markwalters1009@gmail.com>
Sat, 27 Oct 2012 09:34:11 +0000 (10:34 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:50:05 +0000 (09:50 -0800)
5e/41740c0fd93a2f955e883c810fef683fdfc638 [new file with mode: 0644]

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