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