[PATCH] emacs: show: improve handling of mark read tagging errors
authorMark Walters <markwalters1009@gmail.com>
Thu, 9 Jun 2016 09:54:10 +0000 (10:54 +0100)
committerW. Trevor King <wking@tremily.us>
Sat, 20 Aug 2016 23:22:01 +0000 (16:22 -0700)
12/6798a70ae2d03e7dfb1870e21c2630687c3d86 [new file with mode: 0644]

diff --git a/12/6798a70ae2d03e7dfb1870e21c2630687c3d86 b/12/6798a70ae2d03e7dfb1870e21c2630687c3d86
new file mode 100644 (file)
index 0000000..e4cfd25
--- /dev/null
@@ -0,0 +1,153 @@
+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 F14BC6DE0281\r
+ for <notmuch@notmuchmail.org>; Thu,  9 Jun 2016 02:54:24 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.331\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.331 tagged_above=-999 required=5 tests=[AWL=0.239,\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 jSMCgc5Tf3b9 for <notmuch@notmuchmail.org>;\r
+ Thu,  9 Jun 2016 02:54:17 -0700 (PDT)\r
+Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com\r
+ [74.125.82.65]) by arlo.cworth.org (Postfix) with ESMTPS id CF3E46DE01C2 for\r
+ <notmuch@notmuchmail.org>; Thu,  9 Jun 2016 02:54:16 -0700 (PDT)\r
+Received: by mail-wm0-f65.google.com with SMTP id m124so9222217wme.3\r
+ for <notmuch@notmuchmail.org>; Thu, 09 Jun 2016 02:54:16 -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=QOd+Z7/1DUGy5QN/DHU0wgwsSc0S/LyfFRfYP8Or1Gg=;\r
+ b=OwMs86qtNkTIy7VQtB/x4IM3INKcRCVF+jrqxCsU7LHCP26MYLvzouQVGIBkcWZOVI\r
+ ZDJ8cJLIcRkBtfUk/0oAORDK2P5Q5nDn6OPZ8KkVB4cjEUzdvcJBtmyM2kDi6Z77+8P6\r
+ PoGLqHFlLzCDlC19ELGQ9CeuzXHM/sybqyQhgvnl08bw1mdtcBe6QJ59Q40KmCoEv2BP\r
+ pC8TPHdc4XKsx9B4HVpJ4lnm3qsw3Xfseup8AE7FAu/RIGUrEtsvmAvP21gW+Ri+k4KM\r
+ 8O8jeVa0GqSE+HSBmLO/qG8r48uoOQrx1/sOti77FtlzlDJ99gOqUefZTCIZSJJZcn6G\r
+ qolQ==\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=QOd+Z7/1DUGy5QN/DHU0wgwsSc0S/LyfFRfYP8Or1Gg=;\r
+ b=gPO37mrYLKQ+NzqFiHQRFljsAj44ZjRYBlph71j1DDMvPQmicoz7UefyPKHZsYXLTB\r
+ +5XPieCEtCOVfVC3qIJfafjA7sKrozN8fVvti3fHxexhd2LDbv1/KbGTpaGWmI2XrNAA\r
+ ki/tahpkOhg8abgSB71TyCXNWpppw0Mcbv7jg2VT3vhngATCx6PgwOkVP9iI3b3S6Mdn\r
+ RriXquFQpMFSJwT73doLDZj2BCSMnSktwX0C8+MNJZBEe9Hro95gU31wtm1A7cDx1mOy\r
+ hATND6B1Va/Sv5VwXm4BUi14aMS5vZSGfT1Bb7V21SWgHYpt7wcgybW6e6hi/BeF3FOW\r
+ qSEg==\r
+X-Gm-Message-State:\r
+ ALyK8tIHxDc+G56NGC0pm8g5HQz7sCEon56Q8A/OEpCiOZeX2QXU6RKEl0ZuLCsUSMh3SA==\r
+X-Received: by 10.28.197.132 with SMTP id v126mr1989870wmf.8.1465466054929;\r
+ Thu, 09 Jun 2016 02:54:14 -0700 (PDT)\r
+Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162])\r
+ by smtp.gmail.com with ESMTPSA id k127sm6707348wmf.21.2016.06.09.02.54.13\r
+ (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
+ Thu, 09 Jun 2016 02:54:13 -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: Thu,  9 Jun 2016 10:54:10 +0100\r
+Message-Id: <1465466050-27220-1-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 2.1.4\r
+In-Reply-To: <1465336292-18704-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1465336292-18704-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: Thu, 09 Jun 2016 09:54:25 -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.\r
+---\r
+\r
+This is a slightly changed version of the previous patch, based on\r
+some comments and a patch Tomi had on irc.\r
+\r
+The changes are:\r
+\r
+- we allow the debugger to run if debug-on-error is set\r
+\r
+- the condition-case now protects any customised mark-read function\r
+\r
+- the fact that a tagging error may have occured is displayed in the headerline\r
+\r
+Best wishes\r
+\r
+Mark\r
+\r
+\r
+\r
+\r
+\r
+emacs/notmuch-show.el | 13 ++++++++++++-\r
+ 1 file changed, 12 insertions(+), 1 deletion(-)\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index fea39fa..6d3149b 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -1701,12 +1701,23 @@ 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 err\r
++        (funcall notmuch-show-mark-read-function (window-start) (window-end))\r
++      ((debug error)\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