[PATCH] emacs: show: improve handling of mark read tagging errors

Mark Walters markwalters1009 at gmail.com
Thu Jun 9 02:54:10 PDT 2016


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



More information about the notmuch mailing list