From 1c0fcd3fe4a653fe7d8fdfa84866fbf15cc8fbff Mon Sep 17 00:00:00 2001 From: Mark Walters Date: Fri, 10 Jun 2016 11:19:25 +0100 Subject: [PATCH] [PATCH v3] emacs: show: improve handling of mark read tagging errors --- d1/4ec11daf3e5a9dffabbc0c8010521f0953d5d2 | 166 ++++++++++++++++++++++ 1 file changed, 166 insertions(+) create mode 100644 d1/4ec11daf3e5a9dffabbc0c8010521f0953d5d2 diff --git a/d1/4ec11daf3e5a9dffabbc0c8010521f0953d5d2 b/d1/4ec11daf3e5a9dffabbc0c8010521f0953d5d2 new file mode 100644 index 000000000..5c47201b1 --- /dev/null +++ b/d1/4ec11daf3e5a9dffabbc0c8010521f0953d5d2 @@ -0,0 +1,166 @@ +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 8C1506DE01C2 + for ; Fri, 10 Jun 2016 03:19:40 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: -0.333 +X-Spam-Level: +X-Spam-Status: No, score=-0.333 tagged_above=-999 required=5 tests=[AWL=0.237, + 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 Ha_Re1YI5MYy for ; + Fri, 10 Jun 2016 03:19:32 -0700 (PDT) +Received: from mail-wm0-f49.google.com (mail-wm0-f49.google.com + [74.125.82.49]) by arlo.cworth.org (Postfix) with ESMTPS id E7E796DE01BE for + ; Fri, 10 Jun 2016 03:19:31 -0700 (PDT) +Received: by mail-wm0-f49.google.com with SMTP id m124so95502339wme.1 + for ; Fri, 10 Jun 2016 03:19:31 -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=vGXClV32KG4C7UpV0fFeD/dKC3WXQskX9cyfIHr29Bw=; + b=I1WrOZ1ZjZzpkt3ldEU2XXX6rr00FNfw50aEkecPAdoi+6FUXRWy98gM0Xf6rdzkuL + 3sIVznFWsmm9uCoc6ggu6DI66F1HfM/Lr2buznZkaVWq/ZOcDhV2wxITmCrLYbrKyBAq + eAXaeVVC/dXs4qYgOCC41Qiy6/FZmYkkVj5fkuMJcrTuuIPWPuFk2htN4h7XIafX3h1f + seZAWnZlqJezdmDvzNhf4p6mhRTJ6b9QuMbBSP5SImvkrkBrLyrEhDs4VLdj47PZZMzC + FwGeSrdBGm+CAvcjjUgGdCseixJg0ROjPE0O4osXzXW6RIU6h3cGST0KMJ2vq52gZaGK + fv4g== +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=vGXClV32KG4C7UpV0fFeD/dKC3WXQskX9cyfIHr29Bw=; + b=kdu4b2B1dfaDLQuoirgGGsN4rLndcGJz5UD0Lc+dyCbjHH1IhH2/tG3rKqKxkZszLw + 320XEQE0dCsTt6CW2XkgY+9iWuzDqyZodsDWE9+HS6XdPRZ2tnBjGZTpkcFRsG+2rAyG + VbialwKjo3Z/WKQFLKDSVLPyLKyNI1QEwsgyAIzh5+vRV3kefcqhkEZa4u48b5UVn3Ed + AcaqnB/JCmtxS79Kq9gG7tCb8PvQRue3yIC2o+8aFHR2td8Cu15/bZkRdMV1LiZq7JTs + xUHnoKKB68Mz+5LStrhtnmO/kdf73+OM105eYGs04pUdjQOZN4LMcP6azkFPbOF9Dhw9 + XOxg== +X-Gm-Message-State: + ALyK8tI2jXX82n+pRfq4mSVc8QkCZzsdicly2Zmn+lX8b3I7Skc/bQso3lc74opLwbZcMA== +X-Received: by 10.194.117.3 with SMTP id ka3mr1441179wjb.38.1465553970185; + Fri, 10 Jun 2016 03:19:30 -0700 (PDT) +Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162]) + by smtp.gmail.com with ESMTPSA id y6sm34852277wmy.8.2016.06.10.03.19.28 + (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); + Fri, 10 Jun 2016 03:19:29 -0700 (PDT) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [PATCH v3] emacs: show: improve handling of mark read tagging errors +Date: Fri, 10 Jun 2016 11:19:25 +0100 +Message-Id: <1465553965-3260-1-git-send-email-markwalters1009@gmail.com> +X-Mailer: git-send-email 2.1.4 +In-Reply-To: <1465466050-27220-1-git-send-email-markwalters1009@gmail.com> +References: <1465466050-27220-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: Fri, 10 Jun 2016 10:19:40 -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 and by a message in the echo area. +--- + +Hi + +The best level of user notification in case of an error is +unclear. The best we came up with on irc is this one: + +On first error, the headerline is changed to say (in warning face) +that some mark read tag changes may have failed. + +On each error, which will occur on each call to +notmuch-show-command-hook (so roughly after each keypress) we write +the error to the error buffer and we send a message to the echo area. + +In principle I would like to send a single message to the echo area +and have it persist for a few seconds. However, the echo area is +cleared after each keypress so this seems difficult. Moreover, this +clearing means if we send the message a single time and the user +enters the message with repeated cursor-downs then the message will +disappear as soon as it is displayed. + +In the future we might want to modify the error code to be something like the +message buffer and say "last error repeated x times", but that can +come later. + +Best wishes + +Mark + + + emacs/notmuch-show.el | 17 ++++++++++++++++- + 1 file changed, 16 insertions(+), 1 deletion(-) + +diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el +index fea39fa..406f418 100644 +--- a/emacs/notmuch-show.el ++++ b/emacs/notmuch-show.el +@@ -1701,12 +1701,27 @@ 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 nil ++ (funcall notmuch-show-mark-read-function (window-start) (window-end)) ++ ((debug error) ++ ;; The call chain from notmuch-show-mark-read-function writes ++ ;; and error to the error buffer before calling the error, so ++ ;; we do not need to do that here. Just tell the user. ++ (message "Warning -- marking message read failed.") ++ (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