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 18A2E41ED73
\r
6 for <notmuch@notmuchmail.org>; Thu, 12 Jul 2012 17:45:29 -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 Qgfl8TpxqarU for <notmuch@notmuchmail.org>;
\r
16 Thu, 12 Jul 2012 17:45:26 -0700 (PDT)
\r
17 Received: from dmz-mailsec-scanner-6.mit.edu (DMZ-MAILSEC-SCANNER-6.MIT.EDU
\r
19 by olra.theworths.org (Postfix) with ESMTP id 787C6429E47
\r
20 for <notmuch@notmuchmail.org>; Thu, 12 Jul 2012 17:45:26 -0700 (PDT)
\r
21 X-AuditID: 12074423-b7f396d0000008f4-84-4fff6fa522f2
\r
22 Received: from mailhub-auth-3.mit.edu ( [18.9.21.43])
\r
23 by dmz-mailsec-scanner-6.mit.edu (Symantec Messaging Gateway) with SMTP
\r
24 id 3E.8F.02292.5AF6FFF4; Thu, 12 Jul 2012 20:45:26 -0400 (EDT)
\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])
\r
26 by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id q6D0jP3S011236;
\r
27 Thu, 12 Jul 2012 20:45:25 -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 q6D0jNAm010664
\r
33 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);
\r
34 Thu, 12 Jul 2012 20:45:24 -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 1SpU0Z-0005Rz-IB; Thu, 12 Jul 2012 20:45:23 -0400
\r
38 From: Austin Clements <amdragon@MIT.EDU>
\r
39 To: notmuch@notmuchmail.org
\r
40 Subject: [PATCH 3/7] emacs: Update tags by rewriting the search result line in
\r
42 Date: Thu, 12 Jul 2012 20:45:15 -0400
\r
43 Message-Id: <1342140319-19859-4-git-send-email-amdragon@mit.edu>
\r
44 X-Mailer: git-send-email 1.7.10
\r
45 In-Reply-To: <1342140319-19859-1-git-send-email-amdragon@mit.edu>
\r
46 References: <1342140319-19859-1-git-send-email-amdragon@mit.edu>
\r
47 X-Brightmail-Tracker:
\r
48 H4sIAAAAAAAAA+NgFtrEIsWRmVeSWpSXmKPExsUixCmqrbss/7+/wZUjzBbXb85kdmD0eLbq
\r
49 FnMAYxSXTUpqTmZZapG+XQJXxo9PvewFX2UqHv5bwtrAOEe8i5GTQ0LAROLgrS5WCFtM4sK9
\r
50 9WxdjFwcQgL7GCVebOxhhXA2MErsudgOlXnEJLHo/Gx2CGcuo8SWh5PYQPrZBDQktu1fzghi
\r
51 iwhIS+y8OxuonYODWUBN4k+XCkhYWCBEYtPsg+wgYRYBVYmmI1wgYV4BB4k5vRdZIK6Ql3h6
\r
52 vw9sIqeAo8SGLxfArhMCqmk8NpN5AiP/AkaGVYyyKblVurmJmTnFqcm6xcmJeXmpRbpmermZ
\r
53 JXqpKaWbGEFBw+6ivIPxz0GlQ4wCHIxKPLyLov/7C7EmlhVX5h5ilORgUhLldckGCvEl5adU
\r
54 ZiQWZ8QXleakFh9ilOBgVhLhXWcPlONNSaysSi3Kh0lJc7AoifNeS7npLySQnliSmp2aWpBa
\r
55 BJOV4eBQkuDlBEaHkGBRanpqRVpmTglCmomDE2Q4D9DwbXkgw4sLEnOLM9Mh8qcYFaXEeS+A
\r
56 JARAEhmleXC9sKh+xSgO9Iow7xeQKh5gQoDrfgU0mAlo8Kyf/0AGlyQipKQaGFs1PBlTVmz7
\r
57 qbwtuOxIVMgsk/+e/o+PC7++fSjqjWl0tY9clIXz/deP+RRulTatTdrpP+HRra4pZizG+x/9
\r
58 D77xqXna66W8e872ckt7yNreV/z90OjV/AMGbcskX7wWU1z7aFL/3xmhbko7PtUpzsqJnOGS
\r
59 qcUYk1wzI2OjYDKLTXZFYEvAZiWW4oxEQy3mouJEAHCKqtvFAgAA
\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: Fri, 13 Jul 2012 00:45:29 -0000
\r
74 Now that we keep the full thread result object, we can refresh a
\r
75 result after any changes by simply deleting and reconstructing the
\r
76 result line from scratch.
\r
78 A convenient side-effect of this wholesale replacement is that search
\r
79 now re-applies notmuch-search-line-faces when tags change.
\r
81 emacs/notmuch.el | 55 ++++++++++++++++++++++++++++++------------------------
\r
82 1 file changed, 31 insertions(+), 24 deletions(-)
\r
84 diff --git a/emacs/notmuch.el b/emacs/notmuch.el
\r
85 index 82c148d..2f83425 100644
\r
86 --- a/emacs/notmuch.el
\r
87 +++ b/emacs/notmuch.el
\r
88 @@ -509,28 +509,12 @@ and will also appear in a buffer named \"*Notmuch errors*\"."
\r
89 (error (buffer-substring beg end))
\r
92 -(defun notmuch-search-set-tags (tags)
\r
95 - (re-search-backward "(")
\r
97 - (let ((beg (point))
\r
98 - (inhibit-read-only t))
\r
99 - (re-search-forward ")")
\r
101 - (let ((end (point)))
\r
102 - (delete-region beg end)
\r
103 - (insert (propertize (mapconcat 'identity tags " ")
\r
104 - 'face 'notmuch-tag-face))))))
\r
106 -(defun notmuch-search-get-tags ()
\r
109 - (re-search-backward "(")
\r
110 - (let ((beg (+ (point) 1)))
\r
111 - (re-search-forward ")")
\r
112 - (let ((end (- (point) 1)))
\r
113 - (split-string (buffer-substring-no-properties beg end))))))
\r
114 +(defun notmuch-search-set-tags (tags &optional pos)
\r
115 + (let ((new-result (plist-put (notmuch-search-get-result pos) :tags tags)))
\r
116 + (notmuch-search-update-result new-result pos)))
\r
118 +(defun notmuch-search-get-tags (&optional pos)
\r
119 + (plist-get (notmuch-search-get-result pos) :tags))
\r
121 (defun notmuch-search-get-tags-region (beg end)
\r
123 @@ -583,6 +567,29 @@ This function advances the next thread when finished."
\r
124 (notmuch-search-tag '("-inbox"))
\r
125 (notmuch-search-next-thread))
\r
127 +(defun notmuch-search-update-result (result &optional pos)
\r
128 + "Update the result object of the current thread and redraw it."
\r
129 + (let ((start (notmuch-search-result-beginning pos))
\r
130 + (end (notmuch-search-result-end pos))
\r
131 + (init-point (point))
\r
132 + (inhibit-read-only t))
\r
133 + ;; Delete the current thread
\r
134 + (delete-region start end)
\r
135 + ;; Insert the updated thread
\r
136 + (notmuch-search-show-result result start)
\r
137 + ;; There may have been markers pointing into the text we just
\r
138 + ;; replaced. For the most part, there's nothing we can do about
\r
139 + ;; this, but we can fix markers that were at point (which includes
\r
140 + ;; point itself and any save-excursions for which point hasn't
\r
141 + ;; moved) by re-inserting the text that should come before point
\r
142 + ;; before markers.
\r
143 + (when (and (>= init-point start) (<= init-point end))
\r
144 + (let* ((new-end (notmuch-search-result-end start))
\r
145 + (new-point (if (= init-point end)
\r
147 + (min init-point (- new-end 1)))))
\r
148 + (insert-before-markers (delete-and-extract-region start new-point))))))
\r
150 (defun notmuch-search-process-sentinel (proc msg)
\r
151 "Add a message to let user know when \"notmuch search\" exits"
\r
152 (let ((buffer (process-buffer proc))
\r
153 @@ -745,10 +752,10 @@ non-authors is found, assume that all of the authors match."
\r
154 (mapconcat 'identity (plist-get result :tags) " ")
\r
155 'font-lock-face 'notmuch-tag-face) ")")))))
\r
157 -(defun notmuch-search-show-result (result)
\r
158 +(defun notmuch-search-show-result (result &optional pos)
\r
159 ;; Ignore excluded matches
\r
160 (unless (= (plist-get result :matched) 0)
\r
161 - (let ((beg (point-max)))
\r
162 + (let ((beg (or pos (point-max))))
\r
165 (dolist (spec notmuch-search-result-format)
\r