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