[PATCH 2/4] emacs: Use a plists rather than an assoc list in JSON search.

David Edmondson dme at dme.org
Tue Nov 30 03:00:23 PST 2010


For commonality with the `notmuch-show' code, prefer plists over
associative lists.
---
 emacs/notmuch.el |   17 +++++++++--------
 1 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index f4aefc8..d561c6e 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -700,14 +700,14 @@ foreground and blue background."
   (insert "\n"))
 
 (defun notmuch-search-process-insert-object (object)
-  (let* ((thread-id (concat "thread:" (cdr (assoc 'thread object))))
-	 (date (format "%12s" (cdr (assoc 'date_relative object))))
+  (let* ((thread-id (concat "thread:" (plist-get object :thread)))
+	 (date (format "%12s" (plist-get object :date_relative)))
 	 (count (format "[%d/%d]"
-			(cdr (assoc 'matched object))
-			(cdr (assoc 'total object))))
-	 (authors (cdr (assoc 'authors object)))
-	 (subject (cdr (assoc 'subject object)))
-	 (tag-list (cdr (assoc 'tags object)))
+			(plist-get object :matched)
+			(plist-get object :total)))
+	 (authors (plist-get object :authors))
+	 (subject (plist-get object :subject))
+	 (tag-list (plist-get object :tags))
 	 (tags (mapconcat 'identity tag-list " "))
 	 (beg (point-marker)))
     (notmuch-search-show-result date count authors subject tags)
@@ -724,7 +724,8 @@ foreground and blue background."
     (let ((inhibit-read-only t)
 	  (inhibit-redisplay t)
 	  ;; Vectors are not as useful here.
-	  (json-array-type 'list))
+	  (json-array-type 'list)
+	  (json-object-type 'plist))
       (save-excursion
 	;; Insert the text, advancing the process marker
 	(goto-char (point-max))
-- 
1.7.2.3



More information about the notmuch mailing list