Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / d1 / 4ec11daf3e5a9dffabbc0c8010521f0953d5d2
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 8C1506DE01C2\r
6  for <notmuch@notmuchmail.org>; Fri, 10 Jun 2016 03:19:40 -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.333\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.333 tagged_above=-999 required=5 tests=[AWL=0.237,\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 Ha_Re1YI5MYy for <notmuch@notmuchmail.org>;\r
19  Fri, 10 Jun 2016 03:19:32 -0700 (PDT)\r
20 Received: from mail-wm0-f49.google.com (mail-wm0-f49.google.com\r
21  [74.125.82.49]) by arlo.cworth.org (Postfix) with ESMTPS id E7E796DE01BE for\r
22  <notmuch@notmuchmail.org>; Fri, 10 Jun 2016 03:19:31 -0700 (PDT)\r
23 Received: by mail-wm0-f49.google.com with SMTP id m124so95502339wme.1\r
24  for <notmuch@notmuchmail.org>; Fri, 10 Jun 2016 03:19:31 -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=vGXClV32KG4C7UpV0fFeD/dKC3WXQskX9cyfIHr29Bw=;\r
28  b=I1WrOZ1ZjZzpkt3ldEU2XXX6rr00FNfw50aEkecPAdoi+6FUXRWy98gM0Xf6rdzkuL\r
29  3sIVznFWsmm9uCoc6ggu6DI66F1HfM/Lr2buznZkaVWq/ZOcDhV2wxITmCrLYbrKyBAq\r
30  eAXaeVVC/dXs4qYgOCC41Qiy6/FZmYkkVj5fkuMJcrTuuIPWPuFk2htN4h7XIafX3h1f\r
31  seZAWnZlqJezdmDvzNhf4p6mhRTJ6b9QuMbBSP5SImvkrkBrLyrEhDs4VLdj47PZZMzC\r
32  FwGeSrdBGm+CAvcjjUgGdCseixJg0ROjPE0O4osXzXW6RIU6h3cGST0KMJ2vq52gZaGK\r
33  fv4g==\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=vGXClV32KG4C7UpV0fFeD/dKC3WXQskX9cyfIHr29Bw=;\r
39  b=kdu4b2B1dfaDLQuoirgGGsN4rLndcGJz5UD0Lc+dyCbjHH1IhH2/tG3rKqKxkZszLw\r
40  320XEQE0dCsTt6CW2XkgY+9iWuzDqyZodsDWE9+HS6XdPRZ2tnBjGZTpkcFRsG+2rAyG\r
41  VbialwKjo3Z/WKQFLKDSVLPyLKyNI1QEwsgyAIzh5+vRV3kefcqhkEZa4u48b5UVn3Ed\r
42  AcaqnB/JCmtxS79Kq9gG7tCb8PvQRue3yIC2o+8aFHR2td8Cu15/bZkRdMV1LiZq7JTs\r
43  xUHnoKKB68Mz+5LStrhtnmO/kdf73+OM105eYGs04pUdjQOZN4LMcP6azkFPbOF9Dhw9\r
44  XOxg==\r
45 X-Gm-Message-State:\r
46  ALyK8tI2jXX82n+pRfq4mSVc8QkCZzsdicly2Zmn+lX8b3I7Skc/bQso3lc74opLwbZcMA==\r
47 X-Received: by 10.194.117.3 with SMTP id ka3mr1441179wjb.38.1465553970185;\r
48  Fri, 10 Jun 2016 03:19:30 -0700 (PDT)\r
49 Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162])\r
50  by smtp.gmail.com with ESMTPSA id y6sm34852277wmy.8.2016.06.10.03.19.28\r
51  (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
52  Fri, 10 Jun 2016 03:19:29 -0700 (PDT)\r
53 From: Mark Walters <markwalters1009@gmail.com>\r
54 To: notmuch@notmuchmail.org\r
55 Subject: [PATCH v3] emacs: show: improve handling of mark read tagging errors\r
56 Date: Fri, 10 Jun 2016 11:19:25 +0100\r
57 Message-Id: <1465553965-3260-1-git-send-email-markwalters1009@gmail.com>\r
58 X-Mailer: git-send-email 2.1.4\r
59 In-Reply-To: <1465466050-27220-1-git-send-email-markwalters1009@gmail.com>\r
60 References: <1465466050-27220-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: Fri, 10 Jun 2016 10:19:40 -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 and by a message in the echo area.\r
98 ---\r
99 \r
100 Hi\r
101 \r
102 The best level of user notification in case of an error is\r
103 unclear. The best we came up with on irc is this one:\r
104 \r
105 On first error, the headerline is changed to say (in warning face)\r
106 that some mark read tag changes may have failed.\r
107 \r
108 On each error, which will occur on each call to\r
109 notmuch-show-command-hook (so roughly after each keypress) we write\r
110 the error to the error buffer and we send a message to the echo area.\r
111 \r
112 In principle I would like to send a single message to the echo area\r
113 and have it persist for a few seconds. However, the echo area is\r
114 cleared after each keypress so this seems difficult. Moreover, this\r
115 clearing means if we send the message a single time and the user\r
116 enters the message with repeated cursor-downs then the message will\r
117 disappear as soon as it is displayed.\r
118 \r
119 In the future we might want to modify the error code to be something like the\r
120 message buffer and say "last error repeated x times", but that can\r
121 come later.\r
122 \r
123 Best wishes\r
124 \r
125 Mark\r
126 \r
127 \r
128  emacs/notmuch-show.el | 17 ++++++++++++++++-\r
129  1 file changed, 16 insertions(+), 1 deletion(-)\r
130 \r
131 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
132 index fea39fa..406f418 100644\r
133 --- a/emacs/notmuch-show.el\r
134 +++ b/emacs/notmuch-show.el\r
135 @@ -1701,12 +1701,27 @@ user decision and we should not override it."\r
136         (notmuch-show-mark-read)\r
137         (notmuch-show-set-prop :seen t)))\r
138  \r
139 +(defvar notmuch-show--seen-has-errored nil)\r
140 +(make-variable-buffer-local 'notmuch-show--seen-has-errored)\r
141 +\r
142  (defun notmuch-show-command-hook ()\r
143    (when (eq major-mode 'notmuch-show-mode)\r
144      ;; We need to redisplay to get window-start and window-end correct.\r
145      (redisplay)\r
146      (save-excursion\r
147 -      (funcall notmuch-show-mark-read-function (window-start) (window-end)))))\r
148 +      (condition-case nil\r
149 +         (funcall notmuch-show-mark-read-function (window-start) (window-end))\r
150 +       ((debug error)\r
151 +        ;; The call chain from notmuch-show-mark-read-function writes\r
152 +        ;; and error to the error buffer before calling the error, so\r
153 +        ;; we do not need to do that here. Just tell the user.\r
154 +        (message "Warning -- marking message read failed.")\r
155 +        (unless notmuch-show--seen-has-errored\r
156 +          (setq notmuch-show--seen-has-errored 't)\r
157 +          (setq header-line-format\r
158 +                (concat header-line-format\r
159 +                        (propertize "  [some mark read tag changes may have failed]"\r
160 +                                    'face font-lock-warning-face)))))))))\r
161  \r
162  (defun notmuch-show-filter-thread (query)\r
163    "Filter or LIMIT the current thread based on a new query string.\r
164 -- \r
165 2.1.4\r
166 \r