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 064CA429E29
\r
6 for <notmuch@notmuchmail.org>; Sat, 14 Jul 2012 16:02:33 -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 Mha1YR3XyfKz for <notmuch@notmuchmail.org>;
\r
16 Sat, 14 Jul 2012 16:02:31 -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 3744D429E2F
\r
20 for <notmuch@notmuchmail.org>; Sat, 14 Jul 2012 16:02:27 -0700 (PDT)
\r
21 X-AuditID: 12074423-b7f396d0000008f4-d8-5001fa823436
\r
22 Received: from mailhub-auth-2.mit.edu ( [18.7.62.36])
\r
23 by dmz-mailsec-scanner-6.mit.edu (Symantec Messaging Gateway) with SMTP
\r
24 id 95.26.02292.28AF1005; Sat, 14 Jul 2012 19:02:26 -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 q6EN2PN0031812;
\r
27 Sat, 14 Jul 2012 19:02: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 q6EN2OXq008495
\r
33 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);
\r
34 Sat, 14 Jul 2012 19:02: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 1SqBLz-0002G7-Re; Sat, 14 Jul 2012 19:02:23 -0400
\r
38 From: Austin Clements <amdragon@MIT.EDU>
\r
39 To: notmuch@notmuchmail.org
\r
40 Subject: [PATCH v3 3/8] emacs: Update tags by rewriting the search result line
\r
42 Date: Sat, 14 Jul 2012 19:02:15 -0400
\r
43 Message-Id: <1342306940-7499-4-git-send-email-amdragon@mit.edu>
\r
44 X-Mailer: git-send-email 1.7.10
\r
45 In-Reply-To: <1342306940-7499-1-git-send-email-amdragon@mit.edu>
\r
46 References: <1342140319-19859-1-git-send-email-amdragon@mit.edu>
\r
47 <1342306940-7499-1-git-send-email-amdragon@mit.edu>
\r
48 X-Brightmail-Tracker:
\r
49 H4sIAAAAAAAAA+NgFjrEIsWRmVeSWpSXmKPExsUixG6notv0izHA4OxEHos9+7wsVs/lsbh+
\r
50 cyazA7PH3dNcHjtn3WX3eLbqFnMAcxSXTUpqTmZZapG+XQJXxuOr0gWP5SqaLgY2MF6T6GLk
\r
51 5JAQMJHY2d7FDmGLSVy4t56ti5GLQ0hgH6PE//9LWCCcDYwS+zt+MIJUCQk8YpJ4NdUbIjGX
\r
52 UWL32kVMIAk2AQ2JbfuXgxWJCEhL7Lw7mxXEZhZIk/je/hYsLiwQLnHo+nk2EJtFQFXi95yj
\r
53 YDavgL3E18sbmSHOkJd4er8PLM4p4CBx+MIJVojFZRI3nnxnncDIv4CRYRWjbEpulW5uYmZO
\r
54 cWqybnFyYl5eapGumV5uZoleakrpJkZwULko72D8c1DpEKMAB6MSD2+SP0OAEGtiWXFl7iFG
\r
55 SQ4mJVHe1z8ZA4T4kvJTKjMSizPii0pzUosPMUpwMCuJ8Ep8BcrxpiRWVqUW5cOkpDlYlMR5
\r
56 r6Xc9BcSSE8sSc1OTS1ILYLJynBwKEnwvgIZKliUmp5akZaZU4KQZuLgBBnOAzT8JEgNb3FB
\r
57 Ym5xZjpE/hSjopQ4REIAJJFRmgfXC4v6V4ziQK8I8z4EqeIBJgy47ldAg5mABs/6+c8faHBJ
\r
58 IkJKqoFROkbrvd6NKHHuvyUFrvbPum6WTL9aET1zKoubh1pYyWIu4yWfzk21Wftgy8EU9apy
\r
59 Td+Pq5MuthUvfBjOfqyS+bOx3OnTPuuTDm3x/PL/pNHt4oiDoSvfhV58svik0IefB1SzeA9r
\r
60 /VAz2qpuylVyr+fWeT/vk0u4uO3Petnvss4KEHWZzfZQiaU4I9FQi7moOBEA/dTr8dUCAAA=
\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 23:02:33 -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