[PATCH 2/4] emacs: Use a plists rather than an assoc list in JSON search.
authorDavid Edmondson <dme@dme.org>
Tue, 30 Nov 2010 11:00:23 +0000 (11:00 +0000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:37:37 +0000 (09:37 -0800)
02/b8020badc872a9044d3e4995c07092aceadf03 [new file with mode: 0644]

diff --git a/02/b8020badc872a9044d3e4995c07092aceadf03 b/02/b8020badc872a9044d3e4995c07092aceadf03
new file mode 100644 (file)
index 0000000..b57a59d
--- /dev/null
@@ -0,0 +1,92 @@
+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 2134A41A546\r
+       for <notmuch@notmuchmail.org>; Tue, 30 Nov 2010 03:00:46 -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 B7ELlyp1I-7G for <notmuch@notmuchmail.org>;\r
+       Tue, 30 Nov 2010 03:00:44 -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 7D64441A541\r
+       for <notmuch@notmuchmail.org>; Tue, 30 Nov 2010 03:00:43 -0800 (PST)\r
+Received: by ut.hh.sledj.net (Postfix, from userid 1000)\r
+       id 69DD0594235; Tue, 30 Nov 2010 11:00:28 +0000 (GMT)\r
+From: David Edmondson <dme@dme.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 2/4] emacs: Use a plists rather than an assoc list in JSON\r
+       search.\r
+Date: Tue, 30 Nov 2010 11:00:23 +0000\r
+Message-Id: <1291114825-3513-2-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:46 -0000\r
+\r
+For commonality with the `notmuch-show' code, prefer plists over\r
+associative lists.\r
+---\r
+ emacs/notmuch.el |   17 +++++++++--------\r
+ 1 files changed, 9 insertions(+), 8 deletions(-)\r
+\r
+diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
+index f4aefc8..d561c6e 100644\r
+--- a/emacs/notmuch.el\r
++++ b/emacs/notmuch.el\r
+@@ -700,14 +700,14 @@ foreground and blue background."\r
+   (insert "\n"))\r
\r
+ (defun notmuch-search-process-insert-object (object)\r
+-  (let* ((thread-id (concat "thread:" (cdr (assoc 'thread object))))\r
+-       (date (format "%12s" (cdr (assoc 'date_relative object))))\r
++  (let* ((thread-id (concat "thread:" (plist-get object :thread)))\r
++       (date (format "%12s" (plist-get object :date_relative)))\r
+        (count (format "[%d/%d]"\r
+-                      (cdr (assoc 'matched object))\r
+-                      (cdr (assoc 'total object))))\r
+-       (authors (cdr (assoc 'authors object)))\r
+-       (subject (cdr (assoc 'subject object)))\r
+-       (tag-list (cdr (assoc 'tags object)))\r
++                      (plist-get object :matched)\r
++                      (plist-get object :total)))\r
++       (authors (plist-get object :authors))\r
++       (subject (plist-get object :subject))\r
++       (tag-list (plist-get object :tags))\r
+        (tags (mapconcat 'identity tag-list " "))\r
+        (beg (point-marker)))\r
+     (notmuch-search-show-result date count authors subject tags)\r
+@@ -724,7 +724,8 @@ foreground and blue background."\r
+     (let ((inhibit-read-only t)\r
+         (inhibit-redisplay t)\r
+         ;; Vectors are not as useful here.\r
+-        (json-array-type 'list))\r
++        (json-array-type 'list)\r
++        (json-object-type 'plist))\r
+       (save-excursion\r
+       ;; Insert the text, advancing the process marker\r
+       (goto-char (point-max))\r
+-- \r
+1.7.2.3\r
+\r