--- /dev/null
+Return-Path: <too@guru-group.fi>\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 135EB431FAF\r
+ for <notmuch@notmuchmail.org>; Sat, 6 Jul 2013 05:50:08 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+ 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 IPZ2o3s9-aga for <notmuch@notmuchmail.org>;\r
+ Sat, 6 Jul 2013 05:49:59 -0700 (PDT)\r
+Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
+ by olra.theworths.org (Postfix) with ESMTP id 8466A431FAE\r
+ for <notmuch@notmuchmail.org>; Sat, 6 Jul 2013 05:49:59 -0700 (PDT)\r
+Received: by guru.guru-group.fi (Postfix, from userid 501)\r
+ id 166711000CF; Sat, 6 Jul 2013 15:49:53 +0300 (EEST)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 1/1] emacs: dropped rest of now-unused JSON functionality\r
+Date: Sat, 6 Jul 2013 15:49:51 +0300\r
+Message-Id: <1373114991-301-1-git-send-email-tomi.ollila@iki.fi>\r
+X-Mailer: git-send-email 1.8.0\r
+Cc: tomi.ollila@iki.fi\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, 06 Jul 2013 12:50:08 -0000\r
+\r
+Notmuch cli provides all structured data previously provided\r
+in json format now in s-expression format, rendering all current\r
+json functionality obsolete.\r
+---\r
+\r
+ grep -ri json emacs prints no results\r
+ All 571 tests passed.\r
+\r
+ This patch should speed up Austin to create github repo for the\r
+ incremental json parser ;D\r
+\r
+ emacs/notmuch-lib.el | 268 +------------------------------------------------\r
+ emacs/notmuch-mua.el | 3 +-\r
+ emacs/notmuch-query.el | 1 -\r
+ emacs/notmuch-show.el | 2 +-\r
+ 4 files changed, 3 insertions(+), 271 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
+index 8deb7de..4796f17 100644\r
+--- a/emacs/notmuch-lib.el\r
++++ b/emacs/notmuch-lib.el\r
+@@ -23,7 +23,6 @@\r
+ \r
+ (require 'mm-view)\r
+ (require 'mm-decode)\r
+-(require 'json)\r
+ (require 'cl)\r
+ \r
+ (defvar notmuch-command "notmuch"\r
+@@ -258,7 +257,7 @@ the given type."\r
+ parts))\r
+ \r
+ ;; Helper for parts which are generally not included in the default\r
+-;; JSON output.\r
++;; SEXP output.\r
+ (defun notmuch-get-bodypart-internal (query part-number process-crypto)\r
+ (let ((args '("show" "--format=raw"))\r
+ (part-arg (format "--part=%s" part-number)))\r
+@@ -559,271 +558,6 @@ status."\r
+ (defvar notmuch-show-process-crypto nil)\r
+ (make-variable-buffer-local 'notmuch-show-process-crypto)\r
+ \r
+-;; Incremental JSON parsing\r
+-\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-json-parser nil\r
+- "Internal incremental JSON parser object: local to the buffer being parsed.")\r
+-\r
+-(defvar notmuch-json-state nil\r
+- "State of the internal JSON parser: local to the buffer being parsed.")\r
+-\r
+-(defun notmuch-json-create-parser (buffer)\r
+- "Return a streaming JSON parser that consumes input from BUFFER.\r
+-\r
+-This parser is designed to read streaming JSON whose structure is\r
+-known to the caller. Like a typical JSON parsing interface, it\r
+-provides a function to read a complete JSON value from the input.\r
+-However, it extends this with an additional function that\r
+-requires the next value in the input to be a compound value and\r
+-descends into it, allowing its elements to be read one at a time\r
+-or further descended into. Both functions can return 'retry to\r
+-indicate that not enough input is available.\r
+-\r
+-The parser always consumes input from BUFFER's point. Hence, the\r
+-caller is allowed to delete and data before point and may\r
+-resynchronize after an error by moving point."\r
+-\r
+- (list buffer\r
+- ;; Terminator stack: a stack of characters that indicate the\r
+- ;; end of the compound values enclosing point\r
+- '()\r
+- ;; Next: One of\r
+- ;; * 'expect-value if the next token must be a value, but a\r
+- ;; value has not yet been reached\r
+- ;; * 'value if point is at the beginning of a value\r
+- ;; * 'expect-comma if the next token must be a comma\r
+- 'expect-value\r
+- ;; Allow terminator: non-nil if the next token may be a\r
+- ;; terminator\r
+- nil\r
+- ;; Partial parse position: If state is 'value, a marker for\r
+- ;; the position of the partial parser or nil if no partial\r
+- ;; parsing has happened yet\r
+- nil\r
+- ;; Partial parse state: If state is 'value, the current\r
+- ;; `parse-partial-sexp' state\r
+- nil))\r
+-\r
+-(defmacro notmuch-json-buffer (jp) `(first ,jp))\r
+-(defmacro notmuch-json-term-stack (jp) `(second ,jp))\r
+-(defmacro notmuch-json-next (jp) `(third ,jp))\r
+-(defmacro notmuch-json-allow-term (jp) `(fourth ,jp))\r
+-(defmacro notmuch-json-partial-pos (jp) `(fifth ,jp))\r
+-(defmacro notmuch-json-partial-state (jp) `(sixth ,jp))\r
+-\r
+-(defvar notmuch-json-syntax-table\r
+- (let ((table (make-syntax-table)))\r
+- ;; The standard syntax table is what we need except that "." needs\r
+- ;; to have word syntax instead of punctuation syntax.\r
+- (modify-syntax-entry ?. "w" table)\r
+- table)\r
+- "Syntax table used for incremental JSON parsing.")\r
+-\r
+-(defun notmuch-json-scan-to-value (jp)\r
+- ;; Helper function that consumes separators, terminators, and\r
+- ;; whitespace from point. Returns nil if it successfully reached\r
+- ;; the beginning of a value, 'end if it consumed a terminator, or\r
+- ;; 'retry if not enough input was available to reach a value. Upon\r
+- ;; nil return, (notmuch-json-next jp) is always 'value.\r
+-\r
+- (if (eq (notmuch-json-next jp) 'value)\r
+- ;; We're already at a value\r
+- nil\r
+- ;; Drive the state toward 'expect-value\r
+- (skip-chars-forward " \t\r\n")\r
+- (or (when (eobp) 'retry)\r
+- ;; Test for the terminator for the current compound\r
+- (when (and (notmuch-json-allow-term jp)\r
+- (eq (char-after) (car (notmuch-json-term-stack jp))))\r
+- ;; Consume it and expect a comma or terminator next\r
+- (forward-char)\r
+- (setf (notmuch-json-term-stack jp) (cdr (notmuch-json-term-stack jp))\r
+- (notmuch-json-next jp) 'expect-comma\r
+- (notmuch-json-allow-term jp) t)\r
+- 'end)\r
+- ;; Test for a separator\r
+- (when (eq (notmuch-json-next jp) 'expect-comma)\r
+- (when (/= (char-after) ?,)\r
+- (signal 'json-readtable-error (list "expected ','")))\r
+- ;; Consume it, switch to 'expect-value, and disallow a\r
+- ;; terminator\r
+- (forward-char)\r
+- (skip-chars-forward " \t\r\n")\r
+- (setf (notmuch-json-next jp) 'expect-value\r
+- (notmuch-json-allow-term jp) nil)\r
+- ;; We moved point, so test for eobp again and fall through\r
+- ;; to the next test if there's more input\r
+- (when (eobp) 'retry))\r
+- ;; Next must be 'expect-value and we know this isn't\r
+- ;; whitespace, EOB, or a terminator, so point must be on a\r
+- ;; value\r
+- (progn\r
+- (assert (eq (notmuch-json-next jp) 'expect-value))\r
+- (setf (notmuch-json-next jp) 'value)\r
+- nil))))\r
+-\r
+-(defun notmuch-json-begin-compound (jp)\r
+- "Parse the beginning of a compound value and traverse inside it.\r
+-\r
+-Returns 'retry if there is insufficient input to parse the\r
+-beginning of the compound. If this is able to parse the\r
+-beginning of a compound, it moves point past the token that opens\r
+-the compound and returns t. Later calls to `notmuch-json-read'\r
+-will return the compound's elements.\r
+-\r
+-Entering JSON objects is currently unimplemented."\r
+-\r
+- (with-current-buffer (notmuch-json-buffer jp)\r
+- ;; Disallow terminators\r
+- (setf (notmuch-json-allow-term jp) nil)\r
+- ;; Save "next" so we can restore it if there's a syntax error\r
+- (let ((saved-next (notmuch-json-next jp)))\r
+- (or (notmuch-json-scan-to-value jp)\r
+- (if (/= (char-after) ?\[)\r
+- (progn\r
+- (setf (notmuch-json-next jp) saved-next)\r
+- (signal 'json-readtable-error (list "expected '['")))\r
+- (forward-char)\r
+- (push ?\] (notmuch-json-term-stack jp))\r
+- ;; Expect a value or terminator next\r
+- (setf (notmuch-json-next jp) 'expect-value\r
+- (notmuch-json-allow-term jp) t)\r
+- t)))))\r
+-\r
+-(defun notmuch-json-read (jp)\r
+- "Parse the value at point in JP's buffer.\r
+-\r
+-Returns 'retry if there is insufficient input to parse a complete\r
+-JSON value (though it may still move point over separators or\r
+-whitespace). If the parser is currently inside a compound value\r
+-and the next token ends the list or object, this moves point just\r
+-past the terminator and returns 'end. Otherwise, this moves\r
+-point to just past the end of the value and returns the value."\r
+-\r
+- (with-current-buffer (notmuch-json-buffer jp)\r
+- (or\r
+- ;; Get to a value state\r
+- (notmuch-json-scan-to-value jp)\r
+-\r
+- ;; Can we parse a complete value?\r
+- (let ((complete\r
+- (if (looking-at "[-+0-9tfn]")\r
+- ;; This is a number or a keyword, so the partial\r
+- ;; parser isn't going to help us because a truncated\r
+- ;; number or keyword looks like a complete symbol to\r
+- ;; it. Look for something that clearly ends it.\r
+- (save-excursion\r
+- (skip-chars-forward "^]},: \t\r\n")\r
+- (not (eobp)))\r
+-\r
+- ;; We're looking at a string, object, or array, which we\r
+- ;; can partial parse. If we just reached the value, set\r
+- ;; up the partial parser.\r
+- (when (null (notmuch-json-partial-state jp))\r
+- (setf (notmuch-json-partial-pos jp) (point-marker)))\r
+-\r
+- ;; Extend the partial parse until we either reach EOB or\r
+- ;; get the whole value\r
+- (save-excursion\r
+- (let ((pstate\r
+- (with-syntax-table notmuch-json-syntax-table\r
+- (parse-partial-sexp\r
+- (notmuch-json-partial-pos jp) (point-max) 0 nil\r
+- (notmuch-json-partial-state jp)))))\r
+- ;; A complete value is available if we've reached\r
+- ;; depth 0 or less and encountered a complete\r
+- ;; subexpression.\r
+- (if (and (<= (first pstate) 0) (third pstate))\r
+- t\r
+- ;; Not complete. Update the partial parser state\r
+- (setf (notmuch-json-partial-pos jp) (point-marker)\r
+- (notmuch-json-partial-state jp) pstate)\r
+- nil))))))\r
+-\r
+- (if (not complete)\r
+- 'retry\r
+- ;; We have a value. Reset the partial parse state and expect\r
+- ;; a comma or terminator after the value.\r
+- (setf (notmuch-json-next jp) 'expect-comma\r
+- (notmuch-json-allow-term jp) t\r
+- (notmuch-json-partial-pos jp) nil\r
+- (notmuch-json-partial-state jp) nil)\r
+- ;; Parse the value\r
+- (let ((json-object-type 'plist)\r
+- (json-array-type 'list)\r
+- (json-false nil))\r
+- (json-read)))))))\r
+-\r
+-(defun notmuch-json-eof (jp)\r
+- "Signal a json-error if there is more data in JP's buffer.\r
+-\r
+-Moves point to the beginning of any trailing data or to the end\r
+-of the buffer if there is only trailing whitespace."\r
+-\r
+- (with-current-buffer (notmuch-json-buffer jp)\r
+- (skip-chars-forward " \t\r\n")\r
+- (unless (eobp)\r
+- (signal 'json-error (list "Trailing garbage following JSON data")))))\r
+-\r
+-(defun notmuch-json-parse-partial-list (result-function error-function results-buf)\r
+- "Parse a partial JSON list from current buffer.\r
+-\r
+-This function consumes a JSON list from the current buffer,\r
+-applying RESULT-FUNCTION in buffer RESULT-BUFFER to each complete\r
+-value in the list. It operates incrementally and should be\r
+-called whenever the buffer has been extended with additional\r
+-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
+-\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-json-parser)\r
+- (set (make-local-variable 'notmuch-json-parser)\r
+- (notmuch-json-create-parser (current-buffer)))\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-json-parser) 'retry)\r
+- (setq done t)\r
+- (setq notmuch-json-state 'result)))\r
+- ((result)\r
+- ;; Parse a result\r
+- (let ((result (notmuch-json-read notmuch-json-parser)))\r
+- (case result\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-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
+- (with-current-buffer results-buf\r
+- (funcall error-function "%s" bad))))))\r
+- ;; Clear out what we've parsed\r
+- (delete-region (point-min) (point))))\r
+-\r
+-\r
+-\r
+ \r
+ (provide 'notmuch-lib)\r
+ \r
+diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el\r
+index 329d342..2baae5f 100644\r
+--- a/emacs/notmuch-mua.el\r
++++ b/emacs/notmuch-mua.el\r
+@@ -19,7 +19,6 @@\r
+ ;;\r
+ ;; Authors: David Edmondson <dme@dme.org>\r
+ \r
+-(require 'json)\r
+ (require 'message)\r
+ (require 'mm-view)\r
+ (require 'format-spec)\r
+@@ -157,7 +156,7 @@ list."\r
+ (setq args (append args '("--reply-to=sender"))))\r
+ (setq args (append args (list query-string)))\r
+ \r
+- ;; Get the reply object as JSON, and parse it into an elisp object.\r
++ ;; Get the reply object as SEXP, and parse it into an elisp object.\r
+ (setq reply (apply #'notmuch-call-notmuch-sexp args))\r
+ \r
+ ;; Extract the original message to simplify the following code.\r
+diff --git a/emacs/notmuch-query.el b/emacs/notmuch-query.el\r
+index 51d427f..d1daffc 100644\r
+--- a/emacs/notmuch-query.el\r
++++ b/emacs/notmuch-query.el\r
+@@ -20,7 +20,6 @@\r
+ ;; Authors: David Bremner <david@tethera.net>\r
+ \r
+ (require 'notmuch-lib)\r
+-(require 'json)\r
+ \r
+ (defun notmuch-query-get-threads (search-terms)\r
+ "Return a list of threads of messages matching SEARCH-TERMS.\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index e5de977..c4e0a99 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -2042,7 +2042,7 @@ the user (see `notmuch-show-stash-mlarchive-link-alist')."\r
+ (with-current-buffer buf\r
+ (setq notmuch-show-process-crypto process-crypto)\r
+ ;; Always acquires the part via `notmuch part', even if it is\r
+- ;; available in the JSON output.\r
++ ;; available in the SEXP output.\r
+ (insert (notmuch-get-bodypart-internal message-id nth notmuch-show-process-crypto)))\r
+ buf))\r
+ \r
+-- \r
+1.8.3.1\r
+\r