Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 55 / a03a3ec6345746da49e7de164fcdd4c641b995
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 80C28431FAE\r
6         for <notmuch@notmuchmail.org>; Mon,  9 Jul 2012 14:42:55 -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 QcVSfCSrLhB9 for <notmuch@notmuchmail.org>;\r
16         Mon,  9 Jul 2012 14:42:53 -0700 (PDT)\r
17 Received: from dmz-mailsec-scanner-8.mit.edu (DMZ-MAILSEC-SCANNER-8.MIT.EDU\r
18         [18.7.68.37])\r
19         by olra.theworths.org (Postfix) with ESMTP id D5F5F429E30\r
20         for <notmuch@notmuchmail.org>; Mon,  9 Jul 2012 14:42:50 -0700 (PDT)\r
21 X-AuditID: 12074425-b7f9b6d0000008c4-c7-4ffb505855a3\r
22 Received: from mailhub-auth-2.mit.edu ( [18.7.62.36])\r
23         by dmz-mailsec-scanner-8.mit.edu (Symantec Messaging Gateway) with SMTP\r
24         id F2.E0.02244.8505BFF4; Mon,  9 Jul 2012 17:42:48 -0400 (EDT)\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
26         by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id q69LglAj003848; \r
27         Mon, 9 Jul 2012 17:42:47 -0400\r
28 Received: from drake.dyndns.org (26-4-176.dynamic.csail.mit.edu [18.26.4.176])\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 q69LgiVe022686\r
32         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
33         Mon, 9 Jul 2012 17:42:45 -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 1SoLjA-0004g0-1C; Mon, 09 Jul 2012 17:42:44 -0400\r
37 From: Austin Clements <amdragon@MIT.EDU>\r
38 To: notmuch@notmuchmail.org\r
39 Subject: [PATCH v3 5/9] emacs: Pass plist to `notmuch-search-show-result'\r
40 Date: Mon,  9 Jul 2012 17:42:38 -0400\r
41 Message-Id: <1341870162-17782-6-git-send-email-amdragon@mit.edu>\r
42 X-Mailer: git-send-email 1.7.10\r
43 In-Reply-To: <1341870162-17782-1-git-send-email-amdragon@mit.edu>\r
44 References: <1341354059-29396-1-git-send-email-amdragon@mit.edu>\r
45         <1341870162-17782-1-git-send-email-amdragon@mit.edu>\r
46 X-Brightmail-Tracker:\r
47  H4sIAAAAAAAAA+NgFrrEIsWRmVeSWpSXmKPExsUixG6nohsR8NvfYGu7nsXquTwW12/OZLZ4\r
48         s3IeqwOzx85Zd9k9Dn9dyOLxbNUt5gDmKC6blNSczLLUIn27BK6MPTtWMBYc1qxomdHM1MC4\r
49         UbGLkZNDQsBE4tOfb4wQtpjEhXvr2boYuTiEBPYxSny4tYcFwlnPKNE+4SYrhHOSSeLjlyWM\r
50         EM5cRonl94+zgfSzCWhIbNu/HGyWiIC0xM67s1lBbGaBOIktU/4DxTk4hAU8JRbskgcJswio\r
51         Ssw42MoMYvMKOEisPzyBCeIMeYmn9/vARnIKOErMubkDbKSQQLnE5xv/mCcw8i9gZFjFKJuS\r
52         W6Wbm5iZU5yarFucnJiXl1qka6GXm1mil5pSuokRHFwuqjsYJxxSOsQowMGoxMO7keW3vxBr\r
53         YllxZe4hRkkOJiVR3jxPoBBfUn5KZUZicUZ8UWlOavEhRgkOZiUR3luuQDnelMTKqtSifJiU\r
54         NAeLkjjvjZSb/kIC6YklqdmpqQWpRTBZGQ4OJQneaf5AjYJFqempFWmZOSUIaSYOTpDhPEDD\r
55         J4DU8BYXJOYWZ6ZD5E8x6nKse3PkBqMQS15+XqqUOO9kkCIBkKKM0jy4ObCk8IpRHOgtYd4i\r
56         kCoeYEKBm/QKaAkT0JL2nl8gS0oSEVJSDYzFZmliZR7G71b4O7oeL85gsXv80er+inqbbsMV\r
57         ijpsktc2b5usV5EVtPCCRtwBV96+nh9Pb/yY7Hjny4tEgd+1HM2f58zvOZDjv6bkwXHGR9tv\r
58         8zuf1OV+bLVprfaxwm7B+m8Xk4LzIlIUM6pt+Hg0jd5yZvGemrlDLnGlxUqDwItNF7LyRJVY\r
59         ijMSDbWYi4oTAd18xl/lAgAA\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: Mon, 09 Jul 2012 21:42:56 -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