1 Return-Path: <amdragon@mit.edu>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 526F0431FAF
\r
6 for <notmuch@notmuchmail.org>; Tue, 3 Jul 2012 15:21:12 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id FxdQj+cqzivA for <notmuch@notmuchmail.org>;
\r
16 Tue, 3 Jul 2012 15:21:10 -0700 (PDT)
\r
17 Received: from dmz-mailsec-scanner-3.mit.edu (DMZ-MAILSEC-SCANNER-3.MIT.EDU
\r
19 by olra.theworths.org (Postfix) with ESMTP id 93AA0431FC2
\r
20 for <notmuch@notmuchmail.org>; Tue, 3 Jul 2012 15:21:06 -0700 (PDT)
\r
21 X-AuditID: 1209190e-b7fb56d0000008b2-5c-4ff3705269de
\r
22 Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])
\r
23 by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP
\r
24 id B8.C6.02226.25073FF4; Tue, 3 Jul 2012 18:21:06 -0400 (EDT)
\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])
\r
26 by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id q63ML5WX010808;
\r
27 Tue, 3 Jul 2012 18:21:05 -0400
\r
28 Received: from drake.dyndns.org (26-4-182.dynamic.csail.mit.edu [18.26.4.182])
\r
29 (authenticated bits=0)
\r
30 (User authenticated as amdragon@ATHENA.MIT.EDU)
\r
31 by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q63ML1vJ023223
\r
32 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);
\r
33 Tue, 3 Jul 2012 18:21:02 -0400 (EDT)
\r
34 Received: from amthrax by drake.dyndns.org with local (Exim 4.77)
\r
35 (envelope-from <amdragon@mit.edu>)
\r
36 id 1SmBSv-0007fV-1W; Tue, 03 Jul 2012 18:21:01 -0400
\r
37 From: Austin Clements <amdragon@MIT.EDU>
\r
38 To: notmuch@notmuchmail.org
\r
39 Subject: [PATCH 5/8] emacs: Pass plist to `notmuch-search-show-result'
\r
40 Date: Tue, 3 Jul 2012 18:20:56 -0400
\r
41 Message-Id: <1341354059-29396-6-git-send-email-amdragon@mit.edu>
\r
42 X-Mailer: git-send-email 1.7.10
\r
43 In-Reply-To: <1341354059-29396-1-git-send-email-amdragon@mit.edu>
\r
44 References: <1341354059-29396-1-git-send-email-amdragon@mit.edu>
\r
45 X-Brightmail-Tracker:
\r
46 H4sIAAAAAAAAA+NgFrrLIsWRmVeSWpSXmKPExsUixG6nrhtU8NnfoHEfu8WRPbPYLZae+c9s
\r
47 cf3mTGaLNyvnsTqweOycdZfd4/DXhSwez1bdYvZo+rGYNYAlissmJTUnsyy1SN8ugStj+8JH
\r
48 rAXLNSp+/9jN1MA4TaGLkZNDQsBEYt/qV6wQtpjEhXvr2boYuTiEBPYxSkxZfYMVwlnPKLFg
\r
49 1z2wKiGBk0wSazrKIBJzGSWudW5gA0mwCWhIbNu/nBHEFhGQlth5dzZYA7NArsTZ1sNgcWEB
\r
50 N4nex/eZQGwWAVWJTe9es4PYvAIOEo9+PGKDOENe4un9PjCbU8BRYsXNsywQix0ktn3oYJ3A
\r
51 yL+AkWEVo2xKbpVubmJmTnFqsm5xcmJeXmqRrrFebmaJXmpK6SZGUMhxSvLtYPx6UOkQowAH
\r
52 oxIPb7LCZ38h1sSy4srcQ4ySHExKorxX8oBCfEn5KZUZicUZ8UWlOanFhxglOJiVRHhXJwHl
\r
53 eFMSK6tSi/JhUtIcLErivFdSbvoLCaQnlqRmp6YWpBbBZGU4OJQkeFvzgRoFi1LTUyvSMnNK
\r
54 ENJMHJwgw3mAhmeD1PAWFyTmFmemQ+RPMepyrHtz5AajEEtefl6qlDjvTpAiAZCijNI8uDmw
\r
55 VPGKURzoLWHeTpAqHmCagZv0CmgJE9CSvMWfQJaUJCKkpBoYV+qd3/C1acrfyaaTZ5zb08t5
\r
56 UCdklpV91OPfmxZqiO7quON8IfnfxwLvdRvM0z4dNzR776vZ/CuNKVhr3RuB6+c2L3t+2mDl
\r
57 O6VlWxl590sskxbS2n//8QLGGVPnHz1T/2WZz5NHr1er+Vx583eXZoPjv4MyCaHXL6YuZb39
\r
58 8LPD/2UW+3/afPdTYinOSDTUYi4qTgQAdZIFfPACAAA=
\r
59 Cc: tomi.ollila@iki.fi
\r
60 X-BeenThere: notmuch@notmuchmail.org
\r
61 X-Mailman-Version: 2.1.13
\r
63 List-Id: "Use and development of the notmuch mail system."
\r
64 <notmuch.notmuchmail.org>
\r
65 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
66 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
67 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
68 List-Post: <mailto:notmuch@notmuchmail.org>
\r
69 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
70 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
71 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
72 X-List-Received-Date: Tue, 03 Jul 2012 22:21:12 -0000
\r
74 Rather than passing lots of arguments and then further passing those
\r
75 to `notmuch-search-insert-field', pass a plist containing all of the
\r
76 search result information. This plist is compatible JSON format
\r
79 emacs/notmuch.el | 65 +++++++++++++++++++++++++++++++-----------------------
\r
80 1 file changed, 38 insertions(+), 27 deletions(-)
\r
82 diff --git a/emacs/notmuch.el b/emacs/notmuch.el
\r
83 index a073367..084cec6 100644
\r
84 --- a/emacs/notmuch.el
\r
85 +++ b/emacs/notmuch.el
\r
86 @@ -707,41 +707,46 @@ non-authors is found, assume that all of the authors match."
\r
87 (overlay-put overlay 'isearch-open-invisible #'delete-overlay)))
\r
90 -(defun notmuch-search-insert-field (field format date count authors subject tags)
\r
91 +(defun notmuch-search-insert-field (field format result)
\r
93 ((string-equal field "date")
\r
94 - (insert (propertize (format format date)
\r
95 + (insert (propertize (format format (plist-get result :date_relative))
\r
96 'face 'notmuch-search-date)))
\r
97 ((string-equal field "count")
\r
98 - (insert (propertize (format format count)
\r
99 + (insert (propertize (format format (format "[%s/%s]"
\r
100 + (plist-get result :matched)
\r
101 + (plist-get result :total)))
\r
102 'face 'notmuch-search-count)))
\r
103 ((string-equal field "subject")
\r
104 - (insert (propertize (format format subject)
\r
105 + (insert (propertize (format format (plist-get result :subject))
\r
106 'face 'notmuch-search-subject)))
\r
108 ((string-equal field "authors")
\r
109 - (notmuch-search-insert-authors format authors))
\r
110 + (notmuch-search-insert-authors format (plist-get result :authors)))
\r
112 ((string-equal field "tags")
\r
114 - (format format (propertize tags 'font-lock-face 'notmuch-tag-face))))))
\r
115 + (format format (propertize
\r
116 + (mapconcat 'identity (plist-get result :tags) " ")
\r
117 + 'font-lock-face 'notmuch-tag-face))))))
\r
119 -(defun notmuch-search-show-result (thread-id date count authors subject tags)
\r
120 +(defun notmuch-search-show-result (result)
\r
121 ;; Ignore excluded matches
\r
122 - (unless (eq (aref count 1) ?0)
\r
123 - (let ((beg (point-max))
\r
124 - (tags-str (mapconcat 'identity tags " ")))
\r
125 + (unless (= (plist-get result :matched) 0)
\r
126 + (let ((beg (point-max)))
\r
129 (dolist (format notmuch-search-result-format)
\r
130 - (notmuch-search-insert-field (car format) (cdr format)
\r
131 - date count authors subject tags-str))
\r
132 + (notmuch-search-insert-field (car format) (cdr format) result))
\r
134 - (notmuch-search-color-line beg (point) tags)
\r
135 - (put-text-property beg (point) 'notmuch-search-thread-id thread-id)
\r
136 - (put-text-property beg (point) 'notmuch-search-authors authors)
\r
137 - (put-text-property beg (point) 'notmuch-search-subject subject))
\r
138 - (when (string= thread-id notmuch-search-target-thread)
\r
139 + (notmuch-search-color-line beg (point) (plist-get result :tags))
\r
140 + (put-text-property beg (point) 'notmuch-search-thread-id
\r
141 + (concat "thread:" (plist-get result :thread)))
\r
142 + (put-text-property beg (point) 'notmuch-search-authors
\r
143 + (plist-get result :authors))
\r
144 + (put-text-property beg (point) 'notmuch-search-subject
\r
145 + (plist-get result :subject)))
\r
146 + (when (string= (plist-get result :thread) notmuch-search-target-thread)
\r
147 (setq notmuch-search-target-thread "found")
\r
148 (goto-char beg)))))
\r
150 @@ -765,18 +770,24 @@ non-authors is found, assume that all of the authors match."
\r
152 (while (and (< line (length string)) (= (elt string line) ?\n))
\r
153 (setq line (1+ line)))
\r
154 - (if (string-match "^\\(thread:[0-9A-Fa-f]*\\) \\([^][]*\\) \\(\\[[0-9/]*\\]\\) \\([^;]*\\); \\(.*\\) (\\([^()]*\\))$" string line)
\r
155 + (if (string-match "^thread:\\([0-9A-Fa-f]*\\) \\([^][]*\\) \\[\\([0-9]*\\)/\\([0-9]*\\)\\] \\([^;]*\\); \\(.*\\) (\\([^()]*\\))$" string line)
\r
156 (let* ((thread-id (match-string 1 string))
\r
157 - (date (match-string 2 string))
\r
158 - (count (match-string 3 string))
\r
159 - (authors (match-string 4 string))
\r
160 - (subject (match-string 5 string))
\r
161 - (tags (match-string 6 string))
\r
162 - (tag-list (if tags (save-match-data (split-string tags)))))
\r
163 - (if (/= (match-beginning 1) line)
\r
164 + (tags-str (match-string 7 string))
\r
165 + (result (list :thread thread-id
\r
166 + :date_relative (match-string 2 string)
\r
167 + :matched (string-to-number
\r
168 + (match-string 3 string))
\r
169 + :total (string-to-number
\r
170 + (match-string 4 string))
\r
171 + :authors (match-string 5 string)
\r
172 + :subject (match-string 6 string)
\r
173 + :tags (if tags-str
\r
175 + (split-string tags-str))))))
\r
176 + (if (/= (match-beginning 0) line)
\r
177 (notmuch-search-show-error
\r
178 - (substring string line (match-beginning 1))))
\r
179 - (notmuch-search-show-result thread-id date count authors subject tag-list)
\r
180 + (substring string line (match-beginning 0))))
\r
181 + (notmuch-search-show-result result)
\r
182 (set 'line (match-end 0)))
\r
184 (while (and (< line (length string)) (= (elt string line) ?\n))
\r