--- /dev/null
+Return-Path: <amdragon@mit.edu>\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 11DB7431FAF\r
+ for <notmuch@notmuchmail.org>; Thu, 5 Jul 2012 13:52:45 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+ tests=[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 Payy2bhSgHfC for <notmuch@notmuchmail.org>;\r
+ Thu, 5 Jul 2012 13:52:43 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-3.mit.edu (DMZ-MAILSEC-SCANNER-3.MIT.EDU\r
+ [18.9.25.14])\r
+ by olra.theworths.org (Postfix) with ESMTP id 18509431FB6\r
+ for <notmuch@notmuchmail.org>; Thu, 5 Jul 2012 13:52:43 -0700 (PDT)\r
+X-AuditID: 1209190e-b7fb56d0000008b2-39-4ff5fe9add99\r
+Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])\r
+ by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP\r
+ id 8B.2A.02226.A9EF5FF4; Thu, 5 Jul 2012 16:52:42 -0400 (EDT)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
+ by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id q65KqgMA019982; \r
+ Thu, 5 Jul 2012 16:52:42 -0400\r
+Received: from drake.dyndns.org (26-4-182.dynamic.csail.mit.edu [18.26.4.182])\r
+ (authenticated bits=0)\r
+ (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+ by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q65Kqbrc027238\r
+ (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+ Thu, 5 Jul 2012 16:52:39 -0400 (EDT)\r
+Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
+ (envelope-from <amdragon@mit.edu>)\r
+ id 1Smt2T-0004Xh-Jp; Thu, 05 Jul 2012 16:52:37 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2 5/9] emacs: Pass plist to `notmuch-search-show-result'\r
+Date: Thu, 5 Jul 2012 16:52:23 -0400\r
+Message-Id: <1341521547-15502-6-git-send-email-amdragon@mit.edu>\r
+X-Mailer: git-send-email 1.7.10\r
+In-Reply-To: <1341521547-15502-1-git-send-email-amdragon@mit.edu>\r
+References: <1341354059-29396-1-git-send-email-amdragon@mit.edu>\r
+ <1341521547-15502-1-git-send-email-amdragon@mit.edu>\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFrrIIsWRmVeSWpSXmKPExsUixG6nrjvr31d/gycrNSxWz+WxuH5zJrPF\r
+ m5XzWB2YPXbOusvucfjrQhaPZ6tuMQcwR3HZpKTmZJalFunbJXBl7NmxgrHgsGZFy4xmpgbG\r
+ jYpdjBwcEgImEsv7k7sYOYFMMYkL99azdTFycQgJ7GOUeNi/mQnCWc8ocWfZTxYI5ySTxJmb\r
+ MM5cRonLs/+xgPSzCWhIbNu/nBHEFhGQlth5dzYriM0sECexZcp/sLiwgKfEn/XzweIsAqoS\r
+ k3afZQI5g1fAQeLt5yqIM+Qlnt7vYwOxOQUcJS5MXAzWKiRQLvFnyT+WCYz8CxgZVjHKpuRW\r
+ 6eYmZuYUpybrFicn5uWlFuka6+VmluilppRuYgSFFqck3w7GrweVDjEKcDAq8fAa537xF2JN\r
+ LCuuzD3EKMnBpCTK2/j7q78QX1J+SmVGYnFGfFFpTmrxIUYJDmYlEd7eDKAcb0piZVVqUT5M\r
+ SpqDRUmc90rKTX8hgfTEktTs1NSC1CKYrAwHh5IE78q/QI2CRanpqRVpmTklCGkmDk6Q4TxA\r
+ w9eC1PAWFyTmFmemQ+RPMepyrHtz5AajEEtefl6qlDjvTJAiAZCijNI8uDmwlPCKURzoLWHe\r
+ TyBVPMB0AjfpFdASJqAleYs/gSwpSURISTUwuhSFdJVr/fktF+Opo3rD9SDvhiKFFE7pmram\r
+ uOWHnO7v5OZtsPm1IaPrU/WRH8Z6WSZeFz4wrnntNFn+h0eA5ZWbX36843t/Q2rlsfWFeTK7\r
+ 3JNmnlHRmROmtlA0907WFS5F3YQL1r0vVA9sL492OWCepLLuwA7VRal7ptr93nE87prwSSle\r
+ JZbijERDLeai4kQACRTRAuQCAAA=\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: Thu, 05 Jul 2012 20:52:45 -0000\r
+\r
+Rather than passing lots of arguments and then further passing those\r
+to `notmuch-search-insert-field', pass a plist containing all of the\r
+search result information. This plist is compatible with the JSON\r
+format search results.\r
+---\r
+ emacs/notmuch.el | 65 +++++++++++++++++++++++++++++++-----------------------\r
+ 1 file changed, 38 insertions(+), 27 deletions(-)\r
+\r
+diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
+index 5bf01ca..dfeaf35 100644\r
+--- a/emacs/notmuch.el\r
++++ b/emacs/notmuch.el\r
+@@ -707,42 +707,47 @@ non-authors is found, assume that all of the authors match."\r
+ (overlay-put overlay 'isearch-open-invisible #'delete-overlay)))\r
+ (insert padding))))\r
+ \r
+-(defun notmuch-search-insert-field (field format-string date count authors subject tags)\r
++(defun notmuch-search-insert-field (field format-string result)\r
+ (cond\r
+ ((string-equal field "date")\r
+- (insert (propertize (format format-string date)\r
++ (insert (propertize (format format-string (plist-get result :date_relative))\r
+ 'face 'notmuch-search-date)))\r
+ ((string-equal field "count")\r
+- (insert (propertize (format format-string count)\r
++ (insert (propertize (format format-string\r
++ (format "[%s/%s]" (plist-get result :matched)\r
++ (plist-get result :total)))\r
+ 'face 'notmuch-search-count)))\r
+ ((string-equal field "subject")\r
+- (insert (propertize (format format-string subject)\r
++ (insert (propertize (format format-string (plist-get result :subject))\r
+ 'face 'notmuch-search-subject)))\r
+ \r
+ ((string-equal field "authors")\r
+- (notmuch-search-insert-authors format-string authors))\r
++ (notmuch-search-insert-authors format-string (plist-get result :authors)))\r
+ \r
+ ((string-equal field "tags")\r
+ ;; Ignore format-string here because notmuch-search-set-tags\r
+ ;; depends on the format of this\r
+- (insert (concat "(" (propertize tags 'font-lock-face 'notmuch-tag-face) ")")))))\r
++ (insert (concat "(" (propertize\r
++ (mapconcat 'identity (plist-get result :tags) " ")\r
++ 'font-lock-face 'notmuch-tag-face) ")")))))\r
+ \r
+-(defun notmuch-search-show-result (thread-id date count authors subject tags)\r
++(defun notmuch-search-show-result (result)\r
+ ;; Ignore excluded matches\r
+- (unless (eq (aref count 1) ?0)\r
+- (let ((beg (point-max))\r
+- (tags-str (mapconcat 'identity tags " ")))\r
++ (unless (= (plist-get result :matched) 0)\r
++ (let ((beg (point-max)))\r
+ (save-excursion\r
+ (goto-char beg)\r
+ (dolist (spec notmuch-search-result-format)\r
+- (notmuch-search-insert-field (car spec) (cdr spec)\r
+- date count authors subject tags-str))\r
++ (notmuch-search-insert-field (car spec) (cdr spec) result))\r
+ (insert "\n")\r
+- (notmuch-search-color-line beg (point) tags)\r
+- (put-text-property beg (point) 'notmuch-search-thread-id thread-id)\r
+- (put-text-property beg (point) 'notmuch-search-authors authors)\r
+- (put-text-property beg (point) 'notmuch-search-subject subject))\r
+- (when (string= thread-id notmuch-search-target-thread)\r
++ (notmuch-search-color-line beg (point) (plist-get result :tags))\r
++ (put-text-property beg (point) 'notmuch-search-thread-id\r
++ (concat "thread:" (plist-get result :thread)))\r
++ (put-text-property beg (point) 'notmuch-search-authors\r
++ (plist-get result :authors))\r
++ (put-text-property beg (point) 'notmuch-search-subject\r
++ (plist-get result :subject)))\r
++ (when (string= (plist-get result :thread) notmuch-search-target-thread)\r
+ (setq notmuch-search-target-thread "found")\r
+ (goto-char beg)))))\r
+ \r
+@@ -766,18 +771,24 @@ non-authors is found, assume that all of the authors match."\r
+ (while more\r
+ (while (and (< line (length string)) (= (elt string line) ?\n))\r
+ (setq line (1+ line)))\r
+- (if (string-match "^\\(thread:[0-9A-Fa-f]*\\) \\([^][]*\\) \\(\\[[0-9/]*\\]\\) \\([^;]*\\); \\(.*\\) (\\([^()]*\\))$" string line)\r
++ (if (string-match "^thread:\\([0-9A-Fa-f]*\\) \\([^][]*\\) \\[\\([0-9]*\\)/\\([0-9]*\\)\\] \\([^;]*\\); \\(.*\\) (\\([^()]*\\))$" string line)\r
+ (let* ((thread-id (match-string 1 string))\r
+- (date (match-string 2 string))\r
+- (count (match-string 3 string))\r
+- (authors (match-string 4 string))\r
+- (subject (match-string 5 string))\r
+- (tags (match-string 6 string))\r
+- (tag-list (if tags (save-match-data (split-string tags)))))\r
+- (if (/= (match-beginning 1) line)\r
++ (tags-str (match-string 7 string))\r
++ (result (list :thread thread-id\r
++ :date_relative (match-string 2 string)\r
++ :matched (string-to-number\r
++ (match-string 3 string))\r
++ :total (string-to-number\r
++ (match-string 4 string))\r
++ :authors (match-string 5 string)\r
++ :subject (match-string 6 string)\r
++ :tags (if tags-str\r
++ (save-match-data\r
++ (split-string tags-str))))))\r
++ (if (/= (match-beginning 0) line)\r
+ (notmuch-search-show-error\r
+- (substring string line (match-beginning 1))))\r
+- (notmuch-search-show-result thread-id date count authors subject tag-list)\r
++ (substring string line (match-beginning 0))))\r
++ (notmuch-search-show-result result)\r
+ (set 'line (match-end 0)))\r
+ (set 'more nil)\r
+ (while (and (< line (length string)) (= (elt string line) ?\n))\r
+-- \r
+1.7.10\r
+\r