--- /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 592856DE00D3\r
+ for <notmuch@notmuchmail.org>; Tue, 7 Jun 2016 14:51:47 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.33\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.33 tagged_above=-999 required=5 tests=[AWL=0.240, \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,\r
+ RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01,\r
+ RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] 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 gvEVqlcvyARE for <notmuch@notmuchmail.org>;\r
+ Tue, 7 Jun 2016 14:51:39 -0700 (PDT)\r
+Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com\r
+ [74.125.82.68]) by arlo.cworth.org (Postfix) with ESMTPS id 009986DE00BF for\r
+ <notmuch@notmuchmail.org>; Tue, 7 Jun 2016 14:51:38 -0700 (PDT)\r
+Received: by mail-wm0-f68.google.com with SMTP id r5so9241245wmr.0\r
+ for <notmuch@notmuchmail.org>; Tue, 07 Jun 2016 14:51:38 -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;\r
+ bh=apF6aJ/v5aBPRP8Z4tD2Ty75VeylDvre0GANJCBaUXo=;\r
+ b=sUOF0boM2/Fc4FnhA31ICYX7PUxE3QD50s9ZirExHRRkZdtXgPLTRlPbrnUhfRJcv+\r
+ tlcOKvwQTqabFqgM1OFF9yqnG+aIdaoznHMi+tfwndfMZ65yV7oDp6gkBRq7mnkMNCNo\r
+ O4BvDw/zK1+qXsAFMtUaCc+W63Y93co7X9sO4o7D4kl5x+zPG3JyVsQLZ16zaP1kJtn7\r
+ IH65uZ0K40yiqVxakL8YVMHZE0+P+krPbY/DFb/uCB19ni/kDgMXWzEYYOGwBKZveZow\r
+ NjYmYM+jkUaJilZhT4DeFPvKKMmCmmkQO9/tJ7OPPzMUeVV44fnd5i5t+VgyrmrhSlss\r
+ WEUA==\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;\r
+ bh=apF6aJ/v5aBPRP8Z4tD2Ty75VeylDvre0GANJCBaUXo=;\r
+ b=KcezXVtu+bR9EC+0eH1OaVkf2hktRBDoKjrzHwufayn4dcZIG3XNvvMrx/rMtqg4yG\r
+ zWtesrafHDWUbne9btivuKBRGiqwGcXOcmB/4t5OmiU7N3IMaKPK6NyrWhJIToSiwnSh\r
+ 1mOwQmCxuUCXMyUyiQ8WLaSd0APV9VZOHBs+qb85zc/JdX7PDZWGhj5sNWR76u9jTNUj\r
+ 3FMgIbO8PC5o1oaFS7NYAknEwMz9atRZPr/SLaLYHsbuReEsVKV8RpH0ELzDJGXt8ZuL\r
+ gycJP+qTSuE7bOYxtu2+8X41bfFGy3MY8swW23csmT4qhC5kaUlg26AgZm+2zCj8VCkK\r
+ THZQ==\r
+X-Gm-Message-State:\r
+ ALyK8tIWwr2zJS4GenOjbkqDI7oE7dyr8rVOj35GBBPk6SCn7iOY4WciGwXEPqGbMzclhw==\r
+X-Received: by 10.194.122.234 with SMTP id lv10mr1420754wjb.40.1465336297000; \r
+ Tue, 07 Jun 2016 14:51:37 -0700 (PDT)\r
+Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162])\r
+ by smtp.gmail.com with ESMTPSA id r3sm21382401wme.24.2016.06.07.14.51.36\r
+ (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
+ Tue, 07 Jun 2016 14:51:36 -0700 (PDT)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] emacs: show: improve handling of mark read tagging errors\r
+Date: Tue, 7 Jun 2016 22:51:32 +0100\r
+Message-Id: <1465336292-18704-1-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 2.1.4\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: Tue, 07 Jun 2016 21:51:47 -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
+Since we could have many failed attempts at tagging, we just show a\r
+message once per buffer.\r
+---\r
+\r
+This came up on irc today. The only real question is where to catch\r
+the error. I think manual tag changes should give an actual error, so\r
+we only want to catch errors from automatic tag-changes. By far the\r
+most common of these is the mark read change, so just catch errors for\r
+that.\r
+\r
+Best wishes\r
+\r
+Mark\r
+\r
+\r
+emacs/notmuch-show.el | 13 +++++++++++--\r
+ 1 file changed, 11 insertions(+), 2 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index fea39fa..1753cac 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -1691,6 +1691,9 @@ marked as unread, i.e. the tag changes in\r
+ (apply 'notmuch-show-tag-message\r
+ (notmuch-tag-change-list notmuch-show-mark-read-tags unread))))\r
+ \r
++(defvar notmuch-show--seen-has-errored nil)\r
++(make-variable-buffer-local 'notmuch-show--seen-has-errored)\r
++\r
+ (defun notmuch-show-seen-current-message (start end)\r
+ "Mark the current message read if it is open.\r
+ \r
+@@ -1698,8 +1701,14 @@ We only mark it read once: if it is changed back then that is a\r
+ user decision and we should not override it."\r
+ (when (and (notmuch-show-message-visible-p)\r
+ (not (notmuch-show-get-prop :seen)))\r
+- (notmuch-show-mark-read)\r
+- (notmuch-show-set-prop :seen t)))\r
++ (condition-case err\r
++ (progn\r
++ (notmuch-show-mark-read)\r
++ (notmuch-show-set-prop :seen t))\r
++ (error\r
++ (unless notmuch-show--seen-has-errored\r
++ (setq notmuch-show--seen-has-errored 't)\r
++ (message "Warning: marking message read failed"))))))\r
+ \r
+ (defun notmuch-show-command-hook ()\r
+ (when (eq major-mode 'notmuch-show-mode)\r
+-- \r
+2.1.4\r
+\r