[PATCH 2/2] contrib: pick: fix refresh result
authorMark Walters <markwalters1009@gmail.com>
Sun, 26 May 2013 06:50:08 +0000 (07:50 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:55:01 +0000 (09:55 -0800)
94/fb5b469a6fce9b52c83982d949b704d55b9500 [new file with mode: 0644]

diff --git a/94/fb5b469a6fce9b52c83982d949b704d55b9500 b/94/fb5b469a6fce9b52c83982d949b704d55b9500
new file mode 100644 (file)
index 0000000..996539f
--- /dev/null
@@ -0,0 +1,119 @@
+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 AE894431FAE\r
+       for <notmuch@notmuchmail.org>; Sat, 25 May 2013 23:50:24 -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 md-uCAPrUeLa for <notmuch@notmuchmail.org>;\r
+       Sat, 25 May 2013 23:50:20 -0700 (PDT)\r
+Received: from mail-wg0-f46.google.com (mail-wg0-f46.google.com\r
+ [74.125.82.46])       (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
+ certificate requested)        by olra.theworths.org (Postfix) with ESMTPS id\r
+ 2BA80431FB6   for <notmuch@notmuchmail.org>; Sat, 25 May 2013 23:50:18 -0700\r
+ (PDT)\r
+Received: by mail-wg0-f46.google.com with SMTP id l18so3514500wgh.25\r
+       for <notmuch@notmuchmail.org>; Sat, 25 May 2013 23:50:17 -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=k3oLI12N5hwpZBw2iHurRwx61VNgThKDEsOMPczFG0g=;\r
+       b=ZOJUUw+/UXIkNQRqWWAEye8xDnn+3arqkcudv5kky/6ygZz0Fv4BP7RBy0XFVha0iL\r
+       QZy/ii5AQo1vzCIr1+56xEvfp3g1Hs04xx1OOdXjg/6qEFmC9Y2emqqaCSdE14c88h8j\r
+       nx/S0rN304fNnTCQoP8veWMgSDdsrb0ebnMYtRk72E65WxBDAP6cptVsO4UKUZP8FGhO\r
+       d/YTzsAftM/xSfNZ+LKppr8L3MhLUboX4JHDpcIxJD3iy2vYpyFpGBlpt9KYYZMxCAP7\r
+       WDFLZUYWz+5hNzMDAwpFnr/liwxDG+ThSOTYtZcjd+VU/is1LbAD2K+vFAQqDsVfIokE\r
+       41sg==\r
+X-Received: by 10.194.77.15 with SMTP id o15mr4401036wjw.27.1369551017144;\r
+       Sat, 25 May 2013 23:50:17 -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 fu14sm9032723wic.8.2013.05.25.23.50.16\r
+       for <multiple recipients>\r
+       (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+       Sat, 25 May 2013 23:50:16 -0700 (PDT)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 2/2] contrib: pick: fix refresh result\r
+Date: Sun, 26 May 2013 07:50:08 +0100\r
+Message-Id: <1369551008-30697-3-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.9.1\r
+In-Reply-To: <1369551008-30697-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1369551008-30697-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, 26 May 2013 06:50:24 -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 9112989..46d9503 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