"snoozing" with notmuch?
[notmuch-archives.git] / 9c / cf3c10a4da8ffd3c95a2f7d8631f4b7dd49b14
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 11DB7431FAF\r
6         for <notmuch@notmuchmail.org>; Thu,  5 Jul 2012 13:52:45 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.7\r
10 X-Spam-Level: \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 Payy2bhSgHfC for <notmuch@notmuchmail.org>;\r
16         Thu,  5 Jul 2012 13:52:43 -0700 (PDT)\r
17 Received: from dmz-mailsec-scanner-3.mit.edu (DMZ-MAILSEC-SCANNER-3.MIT.EDU\r
18         [18.9.25.14])\r
19         by olra.theworths.org (Postfix) with ESMTP id 18509431FB6\r
20         for <notmuch@notmuchmail.org>; Thu,  5 Jul 2012 13:52:43 -0700 (PDT)\r
21 X-AuditID: 1209190e-b7fb56d0000008b2-39-4ff5fe9add99\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 8B.2A.02226.A9EF5FF4; Thu,  5 Jul 2012 16:52:42 -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 q65KqgMA019982; \r
27         Thu, 5 Jul 2012 16:52:42 -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 q65Kqbrc027238\r
32         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
33         Thu, 5 Jul 2012 16:52:39 -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 1Smt2T-0004Xh-Jp; Thu, 05 Jul 2012 16:52:37 -0400\r
37 From: Austin Clements <amdragon@MIT.EDU>\r
38 To: notmuch@notmuchmail.org\r
39 Subject: [PATCH v2 5/9] emacs: Pass plist to `notmuch-search-show-result'\r
40 Date: Thu,  5 Jul 2012 16:52:23 -0400\r
41 Message-Id: <1341521547-15502-6-git-send-email-amdragon@mit.edu>\r
42 X-Mailer: git-send-email 1.7.10\r
43 In-Reply-To: <1341521547-15502-1-git-send-email-amdragon@mit.edu>\r
44 References: <1341354059-29396-1-git-send-email-amdragon@mit.edu>\r
45         <1341521547-15502-1-git-send-email-amdragon@mit.edu>\r
46 X-Brightmail-Tracker:\r
47  H4sIAAAAAAAAA+NgFrrIIsWRmVeSWpSXmKPExsUixG6nrjvr31d/gycrNSxWz+WxuH5zJrPF\r
48         m5XzWB2YPXbOusvucfjrQhaPZ6tuMQcwR3HZpKTmZJalFunbJXBl7NmxgrHgsGZFy4xmpgbG\r
49         jYpdjBwcEgImEsv7k7sYOYFMMYkL99azdTFycQgJ7GOUeNi/mQnCWc8ocWfZTxYI5ySTxJmb\r
50         MM5cRonLs/+xgPSzCWhIbNu/nBHEFhGQlth5dzYriM0sECexZcp/sLiwgKfEn/XzweIsAqoS\r
51         k3afZQI5g1fAQeLt5yqIM+Qlnt7vYwOxOQUcJS5MXAzWKiRQLvFnyT+WCYz8CxgZVjHKpuRW\r
52         6eYmZuYUpybrFicn5uWlFuka6+VmluilppRuYgSFFqck3w7GrweVDjEKcDAq8fAa537xF2JN\r
53         LCuuzD3EKMnBpCTK2/j7q78QX1J+SmVGYnFGfFFpTmrxIUYJDmYlEd7eDKAcb0piZVVqUT5M\r
54         SpqDRUmc90rKTX8hgfTEktTs1NSC1CKYrAwHh5IE78q/QI2CRanpqRVpmTklCGkmDk6Q4TxA\r
55         w9eC1PAWFyTmFmemQ+RPMepyrHtz5AajEEtefl6qlDjvTJAiAZCijNI8uDmwlPCKURzoLWHe\r
56         TyBVPMB0AjfpFdASJqAleYs/gSwpSURISTUwuhSFdJVr/fktF+Opo3rD9SDvhiKFFE7pmram\r
57         uOWHnO7v5OZtsPm1IaPrU/WRH8Z6WSZeFz4wrnntNFn+h0eA5ZWbX36843t/Q2rlsfWFeTK7\r
58         3JNmnlHRmROmtlA0907WFS5F3YQL1r0vVA9sL492OWCepLLuwA7VRal7ptr93nE87prwSSle\r
59         JZbijERDLeai4kQACRTRAuQCAAA=\r
60 Cc: tomi.ollila@iki.fi\r
61 X-BeenThere: notmuch@notmuchmail.org\r
62 X-Mailman-Version: 2.1.13\r
63 Precedence: list\r
64 List-Id: "Use and development of the notmuch mail system."\r
65         <notmuch.notmuchmail.org>\r
66 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
67         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
68 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
69 List-Post: <mailto:notmuch@notmuchmail.org>\r
70 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
71 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
72         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
73 X-List-Received-Date: Thu, 05 Jul 2012 20:52:45 -0000\r
74 \r
75 Rather than passing lots of arguments and then further passing those\r
76 to `notmuch-search-insert-field', pass a plist containing all of the\r
77 search result information.  This plist is compatible with the JSON\r
78 format search results.\r
79 ---\r
80  emacs/notmuch.el |   65 +++++++++++++++++++++++++++++++-----------------------\r
81  1 file changed, 38 insertions(+), 27 deletions(-)\r
82 \r
83 diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
84 index 5bf01ca..dfeaf35 100644\r
85 --- a/emacs/notmuch.el\r
86 +++ b/emacs/notmuch.el\r
87 @@ -707,42 +707,47 @@ non-authors is found, assume that all of the authors match."\r
88           (overlay-put overlay 'isearch-open-invisible #'delete-overlay)))\r
89        (insert padding))))\r
90  \r
91 -(defun notmuch-search-insert-field (field format-string date count authors subject tags)\r
92 +(defun notmuch-search-insert-field (field format-string result)\r
93    (cond\r
94     ((string-equal field "date")\r
95 -    (insert (propertize (format format-string date)\r
96 +    (insert (propertize (format format-string (plist-get result :date_relative))\r
97                         'face 'notmuch-search-date)))\r
98     ((string-equal field "count")\r
99 -    (insert (propertize (format format-string count)\r
100 +    (insert (propertize (format format-string\r
101 +                               (format "[%s/%s]" (plist-get result :matched)\r
102 +                                       (plist-get result :total)))\r
103                         'face 'notmuch-search-count)))\r
104     ((string-equal field "subject")\r
105 -    (insert (propertize (format format-string subject)\r
106 +    (insert (propertize (format format-string (plist-get result :subject))\r
107                         'face 'notmuch-search-subject)))\r
108  \r
109     ((string-equal field "authors")\r
110 -    (notmuch-search-insert-authors format-string authors))\r
111 +    (notmuch-search-insert-authors format-string (plist-get result :authors)))\r
112  \r
113     ((string-equal field "tags")\r
114      ;; Ignore format-string here because notmuch-search-set-tags\r
115      ;; depends on the format of this\r
116 -    (insert (concat "(" (propertize tags 'font-lock-face 'notmuch-tag-face) ")")))))\r
117 +    (insert (concat "(" (propertize\r
118 +                        (mapconcat 'identity (plist-get result :tags) " ")\r
119 +                        'font-lock-face 'notmuch-tag-face) ")")))))\r
120  \r
121 -(defun notmuch-search-show-result (thread-id date count authors subject tags)\r
122 +(defun notmuch-search-show-result (result)\r
123    ;; Ignore excluded matches\r
124 -  (unless (eq (aref count 1) ?0)\r
125 -    (let ((beg (point-max))\r
126 -         (tags-str (mapconcat 'identity tags " ")))\r
127 +  (unless (= (plist-get result :matched) 0)\r
128 +    (let ((beg (point-max)))\r
129        (save-excursion\r
130         (goto-char beg)\r
131         (dolist (spec notmuch-search-result-format)\r
132 -         (notmuch-search-insert-field (car spec) (cdr spec)\r
133 -                                      date count authors subject tags-str))\r
134 +         (notmuch-search-insert-field (car spec) (cdr spec) result))\r
135         (insert "\n")\r
136 -       (notmuch-search-color-line beg (point) tags)\r
137 -       (put-text-property beg (point) 'notmuch-search-thread-id thread-id)\r
138 -       (put-text-property beg (point) 'notmuch-search-authors authors)\r
139 -       (put-text-property beg (point) 'notmuch-search-subject subject))\r
140 -      (when (string= thread-id notmuch-search-target-thread)\r
141 +       (notmuch-search-color-line beg (point) (plist-get result :tags))\r
142 +       (put-text-property beg (point) 'notmuch-search-thread-id\r
143 +                          (concat "thread:" (plist-get result :thread)))\r
144 +       (put-text-property beg (point) 'notmuch-search-authors\r
145 +                          (plist-get result :authors))\r
146 +       (put-text-property beg (point) 'notmuch-search-subject\r
147 +                          (plist-get result :subject)))\r
148 +      (when (string= (plist-get result :thread) notmuch-search-target-thread)\r
149         (setq notmuch-search-target-thread "found")\r
150         (goto-char beg)))))\r
151  \r
152 @@ -766,18 +771,24 @@ non-authors is found, assume that all of the authors match."\r
153               (while more\r
154                 (while (and (< line (length string)) (= (elt string line) ?\n))\r
155                   (setq line (1+ line)))\r
156 -               (if (string-match "^\\(thread:[0-9A-Fa-f]*\\) \\([^][]*\\) \\(\\[[0-9/]*\\]\\) \\([^;]*\\); \\(.*\\) (\\([^()]*\\))$" string line)\r
157 +               (if (string-match "^thread:\\([0-9A-Fa-f]*\\) \\([^][]*\\) \\[\\([0-9]*\\)/\\([0-9]*\\)\\] \\([^;]*\\); \\(.*\\) (\\([^()]*\\))$" string line)\r
158                     (let* ((thread-id (match-string 1 string))\r
159 -                          (date (match-string 2 string))\r
160 -                          (count (match-string 3 string))\r
161 -                          (authors (match-string 4 string))\r
162 -                          (subject (match-string 5 string))\r
163 -                          (tags (match-string 6 string))\r
164 -                          (tag-list (if tags (save-match-data (split-string tags)))))\r
165 -                     (if (/= (match-beginning 1) line)\r
166 +                          (tags-str (match-string 7 string))\r
167 +                          (result (list :thread thread-id\r
168 +                                        :date_relative (match-string 2 string)\r
169 +                                        :matched (string-to-number\r
170 +                                                  (match-string 3 string))\r
171 +                                        :total (string-to-number\r
172 +                                                (match-string 4 string))\r
173 +                                        :authors (match-string 5 string)\r
174 +                                        :subject (match-string 6 string)\r
175 +                                        :tags (if tags-str\r
176 +                                                  (save-match-data\r
177 +                                                    (split-string tags-str))))))\r
178 +                     (if (/= (match-beginning 0) line)\r
179                           (notmuch-search-show-error\r
180 -                          (substring string line (match-beginning 1))))\r
181 -                     (notmuch-search-show-result thread-id date count authors subject tag-list)\r
182 +                          (substring string line (match-beginning 0))))\r
183 +                     (notmuch-search-show-result result)\r
184                       (set 'line (match-end 0)))\r
185                   (set 'more nil)\r
186                   (while (and (< line (length string)) (= (elt string line) ?\n))\r
187 -- \r
188 1.7.10\r
189 \r