--- /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 0163B431FAF\r
+ for <notmuch@notmuchmail.org>; Sun, 22 Jul 2012 08:28:04 -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 m+h77mIIIfIE for <notmuch@notmuchmail.org>;\r
+ Sun, 22 Jul 2012 08:28:00 -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 2723F431FAE\r
+ for <notmuch@notmuchmail.org>; Sun, 22 Jul 2012 08:28:00 -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 1Ssy4W-0005S7-Sx; Sun, 22 Jul 2012 16:27:55 +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 1Ssy4W-0004UL-FF; Sun, 22 Jul 2012 16:27:52 +0100\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: Austin Clements <amdragon@MIT.EDU>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH v4 0/8] emacs: JSON-based search cleanups\r
+In-Reply-To: <1342892232-5659-1-git-send-email-amdragon@mit.edu>\r
+References: <1341354059-29396-1-git-send-email-amdragon@mit.edu>\r
+ <1342892232-5659-1-git-send-email-amdragon@mit.edu>\r
+User-Agent: Notmuch/0.13.2+82~g23d46be (http://notmuchmail.org) Emacs/23.4.1\r
+ (x86_64-pc-linux-gnu)\r
+Date: Sun, 22 Jul 2012 16:27:53 +0100\r
+Message-ID: <877gtvq0hy.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: 7fa17d740af2e6d74b4853cc7a622086 (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: Sun, 22 Jul 2012 15:28:04 -0000\r
+\r
+\r
+This version looks good to me +1\r
+\r
+Best wishes\r
+\r
+Mark\r
+\r
+On Sat, 21 Jul 2012, Austin Clements <amdragon@MIT.EDU> wrote:\r
+> This version fixes several bugs found in the previous version. I\r
+> replaced the insert-before-markers trick in\r
+> notmuch-search-update-result with direct point manipulation. This\r
+> fixes the problem with authors getting unhidden when a result is\r
+> updated with point after the authors on the line (since it no longer\r
+> deletes the region with the invisibility overlay). I also removed the\r
+> scrolling hack (which was partially necessitated by\r
+> insert-before-markers), so that archiving the last visible result will\r
+> properly scroll the buffer instead of jumping point to the middle of\r
+> the visible window. As a result, the window may scroll when updating\r
+> a multiline result, however, it will scroll to show the entire result\r
+> (unlike an earlier version where it scrolled to cut off the result\r
+> because of an interaction with insert-before-markers). Finally, I\r
+> fixed notmuch-search-last-thread so that it behaves like it did before\r
+> when there are no results, rather than failing with an obscure error.\r
+>\r
+> I also updated the customize documentation and NEWS to indicate that\r
+> multiline search results are considered experimental.\r
+>\r
+> Diff from v3:\r
+>\r
+> diff --git a/NEWS b/NEWS\r
+> index 7b33f0d..7b1f36c 100644\r
+> --- a/NEWS\r
+> +++ b/NEWS\r
+> @@ -25,7 +25,7 @@ The formatting of tags in search results can now be customized\r
+> `notmuch-search-result-format` would usually break tagging from\r
+> search-mode. We no longer make assumptions about the format.\r
+> \r
+> -Multi-line search result formats are now supported\r
+> +Experimental support for multi-line search result formats\r
+> \r
+> It is now possible to embed newlines in\r
+> `notmuch-search-result-format` to make individual search results\r
+> diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
+> index ec760dc..fd1836f 100644\r
+> --- a/emacs/notmuch.el\r
+> +++ b/emacs/notmuch.el\r
+> @@ -70,12 +70,12 @@\r
+> For example:\r
+> (setq notmuch-search-result-format \(\(\"authors\" . \"%-40s\"\)\r
+> \(\"subject\" . \"%s\"\)\)\)\r
+> -Line breaks are permitted in format strings. Note that a line\r
+> -break at the end of an \"authors\" field will get elided if the\r
+> -authors list is long; place it instead at the beginning of the\r
+> -following field. To enter a line break when setting this\r
+> -variable with setq, use \\n. To enter a line break in customize,\r
+> -press \\[quoted-insert] C-j."\r
+> +Line breaks are permitted in format strings (though this is\r
+> +currently experimental). Note that a line break at the end of an\r
+> +\"authors\" field will get elided if the authors list is long;\r
+> +place it instead at the beginning of the following field. To\r
+> +enter a line break when setting this variable with setq, use \\n.\r
+> +To enter a line break in customize, press \\[quoted-insert] C-j."\r
+> :type '(alist :key-type (string) :value-type (string))\r
+> :group 'notmuch-search)\r
+> \r
+> @@ -310,7 +310,8 @@ For a mouse binding, return nil."\r
+> (interactive)\r
+> (goto-char (point-max))\r
+> (forward-line -2)\r
+> - (goto-char (notmuch-search-result-beginning)))\r
+> + (let ((beg (notmuch-search-result-beginning)))\r
+> + (when beg (goto-char beg))))\r
+> \r
+> (defun notmuch-search-first-thread ()\r
+> "Select the first thread in the search results."\r
+> @@ -599,30 +600,31 @@ This function advances the next thread when finished."\r
+> \r
+> (defun notmuch-search-update-result (result &optional pos)\r
+> "Replace the result object of the thread at POS (or point) by\r
+> -RESULT and redraw it."\r
+> +RESULT and redraw it.\r
+> +\r
+> +This will keep point in a reasonable location. However, if there\r
+> +are enclosing save-excursions and the saved point is in the\r
+> +result being updated, the point will be restored to the beginning\r
+> +of the result."\r
+> (let ((start (notmuch-search-result-beginning pos))\r
+> (end (notmuch-search-result-end pos))\r
+> (init-point (point))\r
+> - (init-start (window-start))\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
+> + ;; If point was inside the old result, make an educated guess\r
+> + ;; about where to place it now. Unfortunately, this won't work\r
+> + ;; with save-excursion (or any other markers that would be nice to\r
+> + ;; preserve, such as the window start), but there's nothing we can\r
+> + ;; do about that without a way to retrieve markers in a region.\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
+> - ;; We also may have shifted the window scroll. Fix it.\r
+> - (set-window-start (selected-window) init-start)))\r
+> + (goto-char new-point)))))\r
+> \r
+> (defun notmuch-search-process-sentinel (proc msg)\r
+> "Add a message to let user know when \"notmuch search\" exits"\r