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 145E841ED71
\r
6 for <notmuch@notmuchmail.org>; Fri, 13 Jul 2012 20:43:43 -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 ygLRCxbalFRJ for <notmuch@notmuchmail.org>;
\r
16 Fri, 13 Jul 2012 20:43:41 -0700 (PDT)
\r
17 Received: from dmz-mailsec-scanner-8.mit.edu (DMZ-MAILSEC-SCANNER-8.MIT.EDU
\r
19 by olra.theworths.org (Postfix) with ESMTP id D0EA0429E42
\r
20 for <notmuch@notmuchmail.org>; Fri, 13 Jul 2012 20:43:39 -0700 (PDT)
\r
21 X-AuditID: 12074425-b7f9b6d0000008c4-8f-5000eaeb94a3
\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 0B.AD.02244.BEAE0005; Fri, 13 Jul 2012 23:43:39 -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 q6E3hcro014752;
\r
27 Fri, 13 Jul 2012 23:43:38 -0400
\r
28 Received: from drake.dyndns.org
\r
29 (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com
\r
30 [209.6.116.242]) (authenticated bits=0)
\r
31 (User authenticated as amdragon@ATHENA.MIT.EDU)
\r
32 by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q6E3hbfB021327
\r
33 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);
\r
34 Fri, 13 Jul 2012 23:43:38 -0400 (EDT)
\r
35 Received: from amthrax by drake.dyndns.org with local (Exim 4.77)
\r
36 (envelope-from <amdragon@mit.edu>)
\r
37 id 1SptGa-0000Zz-Ol; Fri, 13 Jul 2012 23:43:36 -0400
\r
38 From: Austin Clements <amdragon@MIT.EDU>
\r
39 To: notmuch@notmuchmail.org
\r
40 Subject: [PATCH v2 3/7] emacs: Update tags by rewriting the search result line
\r
42 Date: Fri, 13 Jul 2012 23:43:22 -0400
\r
43 Message-Id: <1342237406-32507-4-git-send-email-amdragon@mit.edu>
\r
44 X-Mailer: git-send-email 1.7.10
\r
45 In-Reply-To: <1342237406-32507-1-git-send-email-amdragon@mit.edu>
\r
46 References: <1342140319-19859-1-git-send-email-amdragon@mit.edu>
\r
47 <1342237406-32507-1-git-send-email-amdragon@mit.edu>
\r
48 X-Brightmail-Tracker:
\r
49 H4sIAAAAAAAAA+NgFtrFIsWRmVeSWpSXmKPExsUixG6novv6FUOAwZsdYhar5/JYXL85k9mB
\r
50 yWPnrLvsHs9W3WIOYIrisklJzcksSy3St0vgynh8VbrgsVxF08XABsZrEl2MnBwSAiYStzZ9
\r
51 ZoKwxSQu3FvP1sXIxSEksI9R4sHsWywQzgZGieZXnxkhnEdMEu8vzYRy5jJKbJ9+hw2kn01A
\r
52 Q2Lb/uWMILaIgLTEzruzWUFsZgFHic/7F4HVCAuES+yceZ+5i5GDg0VAVeJcdypImFfAQWJW
\r
53 9wd2iDPkJZ7e7wMr5wRqbeu9DTZSSKBc4vq3NUwTGPkXMDKsYpRNya3SzU3MzClOTdYtTk7M
\r
54 y0st0rXQy80s0UtNKd3ECA4iF9UdjBMOKR1iFOBgVOLhTfRnCBBiTSwrrsw9xCjJwaQkyssL
\r
55 DEEhvqT8lMqMxOKM+KLSnNTiQ4wSHMxKIrzmbUA53pTEyqrUonyYlDQHi5I4742Um/5CAumJ
\r
56 JanZqakFqUUwWRkODiUJXmGQoYJFqempFWmZOSUIaSYOTpDhPEDDpUFqeIsLEnOLM9Mh8qcY
\r
57 FaXEee1AEgIgiYzSPLheWJS/YhQHekWY1wakigeYIOC6XwENZgIaPOvnP3+gwSWJCCmpBkbP
\r
58 SwYns3Z7h2ue22xyW/3RxJK4kl0rHybOmdLA+erB6x2vfxvv/6leHXf9/CL5DXyrElOedHXp
\r
59 8F26prsxe27UtBsCScsSJx+20Mz4e8XwXFWMxbtbr56ZfDuplqPpnDxH/3Jq/g0Z/jW5uuGn
\r
60 k6O3Ca4w/3P2oeavhY/D9HMVrqQu+mUks8lTiaU4I9FQi7moOBEAiF8dQ80CAAA=
\r
61 X-BeenThere: notmuch@notmuchmail.org
\r
62 X-Mailman-Version: 2.1.13
\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: Sat, 14 Jul 2012 03:43:43 -0000
\r
75 Now that we keep the full thread result object, we can refresh a
\r
76 result after any changes by simply deleting and reconstructing the
\r
77 result line from scratch.
\r
79 A convenient side-effect of this wholesale replacement is that search
\r
80 now re-applies notmuch-search-line-faces when tags change.
\r
82 emacs/notmuch.el | 60 ++++++++++++++++++++++++++++++++----------------------
\r
83 1 file changed, 36 insertions(+), 24 deletions(-)
\r
85 diff --git a/emacs/notmuch.el b/emacs/notmuch.el
\r
86 index 82c148d..8e1a769 100644
\r
87 --- a/emacs/notmuch.el
\r
88 +++ b/emacs/notmuch.el
\r
89 @@ -509,28 +509,12 @@ and will also appear in a buffer named \"*Notmuch errors*\"."
\r
90 (error (buffer-substring beg end))
\r
93 -(defun notmuch-search-set-tags (tags)
\r
96 - (re-search-backward "(")
\r
98 - (let ((beg (point))
\r
99 - (inhibit-read-only t))
\r
100 - (re-search-forward ")")
\r
102 - (let ((end (point)))
\r
103 - (delete-region beg end)
\r
104 - (insert (propertize (mapconcat 'identity tags " ")
\r
105 - 'face 'notmuch-tag-face))))))
\r
107 -(defun notmuch-search-get-tags ()
\r
110 - (re-search-backward "(")
\r
111 - (let ((beg (+ (point) 1)))
\r
112 - (re-search-forward ")")
\r
113 - (let ((end (- (point) 1)))
\r
114 - (split-string (buffer-substring-no-properties beg end))))))
\r
115 +(defun notmuch-search-set-tags (tags &optional pos)
\r
116 + (let ((new-result (plist-put (notmuch-search-get-result pos) :tags tags)))
\r
117 + (notmuch-search-update-result new-result pos)))
\r
119 +(defun notmuch-search-get-tags (&optional pos)
\r
120 + (plist-get (notmuch-search-get-result pos) :tags))
\r
122 (defun notmuch-search-get-tags-region (beg end)
\r
124 @@ -583,6 +567,33 @@ This function advances the next thread when finished."
\r
125 (notmuch-search-tag '("-inbox"))
\r
126 (notmuch-search-next-thread))
\r
128 +(defun notmuch-search-update-result (result &optional pos)
\r
129 + "Replace the result object of the thread at POS (or point) by
\r
130 +RESULT and redraw it."
\r
131 + (let ((start (notmuch-search-result-beginning pos))
\r
132 + (end (notmuch-search-result-end pos))
\r
133 + (init-point (point))
\r
134 + (init-start (window-start))
\r
135 + (inhibit-read-only t))
\r
136 + ;; Delete the current thread
\r
137 + (delete-region start end)
\r
138 + ;; Insert the updated thread
\r
139 + (notmuch-search-show-result result start)
\r
140 + ;; There may have been markers pointing into the text we just
\r
141 + ;; replaced. For the most part, there's nothing we can do about
\r
142 + ;; this, but we can fix markers that were at point (which includes
\r
143 + ;; point itself and any save-excursions for which point hasn't
\r
144 + ;; moved) by re-inserting the text that should come before point
\r
145 + ;; before markers.
\r
146 + (when (and (>= init-point start) (<= init-point end))
\r
147 + (let* ((new-end (notmuch-search-result-end start))
\r
148 + (new-point (if (= init-point end)
\r
150 + (min init-point (- new-end 1)))))
\r
151 + (insert-before-markers (delete-and-extract-region start new-point))))
\r
152 + ;; We also may have shifted the window scroll. Fix it.
\r
153 + (set-window-start (selected-window) init-start)))
\r
155 (defun notmuch-search-process-sentinel (proc msg)
\r
156 "Add a message to let user know when \"notmuch search\" exits"
\r
157 (let ((buffer (process-buffer proc))
\r
158 @@ -745,10 +756,11 @@ non-authors is found, assume that all of the authors match."
\r
159 (mapconcat 'identity (plist-get result :tags) " ")
\r
160 'font-lock-face 'notmuch-tag-face) ")")))))
\r
162 -(defun notmuch-search-show-result (result)
\r
163 +(defun notmuch-search-show-result (result &optional pos)
\r
164 + "Insert RESULT at POS or the end of the buffer if POS is null."
\r
165 ;; Ignore excluded matches
\r
166 (unless (= (plist-get result :matched) 0)
\r
167 - (let ((beg (point-max)))
\r
168 + (let ((beg (or pos (point-max))))
\r
171 (dolist (spec notmuch-search-result-format)
\r