[PATCH] emacs: show: improve handling of mark read tagging errors
[notmuch-archives.git] / 12 / 6798a70ae2d03e7dfb1870e21c2630687c3d86
1 Return-Path: <markwalters1009@gmail.com>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5  by arlo.cworth.org (Postfix) with ESMTP id F14BC6DE0281\r
6  for <notmuch@notmuchmail.org>; Thu,  9 Jun 2016 02:54:24 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.331\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.331 tagged_above=-999 required=5 tests=[AWL=0.239,\r
12   DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13  FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7,\r
14  RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001]\r
15  autolearn=disabled\r
16 Received: from arlo.cworth.org ([127.0.0.1])\r
17  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
18  with ESMTP id jSMCgc5Tf3b9 for <notmuch@notmuchmail.org>;\r
19  Thu,  9 Jun 2016 02:54:17 -0700 (PDT)\r
20 Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com\r
21  [74.125.82.65]) by arlo.cworth.org (Postfix) with ESMTPS id CF3E46DE01C2 for\r
22  <notmuch@notmuchmail.org>; Thu,  9 Jun 2016 02:54:16 -0700 (PDT)\r
23 Received: by mail-wm0-f65.google.com with SMTP id m124so9222217wme.3\r
24  for <notmuch@notmuchmail.org>; Thu, 09 Jun 2016 02:54:16 -0700 (PDT)\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
26  h=from:to:cc:subject:date:message-id:in-reply-to:references;\r
27  bh=QOd+Z7/1DUGy5QN/DHU0wgwsSc0S/LyfFRfYP8Or1Gg=;\r
28  b=OwMs86qtNkTIy7VQtB/x4IM3INKcRCVF+jrqxCsU7LHCP26MYLvzouQVGIBkcWZOVI\r
29  ZDJ8cJLIcRkBtfUk/0oAORDK2P5Q5nDn6OPZ8KkVB4cjEUzdvcJBtmyM2kDi6Z77+8P6\r
30  PoGLqHFlLzCDlC19ELGQ9CeuzXHM/sybqyQhgvnl08bw1mdtcBe6QJ59Q40KmCoEv2BP\r
31  pC8TPHdc4XKsx9B4HVpJ4lnm3qsw3Xfseup8AE7FAu/RIGUrEtsvmAvP21gW+Ri+k4KM\r
32  8O8jeVa0GqSE+HSBmLO/qG8r48uoOQrx1/sOti77FtlzlDJ99gOqUefZTCIZSJJZcn6G\r
33  qolQ==\r
34 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
35  d=1e100.net; s=20130820;\r
36  h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\r
37  :references;\r
38  bh=QOd+Z7/1DUGy5QN/DHU0wgwsSc0S/LyfFRfYP8Or1Gg=;\r
39  b=gPO37mrYLKQ+NzqFiHQRFljsAj44ZjRYBlph71j1DDMvPQmicoz7UefyPKHZsYXLTB\r
40  +5XPieCEtCOVfVC3qIJfafjA7sKrozN8fVvti3fHxexhd2LDbv1/KbGTpaGWmI2XrNAA\r
41  ki/tahpkOhg8abgSB71TyCXNWpppw0Mcbv7jg2VT3vhngATCx6PgwOkVP9iI3b3S6Mdn\r
42  RriXquFQpMFSJwT73doLDZj2BCSMnSktwX0C8+MNJZBEe9Hro95gU31wtm1A7cDx1mOy\r
43  hATND6B1Va/Sv5VwXm4BUi14aMS5vZSGfT1Bb7V21SWgHYpt7wcgybW6e6hi/BeF3FOW\r
44  qSEg==\r
45 X-Gm-Message-State:\r
46  ALyK8tIHxDc+G56NGC0pm8g5HQz7sCEon56Q8A/OEpCiOZeX2QXU6RKEl0ZuLCsUSMh3SA==\r
47 X-Received: by 10.28.197.132 with SMTP id v126mr1989870wmf.8.1465466054929;\r
48  Thu, 09 Jun 2016 02:54:14 -0700 (PDT)\r
49 Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162])\r
50  by smtp.gmail.com with ESMTPSA id k127sm6707348wmf.21.2016.06.09.02.54.13\r
51  (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
52  Thu, 09 Jun 2016 02:54:13 -0700 (PDT)\r
53 From: Mark Walters <markwalters1009@gmail.com>\r
54 To: notmuch@notmuchmail.org\r
55 Subject: [PATCH] emacs: show: improve handling of mark read tagging errors\r
56 Date: Thu,  9 Jun 2016 10:54:10 +0100\r
57 Message-Id: <1465466050-27220-1-git-send-email-markwalters1009@gmail.com>\r
58 X-Mailer: git-send-email 2.1.4\r
59 In-Reply-To: <1465336292-18704-1-git-send-email-markwalters1009@gmail.com>\r
60 References: <1465336292-18704-1-git-send-email-markwalters1009@gmail.com>\r
61 X-BeenThere: notmuch@notmuchmail.org\r
62 X-Mailman-Version: 2.1.20\r
63 Precedence: list\r
64 List-Id: "Use and development of the notmuch mail system."\r
65  <notmuch.notmuchmail.org>\r
66 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
67  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
68 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
69 List-Post: <mailto:notmuch@notmuchmail.org>\r
70 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
71 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
72  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
73 X-List-Received-Date: Thu, 09 Jun 2016 09:54:25 -0000\r
74 \r
75 Previously if a marking read tag change (i.e., removing the unread\r
76 tag) failed for some reason, such as a locked database, then no more\r
77 mark read tag changes would be attempted in that buffer.\r
78 \r
79 This handles the error more gracefully. There is not much we can do\r
80 yet about dealing with the error itself, and marking read is probably\r
81 not important enough to warrant keeping a queue of pending changes or\r
82 anything.\r
83 \r
84 However this commit changes it so that\r
85 \r
86 - we do try and make future mark read tag changes.\r
87 \r
88 - we display the tag state correctly: i.e. we don't display the tag as\r
89   deleted (no strike through)\r
90 \r
91 - and since we know the tag change failed we can try to mark this\r
92   message read in the future. Indeed, since the code uses the\r
93   post-command hook we will try again on the next keypress (unless the\r
94   user has left the message).\r
95 \r
96 We indicate to the user that these mark read tag changes may have\r
97 failed in the header-line.\r
98 ---\r
99 \r
100 This is a slightly changed version of the previous patch, based on\r
101 some comments and a patch Tomi had on irc.\r
102 \r
103 The changes are:\r
104 \r
105 - we allow the debugger to run if debug-on-error is set\r
106 \r
107 - the condition-case now protects any customised mark-read function\r
108 \r
109 - the fact that a tagging error may have occured is displayed in the headerline\r
110 \r
111 Best wishes\r
112 \r
113 Mark\r
114 \r
115 \r
116 \r
117 \r
118 \r
119 emacs/notmuch-show.el | 13 ++++++++++++-\r
120  1 file changed, 12 insertions(+), 1 deletion(-)\r
121 \r
122 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
123 index fea39fa..6d3149b 100644\r
124 --- a/emacs/notmuch-show.el\r
125 +++ b/emacs/notmuch-show.el\r
126 @@ -1701,12 +1701,23 @@ user decision and we should not override it."\r
127         (notmuch-show-mark-read)\r
128         (notmuch-show-set-prop :seen t)))\r
129  \r
130 +(defvar notmuch-show--seen-has-errored nil)\r
131 +(make-variable-buffer-local 'notmuch-show--seen-has-errored)\r
132 +\r
133  (defun notmuch-show-command-hook ()\r
134    (when (eq major-mode 'notmuch-show-mode)\r
135      ;; We need to redisplay to get window-start and window-end correct.\r
136      (redisplay)\r
137      (save-excursion\r
138 -      (funcall notmuch-show-mark-read-function (window-start) (window-end)))))\r
139 +      (condition-case err\r
140 +         (funcall notmuch-show-mark-read-function (window-start) (window-end))\r
141 +       ((debug error)\r
142 +        (unless notmuch-show--seen-has-errored\r
143 +          (setq notmuch-show--seen-has-errored 't)\r
144 +          (setq header-line-format\r
145 +                (concat header-line-format\r
146 +                        (propertize "  [some mark read tag changes may have failed]"\r
147 +                                    'face font-lock-warning-face)))))))))\r
148  \r
149  (defun notmuch-show-filter-thread (query)\r
150    "Filter or LIMIT the current thread based on a new query string.\r
151 -- \r
152 2.1.4\r
153 \r