--- /dev/null
+Return-Path: <markwalters1009@gmail.com>\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 77B03431FCF\r
+ for <notmuch@notmuchmail.org>; Sun, 30 Jun 2013 01:55:29 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.201\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
+ tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+ FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
+ RCVD_IN_DNSWL_LOW=-0.7] 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 d2gPHIUWxOs6 for <notmuch@notmuchmail.org>;\r
+ Sun, 30 Jun 2013 01:55:25 -0700 (PDT)\r
+Received: from mail-we0-f175.google.com (mail-we0-f175.google.com\r
+ [74.125.82.175]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 17217431FC2\r
+ for <notmuch@notmuchmail.org>; Sun, 30 Jun 2013 01:55:22 -0700 (PDT)\r
+Received: by mail-we0-f175.google.com with SMTP id t59so2483534wes.34\r
+ for <notmuch@notmuchmail.org>; Sun, 30 Jun 2013 01:55:22 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+ h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;\r
+ bh=7mupWdI9ysGTEZQlOvljZKwPGzVM57fxAuLerd1lOHQ=;\r
+ b=ellvnHwz7YnAFwddJr07s1Er5Zz27dMvMh/UT2VHP54KfBJwmNuy+M3ueCuSzzxnGn\r
+ ZmoZ5Bbx8bW8l2pfJ4tt9W4eRQey5QYno57syHPP8FNIEab7hAQ+8wYbSEAioej4+z2m\r
+ KWoXfkQQ4Unktlt58jgBPaN8XBvEo8HEsZBQgravRHduQ2jZsmXLeWS+NMTrGMSdbd2U\r
+ /iVEXqpXlE9zJ/nkzL6/3u0qiVzYKkCaswEhd1EzrK6JsxTtM8KVXunBMkmzYCUh3qRS\r
+ qnDwtYI3Fw9qcsnHSqt2XS/roLS9if6PZ0PdkPRzS4O2sGlbDhNbXFIiT0oytKiyC+ka\r
+ drvA==\r
+X-Received: by 10.180.189.68 with SMTP id gg4mr9069164wic.27.1372582521977;\r
+ Sun, 30 Jun 2013 01:55:21 -0700 (PDT)\r
+Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])\r
+ by mx.google.com with ESMTPSA id fd3sm8505461wic.10.2013.06.30.01.55.20\r
+ for <multiple recipients>\r
+ (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+ Sun, 30 Jun 2013 01:55:21 -0700 (PDT)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2 3/3] contrib: pick: fix refresh result\r
+Date: Sun, 30 Jun 2013 09:55:12 +0100\r
+Message-Id: <1372582512-10777-4-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.9.1\r
+In-Reply-To: <1372582512-10777-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1372582512-10777-1-git-send-email-markwalters1009@gmail.com>\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, 30 Jun 2013 08:55:29 -0000\r
+\r
+The function notmuch-pick-refresh-result (used to update tag changes)\r
+was not quite correct: sometimes it got the choice between the subject\r
+and " ..." wrong. This was always true but the new code often calls\r
+this (when opening a message in the message pane to remove the unread\r
+tag) while the async pick process is still running and this caused\r
+mistakes which made the tests fail.\r
+\r
+Thus we store the previous subject with the message.\r
+---\r
+ contrib/notmuch-pick/notmuch-pick.el | 23 +++++++++++++++++------\r
+ 1 files changed, 17 insertions(+), 6 deletions(-)\r
+\r
+diff --git a/contrib/notmuch-pick/notmuch-pick.el b/contrib/notmuch-pick/notmuch-pick.el\r
+index 5639c7c..11b5058 100644\r
+--- a/contrib/notmuch-pick/notmuch-pick.el\r
++++ b/contrib/notmuch-pick/notmuch-pick.el\r
+@@ -264,8 +264,15 @@ Some useful entries are:\r
+ (msg (notmuch-pick-get-message-properties))\r
+ (inhibit-read-only t))\r
+ (beginning-of-line)\r
+- (delete-region (point) (1+ (line-end-position)))\r
+- (notmuch-pick-insert-msg msg)\r
++ ;; This is a little tricky: we override\r
++ ;; notmuch-pick-previous-subject to get the decision between\r
++ ;; ... and a subject right and it stops notmuch-pick-insert-msg\r
++ ;; from overwriting the buffer local copy of\r
++ ;; notmuch-pick-previous-subject if this is called while the\r
++ ;; buffer is displaying.\r
++ (let ((notmuch-pick-previous-subject (notmuch-pick-get-prop :previous-subject)))\r
++ (delete-region (point) (1+ (line-end-position)))\r
++ (notmuch-pick-insert-msg msg))\r
+ (let ((new-end (line-end-position)))\r
+ (goto-char (if (= init-point end)\r
+ new-end\r
+@@ -628,10 +635,14 @@ unchanged ADDRESS if parsing fails."\r
+ \r
+ (defun notmuch-pick-insert-msg (msg)\r
+ "Insert the message MSG according to notmuch-pick-result-format"\r
+- (dolist (spec notmuch-pick-result-format)\r
+- (notmuch-pick-insert-field (car spec) (cdr spec) msg))\r
+- (notmuch-pick-set-message-properties msg)\r
+- (insert "\n"))\r
++ ;; We need to save the previous subject as it will get overwritten\r
++ ;; by the insert-field calls.\r
++ (let ((previous-subject notmuch-pick-previous-subject))\r
++ (dolist (spec notmuch-pick-result-format)\r
++ (notmuch-pick-insert-field (car spec) (cdr spec) msg))\r
++ (notmuch-pick-set-message-properties msg)\r
++ (notmuch-pick-set-prop :previous-subject previous-subject)\r
++ (insert "\n")))\r
+ \r
+ (defun notmuch-pick-goto-and-insert-msg (msg)\r
+ "Insert msg at the end of the buffer. Move point to msg if it is the target"\r
+-- \r
+1.7.9.1\r
+\r