--- /dev/null
+Return-Path: <m.walters@qmul.ac.uk>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id E4AC0431FC3\r
+ for <notmuch@notmuchmail.org>; Fri, 13 Jul 2012 10:57:10 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -1.098\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5\r
+ tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,\r
+ NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id Olr1Az7bCBRf for <notmuch@notmuchmail.org>;\r
+ Fri, 13 Jul 2012 10:57:10 -0700 (PDT)\r
+Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])\r
+ (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 04FDB431FAE\r
+ for <notmuch@notmuchmail.org>; Fri, 13 Jul 2012 10:57:10 -0700 (PDT)\r
+Received: from smtp.qmul.ac.uk ([138.37.6.40])\r
+ by mail2.qmul.ac.uk with esmtp (Exim 4.71)\r
+ (envelope-from <m.walters@qmul.ac.uk>)\r
+ id 1Spk6z-0003hs-NY; Fri, 13 Jul 2012 18:57:08 +0100\r
+Received: from 94-192-233-223.zone6.bethere.co.uk ([94.192.233.223]\r
+ helo=localhost)\r
+ by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69)\r
+ (envelope-from <m.walters@qmul.ac.uk>)\r
+ id 1Spk6z-0005c1-Bq; Fri, 13 Jul 2012 18:57:05 +0100\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: Austin Clements <amdragon@MIT.EDU>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH 3/7] emacs: Update tags by rewriting the search result\r
+ line in place\r
+In-Reply-To: <1342140319-19859-4-git-send-email-amdragon@mit.edu>\r
+References: <1342140319-19859-1-git-send-email-amdragon@mit.edu>\r
+ <1342140319-19859-4-git-send-email-amdragon@mit.edu>\r
+User-Agent: Notmuch/0.13.2+63~g1397edd (http://notmuchmail.org) Emacs/23.4.1\r
+ (x86_64-pc-linux-gnu)\r
+Date: Fri, 13 Jul 2012 18:57:03 +0100\r
+Message-ID: <87a9z38ryo.fsf@qmul.ac.uk>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+X-Sender-Host-Address: 94.192.233.223\r
+X-QM-SPAM-Info: Sender has good ham record. :)\r
+X-QM-Body-MD5: 48f8d18415519cb4ce08b987404a9c13 (of first 20000 bytes)\r
+X-SpamAssassin-Score: -1.8\r
+X-SpamAssassin-SpamBar: -\r
+X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
+ determine if it is\r
+ spam. We require at least 5.0 points to mark a message as spam.\r
+ This message scored -1.8 points.\r
+ Summary of the scoring: \r
+ * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/,\r
+ * medium trust\r
+ * [138.37.6.40 listed in list.dnswl.org]\r
+ * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\r
+ provider * (markwalters1009[at]gmail.com)\r
+ * -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay\r
+ * domain\r
+ * 0.5 AWL AWL: From: address is in the auto white-list\r
+X-QM-Scan-Virus: ClamAV says the message is clean\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Fri, 13 Jul 2012 17:57:11 -0000\r
+\r
+On Fri, 13 Jul 2012, Austin Clements <amdragon@MIT.EDU> wrote:\r
+> Now that we keep the full thread result object, we can refresh a\r
+> result after any changes by simply deleting and reconstructing the\r
+> result line from scratch.\r
+>\r
+> A convenient side-effect of this wholesale replacement is that search\r
+> now re-applies notmuch-search-line-faces when tags change.\r
+> ---\r
+> emacs/notmuch.el | 55 ++++++++++++++++++++++++++++++------------------------\r
+> 1 file changed, 31 insertions(+), 24 deletions(-)\r
+>\r
+> diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
+> index 82c148d..2f83425 100644\r
+> --- a/emacs/notmuch.el\r
+> +++ b/emacs/notmuch.el\r
+> @@ -509,28 +509,12 @@ and will also appear in a buffer named \"*Notmuch errors*\"."\r
+> (error (buffer-substring beg end))\r
+> ))))))\r
+> \r
+> -(defun notmuch-search-set-tags (tags)\r
+> - (save-excursion\r
+> - (end-of-line)\r
+> - (re-search-backward "(")\r
+> - (forward-char)\r
+> - (let ((beg (point))\r
+> - (inhibit-read-only t))\r
+> - (re-search-forward ")")\r
+> - (backward-char)\r
+> - (let ((end (point)))\r
+> - (delete-region beg end)\r
+> - (insert (propertize (mapconcat 'identity tags " ")\r
+> - 'face 'notmuch-tag-face))))))\r
+> -\r
+> -(defun notmuch-search-get-tags ()\r
+> - (save-excursion\r
+> - (end-of-line)\r
+> - (re-search-backward "(")\r
+> - (let ((beg (+ (point) 1)))\r
+> - (re-search-forward ")")\r
+> - (let ((end (- (point) 1)))\r
+> - (split-string (buffer-substring-no-properties beg end))))))\r
+> +(defun notmuch-search-set-tags (tags &optional pos)\r
+> + (let ((new-result (plist-put (notmuch-search-get-result pos) :tags tags)))\r
+> + (notmuch-search-update-result new-result pos)))\r
+> +\r
+> +(defun notmuch-search-get-tags (&optional pos)\r
+> + (plist-get (notmuch-search-get-result pos) :tags))\r
+> \r
+> (defun notmuch-search-get-tags-region (beg end)\r
+> (save-excursion\r
+> @@ -583,6 +567,29 @@ This function advances the next thread when finished."\r
+> (notmuch-search-tag '("-inbox"))\r
+> (notmuch-search-next-thread))\r
+> \r
+> +(defun notmuch-search-update-result (result &optional pos)\r
+> + "Update the result object of the current thread and redraw it."\r
+\r
+I think this comment reads a little awkwardly. Maybe "Replace the result\r
+object of the current thread by RESULT and redraw it"?\r
+\r
+> + (let ((start (notmuch-search-result-beginning pos))\r
+> + (end (notmuch-search-result-end pos))\r
+> + (init-point (point))\r
+> + (inhibit-read-only t))\r
+> + ;; Delete the current thread\r
+> + (delete-region start end)\r
+> + ;; Insert the updated thread\r
+> + (notmuch-search-show-result result start)\r
+> + ;; There may have been markers pointing into the text we just\r
+> + ;; replaced. For the most part, there's nothing we can do about\r
+> + ;; this, but we can fix markers that were at point (which includes\r
+> + ;; point itself and any save-excursions for which point hasn't\r
+> + ;; moved) by re-inserting the text that should come before point\r
+> + ;; before markers.\r
+> + (when (and (>= init-point start) (<= init-point end))\r
+> + (let* ((new-end (notmuch-search-result-end start))\r
+> + (new-point (if (= init-point end)\r
+> + new-end\r
+> + (min init-point (- new-end 1)))))\r
+> + (insert-before-markers (delete-and-extract-region start new-point))))))\r
+\r
+I think this doesn't always do quite the right thing with multiline\r
+results: the one that I can reproduce reliably is if you are on the\r
+second line of the first result, and the first line of this result is\r
+the first visible line in the window, and update it (eg by marking\r
+unread) then the window scrolls so that the second line of the first\r
+result is the first line visible in the window (ie the window scrolls up\r
+one line)\r
+\r
+> +\r
+> (defun notmuch-search-process-sentinel (proc msg)\r
+> "Add a message to let user know when \"notmuch search\" exits"\r
+> (let ((buffer (process-buffer proc))\r
+> @@ -745,10 +752,10 @@ non-authors is found, assume that all of the authors match."\r
+> (mapconcat 'identity (plist-get result :tags) " ")\r
+> 'font-lock-face 'notmuch-tag-face) ")")))))\r
+> \r
+> -(defun notmuch-search-show-result (result)\r
+> +(defun notmuch-search-show-result (result &optional pos)\r
+\r
+\r
+Perhaps a documentation line? along the lines of Insert RESULT in buffer\r
+at POS or the end of buffer.\r
+\r
+Best wishes\r
+\r
+Mark\r
+\r
+> ;; Ignore excluded matches\r
+> (unless (= (plist-get result :matched) 0)\r
+> - (let ((beg (point-max)))\r
+> + (let ((beg (or pos (point-max))))\r
+> (save-excursion\r
+> (goto-char beg)\r
+> (dolist (spec notmuch-search-result-format)\r
+> -- \r
+> 1.7.10\r
+>\r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r