From cd6c8de5df26cb1324cc8b30fbe576c2e7252f5f Mon Sep 17 00:00:00 2001 From: Mark Walters Date: Thu, 9 Jun 2016 10:54:10 +0100 Subject: [PATCH] [PATCH] emacs: show: improve handling of mark read tagging errors --- 12/6798a70ae2d03e7dfb1870e21c2630687c3d86 | 153 ++++++++++++++++++++++ 1 file changed, 153 insertions(+) create mode 100644 12/6798a70ae2d03e7dfb1870e21c2630687c3d86 diff --git a/12/6798a70ae2d03e7dfb1870e21c2630687c3d86 b/12/6798a70ae2d03e7dfb1870e21c2630687c3d86 new file mode 100644 index 000000000..e4cfd2508 --- /dev/null +++ b/12/6798a70ae2d03e7dfb1870e21c2630687c3d86 @@ -0,0 +1,153 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by arlo.cworth.org (Postfix) with ESMTP id F14BC6DE0281 + for ; Thu, 9 Jun 2016 02:54:24 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: -0.331 +X-Spam-Level: +X-Spam-Status: No, score=-0.331 tagged_above=-999 required=5 tests=[AWL=0.239, + DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, + RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] + autolearn=disabled +Received: from arlo.cworth.org ([127.0.0.1]) + by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id jSMCgc5Tf3b9 for ; + Thu, 9 Jun 2016 02:54:17 -0700 (PDT) +Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com + [74.125.82.65]) by arlo.cworth.org (Postfix) with ESMTPS id CF3E46DE01C2 for + ; Thu, 9 Jun 2016 02:54:16 -0700 (PDT) +Received: by mail-wm0-f65.google.com with SMTP id m124so9222217wme.3 + for ; Thu, 09 Jun 2016 02:54:16 -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:in-reply-to:references; + bh=QOd+Z7/1DUGy5QN/DHU0wgwsSc0S/LyfFRfYP8Or1Gg=; + b=OwMs86qtNkTIy7VQtB/x4IM3INKcRCVF+jrqxCsU7LHCP26MYLvzouQVGIBkcWZOVI + ZDJ8cJLIcRkBtfUk/0oAORDK2P5Q5nDn6OPZ8KkVB4cjEUzdvcJBtmyM2kDi6Z77+8P6 + PoGLqHFlLzCDlC19ELGQ9CeuzXHM/sybqyQhgvnl08bw1mdtcBe6QJ59Q40KmCoEv2BP + pC8TPHdc4XKsx9B4HVpJ4lnm3qsw3Xfseup8AE7FAu/RIGUrEtsvmAvP21gW+Ri+k4KM + 8O8jeVa0GqSE+HSBmLO/qG8r48uoOQrx1/sOti77FtlzlDJ99gOqUefZTCIZSJJZcn6G + qolQ== +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=1e100.net; s=20130820; + h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to + :references; + bh=QOd+Z7/1DUGy5QN/DHU0wgwsSc0S/LyfFRfYP8Or1Gg=; + b=gPO37mrYLKQ+NzqFiHQRFljsAj44ZjRYBlph71j1DDMvPQmicoz7UefyPKHZsYXLTB + +5XPieCEtCOVfVC3qIJfafjA7sKrozN8fVvti3fHxexhd2LDbv1/KbGTpaGWmI2XrNAA + ki/tahpkOhg8abgSB71TyCXNWpppw0Mcbv7jg2VT3vhngATCx6PgwOkVP9iI3b3S6Mdn + RriXquFQpMFSJwT73doLDZj2BCSMnSktwX0C8+MNJZBEe9Hro95gU31wtm1A7cDx1mOy + hATND6B1Va/Sv5VwXm4BUi14aMS5vZSGfT1Bb7V21SWgHYpt7wcgybW6e6hi/BeF3FOW + qSEg== +X-Gm-Message-State: + ALyK8tIHxDc+G56NGC0pm8g5HQz7sCEon56Q8A/OEpCiOZeX2QXU6RKEl0ZuLCsUSMh3SA== +X-Received: by 10.28.197.132 with SMTP id v126mr1989870wmf.8.1465466054929; + Thu, 09 Jun 2016 02:54:14 -0700 (PDT) +Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162]) + by smtp.gmail.com with ESMTPSA id k127sm6707348wmf.21.2016.06.09.02.54.13 + (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); + Thu, 09 Jun 2016 02:54:13 -0700 (PDT) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [PATCH] emacs: show: improve handling of mark read tagging errors +Date: Thu, 9 Jun 2016 10:54:10 +0100 +Message-Id: <1465466050-27220-1-git-send-email-markwalters1009@gmail.com> +X-Mailer: git-send-email 2.1.4 +In-Reply-To: <1465336292-18704-1-git-send-email-markwalters1009@gmail.com> +References: <1465336292-18704-1-git-send-email-markwalters1009@gmail.com> +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.20 +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: Thu, 09 Jun 2016 09:54:25 -0000 + +Previously if a marking read tag change (i.e., removing the unread +tag) failed for some reason, such as a locked database, then no more +mark read tag changes would be attempted in that buffer. + +This handles the error more gracefully. There is not much we can do +yet about dealing with the error itself, and marking read is probably +not important enough to warrant keeping a queue of pending changes or +anything. + +However this commit changes it so that + +- we do try and make future mark read tag changes. + +- we display the tag state correctly: i.e. we don't display the tag as + deleted (no strike through) + +- and since we know the tag change failed we can try to mark this + message read in the future. Indeed, since the code uses the + post-command hook we will try again on the next keypress (unless the + user has left the message). + +We indicate to the user that these mark read tag changes may have +failed in the header-line. +--- + +This is a slightly changed version of the previous patch, based on +some comments and a patch Tomi had on irc. + +The changes are: + +- we allow the debugger to run if debug-on-error is set + +- the condition-case now protects any customised mark-read function + +- the fact that a tagging error may have occured is displayed in the headerline + +Best wishes + +Mark + + + + + +emacs/notmuch-show.el | 13 ++++++++++++- + 1 file changed, 12 insertions(+), 1 deletion(-) + +diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el +index fea39fa..6d3149b 100644 +--- a/emacs/notmuch-show.el ++++ b/emacs/notmuch-show.el +@@ -1701,12 +1701,23 @@ user decision and we should not override it." + (notmuch-show-mark-read) + (notmuch-show-set-prop :seen t))) + ++(defvar notmuch-show--seen-has-errored nil) ++(make-variable-buffer-local 'notmuch-show--seen-has-errored) ++ + (defun notmuch-show-command-hook () + (when (eq major-mode 'notmuch-show-mode) + ;; We need to redisplay to get window-start and window-end correct. + (redisplay) + (save-excursion +- (funcall notmuch-show-mark-read-function (window-start) (window-end))))) ++ (condition-case err ++ (funcall notmuch-show-mark-read-function (window-start) (window-end)) ++ ((debug error) ++ (unless notmuch-show--seen-has-errored ++ (setq notmuch-show--seen-has-errored 't) ++ (setq header-line-format ++ (concat header-line-format ++ (propertize " [some mark read tag changes may have failed]" ++ 'face font-lock-warning-face))))))))) + + (defun notmuch-show-filter-thread (query) + "Filter or LIMIT the current thread based on a new query string. +-- +2.1.4 + -- 2.26.2