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