--- /dev/null
+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 arlo.cworth.org (Postfix) with ESMTP id 8C1506DE01C2\r
+ for <notmuch@notmuchmail.org>; Fri, 10 Jun 2016 03:19:40 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.333\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.333 tagged_above=-999 required=5 tests=[AWL=0.237,\r
+ DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+ FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7,\r
+ RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001]\r
+ autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id Ha_Re1YI5MYy for <notmuch@notmuchmail.org>;\r
+ Fri, 10 Jun 2016 03:19:32 -0700 (PDT)\r
+Received: from mail-wm0-f49.google.com (mail-wm0-f49.google.com\r
+ [74.125.82.49]) by arlo.cworth.org (Postfix) with ESMTPS id E7E796DE01BE for\r
+ <notmuch@notmuchmail.org>; Fri, 10 Jun 2016 03:19:31 -0700 (PDT)\r
+Received: by mail-wm0-f49.google.com with SMTP id m124so95502339wme.1\r
+ for <notmuch@notmuchmail.org>; Fri, 10 Jun 2016 03:19:31 -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:in-reply-to:references;\r
+ bh=vGXClV32KG4C7UpV0fFeD/dKC3WXQskX9cyfIHr29Bw=;\r
+ b=I1WrOZ1ZjZzpkt3ldEU2XXX6rr00FNfw50aEkecPAdoi+6FUXRWy98gM0Xf6rdzkuL\r
+ 3sIVznFWsmm9uCoc6ggu6DI66F1HfM/Lr2buznZkaVWq/ZOcDhV2wxITmCrLYbrKyBAq\r
+ eAXaeVVC/dXs4qYgOCC41Qiy6/FZmYkkVj5fkuMJcrTuuIPWPuFk2htN4h7XIafX3h1f\r
+ seZAWnZlqJezdmDvzNhf4p6mhRTJ6b9QuMbBSP5SImvkrkBrLyrEhDs4VLdj47PZZMzC\r
+ FwGeSrdBGm+CAvcjjUgGdCseixJg0ROjPE0O4osXzXW6RIU6h3cGST0KMJ2vq52gZaGK\r
+ fv4g==\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=1e100.net; s=20130820;\r
+ h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\r
+ :references;\r
+ bh=vGXClV32KG4C7UpV0fFeD/dKC3WXQskX9cyfIHr29Bw=;\r
+ b=kdu4b2B1dfaDLQuoirgGGsN4rLndcGJz5UD0Lc+dyCbjHH1IhH2/tG3rKqKxkZszLw\r
+ 320XEQE0dCsTt6CW2XkgY+9iWuzDqyZodsDWE9+HS6XdPRZ2tnBjGZTpkcFRsG+2rAyG\r
+ VbialwKjo3Z/WKQFLKDSVLPyLKyNI1QEwsgyAIzh5+vRV3kefcqhkEZa4u48b5UVn3Ed\r
+ AcaqnB/JCmtxS79Kq9gG7tCb8PvQRue3yIC2o+8aFHR2td8Cu15/bZkRdMV1LiZq7JTs\r
+ xUHnoKKB68Mz+5LStrhtnmO/kdf73+OM105eYGs04pUdjQOZN4LMcP6azkFPbOF9Dhw9\r
+ XOxg==\r
+X-Gm-Message-State:\r
+ ALyK8tI2jXX82n+pRfq4mSVc8QkCZzsdicly2Zmn+lX8b3I7Skc/bQso3lc74opLwbZcMA==\r
+X-Received: by 10.194.117.3 with SMTP id ka3mr1441179wjb.38.1465553970185;\r
+ Fri, 10 Jun 2016 03:19:30 -0700 (PDT)\r
+Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162])\r
+ by smtp.gmail.com with ESMTPSA id y6sm34852277wmy.8.2016.06.10.03.19.28\r
+ (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
+ Fri, 10 Jun 2016 03:19:29 -0700 (PDT)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v3] emacs: show: improve handling of mark read tagging errors\r
+Date: Fri, 10 Jun 2016 11:19:25 +0100\r
+Message-Id: <1465553965-3260-1-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 2.1.4\r
+In-Reply-To: <1465466050-27220-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1465466050-27220-1-git-send-email-markwalters1009@gmail.com>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.20\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <https://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: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Fri, 10 Jun 2016 10:19:40 -0000\r
+\r
+Previously if a marking read tag change (i.e., removing the unread\r
+tag) failed for some reason, such as a locked database, then no more\r
+mark read tag changes would be attempted in that buffer.\r
+\r
+This handles the error more gracefully. There is not much we can do\r
+yet about dealing with the error itself, and marking read is probably\r
+not important enough to warrant keeping a queue of pending changes or\r
+anything.\r
+\r
+However this commit changes it so that\r
+\r
+- we do try and make future mark read tag changes.\r
+\r
+- we display the tag state correctly: i.e. we don't display the tag as\r
+ deleted (no strike through)\r
+\r
+- and since we know the tag change failed we can try to mark this\r
+ message read in the future. Indeed, since the code uses the\r
+ post-command hook we will try again on the next keypress (unless the\r
+ user has left the message).\r
+\r
+We indicate to the user that these mark read tag changes may have\r
+failed in the header-line and by a message in the echo area.\r
+---\r
+\r
+Hi\r
+\r
+The best level of user notification in case of an error is\r
+unclear. The best we came up with on irc is this one:\r
+\r
+On first error, the headerline is changed to say (in warning face)\r
+that some mark read tag changes may have failed.\r
+\r
+On each error, which will occur on each call to\r
+notmuch-show-command-hook (so roughly after each keypress) we write\r
+the error to the error buffer and we send a message to the echo area.\r
+\r
+In principle I would like to send a single message to the echo area\r
+and have it persist for a few seconds. However, the echo area is\r
+cleared after each keypress so this seems difficult. Moreover, this\r
+clearing means if we send the message a single time and the user\r
+enters the message with repeated cursor-downs then the message will\r
+disappear as soon as it is displayed.\r
+\r
+In the future we might want to modify the error code to be something like the\r
+message buffer and say "last error repeated x times", but that can\r
+come later.\r
+\r
+Best wishes\r
+\r
+Mark\r
+\r
+\r
+ emacs/notmuch-show.el | 17 ++++++++++++++++-\r
+ 1 file changed, 16 insertions(+), 1 deletion(-)\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index fea39fa..406f418 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -1701,12 +1701,27 @@ user decision and we should not override it."\r
+ (notmuch-show-mark-read)\r
+ (notmuch-show-set-prop :seen t)))\r
+ \r
++(defvar notmuch-show--seen-has-errored nil)\r
++(make-variable-buffer-local 'notmuch-show--seen-has-errored)\r
++\r
+ (defun notmuch-show-command-hook ()\r
+ (when (eq major-mode 'notmuch-show-mode)\r
+ ;; We need to redisplay to get window-start and window-end correct.\r
+ (redisplay)\r
+ (save-excursion\r
+- (funcall notmuch-show-mark-read-function (window-start) (window-end)))))\r
++ (condition-case nil\r
++ (funcall notmuch-show-mark-read-function (window-start) (window-end))\r
++ ((debug error)\r
++ ;; The call chain from notmuch-show-mark-read-function writes\r
++ ;; and error to the error buffer before calling the error, so\r
++ ;; we do not need to do that here. Just tell the user.\r
++ (message "Warning -- marking message read failed.")\r
++ (unless notmuch-show--seen-has-errored\r
++ (setq notmuch-show--seen-has-errored 't)\r
++ (setq header-line-format\r
++ (concat header-line-format\r
++ (propertize " [some mark read tag changes may have failed]"\r
++ 'face font-lock-warning-face)))))))))\r
+ \r
+ (defun notmuch-show-filter-thread (query)\r
+ "Filter or LIMIT the current thread based on a new query string.\r
+-- \r
+2.1.4\r
+\r