Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / d7 / c0d1e8efd5df85bb92e81756bbd53456a0fb55
1 Return-Path: <tomi.ollila@iki.fi>\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 706096DE028C\r
6  for <notmuch@notmuchmail.org>; Fri, 10 Jun 2016 08:12:00 -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.57\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.57 tagged_above=-999 required=5 tests=[AWL=-0.082, \r
12  SPF_NEUTRAL=0.652] autolearn=disabled\r
13 Received: from arlo.cworth.org ([127.0.0.1])\r
14  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
15  with ESMTP id ZdwZ8WL4suRR for <notmuch@notmuchmail.org>;\r
16  Fri, 10 Jun 2016 08:11:52 -0700 (PDT)\r
17 Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
18  by arlo.cworth.org (Postfix) with ESMTP id AAAEF6DE00DF\r
19  for <notmuch@notmuchmail.org>; Fri, 10 Jun 2016 08:11:51 -0700 (PDT)\r
20 Received: from guru.guru-group.fi (localhost [IPv6:::1])\r
21  by guru.guru-group.fi (Postfix) with ESMTP id C6F09100104;\r
22  Fri, 10 Jun 2016 18:11:37 +0300 (EEST)\r
23 From: Tomi Ollila <tomi.ollila@iki.fi>\r
24 To: Mark Walters <markwalters1009@gmail.com>, notmuch@notmuchmail.org\r
25 Subject: Re: [PATCH v3] emacs: show: improve handling of mark read tagging\r
26  errors\r
27 In-Reply-To: <1465553965-3260-1-git-send-email-markwalters1009@gmail.com>\r
28 References: <1465466050-27220-1-git-send-email-markwalters1009@gmail.com>\r
29  <1465553965-3260-1-git-send-email-markwalters1009@gmail.com>\r
30 User-Agent: Notmuch/0.22+32~gd4854c5 (http://notmuchmail.org) Emacs/24.5.1\r
31  (x86_64-unknown-linux-gnu)\r
32 X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
33  $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
34  !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
35 Date: Fri, 10 Jun 2016 18:11:37 +0300\r
36 Message-ID: <m2y46djcye.fsf@guru.guru-group.fi>\r
37 MIME-Version: 1.0\r
38 Content-Type: text/plain\r
39 X-BeenThere: notmuch@notmuchmail.org\r
40 X-Mailman-Version: 2.1.20\r
41 Precedence: list\r
42 List-Id: "Use and development of the notmuch mail system."\r
43  <notmuch.notmuchmail.org>\r
44 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
45  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
46 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
47 List-Post: <mailto:notmuch@notmuchmail.org>\r
48 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
49 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
50  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
51 X-List-Received-Date: Fri, 10 Jun 2016 15:12:00 -0000\r
52 \r
53 On Fri, Jun 10 2016, Mark Walters <markwalters1009@gmail.com> wrote:\r
54 \r
55 > Previously if a marking read tag change (i.e., removing the unread\r
56 > tag) failed for some reason, such as a locked database, then no more\r
57 > mark read tag changes would be attempted in that buffer.\r
58 >\r
59 > This handles the error more gracefully. There is not much we can do\r
60 > yet about dealing with the error itself, and marking read is probably\r
61 > not important enough to warrant keeping a queue of pending changes or\r
62 > anything.\r
63 >\r
64 > However this commit changes it so that\r
65 >\r
66 > - we do try and make future mark read tag changes.\r
67 >\r
68 > - we display the tag state correctly: i.e. we don't display the tag as\r
69 >   deleted (no strike through)\r
70 >\r
71 > - and since we know the tag change failed we can try to mark this\r
72 >   message read in the future. Indeed, since the code uses the\r
73 >   post-command hook we will try again on the next keypress (unless the\r
74 >   user has left the message).\r
75 >\r
76 > We indicate to the user that these mark read tag changes may have\r
77 > failed in the header-line and by a message in the echo area.\r
78 > ---\r
79 >\r
80 > Hi\r
81 >\r
82 > The best level of user notification in case of an error is\r
83 > unclear. The best we came up with on irc is this one:\r
84 >\r
85 > On first error, the headerline is changed to say (in warning face)\r
86 > that some mark read tag changes may have failed.\r
87 >\r
88 > On each error, which will occur on each call to\r
89 > notmuch-show-command-hook (so roughly after each keypress) we write\r
90 > the error to the error buffer and we send a message to the echo area.\r
91 >\r
92 > In principle I would like to send a single message to the echo area\r
93 > and have it persist for a few seconds. However, the echo area is\r
94 > cleared after each keypress so this seems difficult. Moreover, this\r
95 > clearing means if we send the message a single time and the user\r
96 > enters the message with repeated cursor-downs then the message will\r
97 > disappear as soon as it is displayed.\r
98 >\r
99 > In the future we might want to modify the error code to be something like the\r
100 > message buffer and say "last error repeated x times", but that can\r
101 > come later.\r
102 >\r
103 > Best wishes\r
104 >\r
105 > Mark\r
106 >\r
107 >\r
108 >  emacs/notmuch-show.el | 17 ++++++++++++++++-\r
109 >  1 file changed, 16 insertions(+), 1 deletion(-)\r
110 >\r
111 > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
112 > index fea39fa..406f418 100644\r
113 > --- a/emacs/notmuch-show.el\r
114 > +++ b/emacs/notmuch-show.el\r
115 > @@ -1701,12 +1701,27 @@ user decision and we should not override it."\r
116 >       (notmuch-show-mark-read)\r
117 >       (notmuch-show-set-prop :seen t)))\r
118 >  \r
119 > +(defvar notmuch-show--seen-has-errored nil)\r
120 > +(make-variable-buffer-local 'notmuch-show--seen-has-errored)\r
121 > +\r
122 >  (defun notmuch-show-command-hook ()\r
123 >    (when (eq major-mode 'notmuch-show-mode)\r
124 >      ;; We need to redisplay to get window-start and window-end correct.\r
125 >      (redisplay)\r
126 >      (save-excursion\r
127 > -      (funcall notmuch-show-mark-read-function (window-start) (window-end)))))\r
128 > +      (condition-case nil\r
129 > +       (funcall notmuch-show-mark-read-function (window-start) (window-end))\r
130 > +     ((debug error)\r
131 > +      ;; The call chain from notmuch-show-mark-read-function writes\r
132 > +      ;; and error to the error buffer before calling the error, so\r
133 > +      ;; we do not need to do that here. Just tell the user.\r
134 \r
135 I had a bit of difficulties to test this since:\r
136 \r
137 notmuch-show-mark-read-function's value is (lambda\r
138   (start end)\r
139     (notmuch-show-do-seen start\r
140                           (point)\r
141                           1000000))\r
142 \r
143 Original value was\r
144 notmuch-show-seen-current-message\r
145 \r
146 (yes, I've heard there if helper called devel/try-emacs-mua but I just\r
147 ignored that knowledge >;) -- actually I put this to my production use,\r
148 replacing my old solution...)\r
149 \r
150 But, If user changes that then it can be expected that errors are handled, too...\r
151 \r
152 \r
153 I'll keep running this; is there any better way to test this than\r
154 \r
155         (setq notmuch-command "broken")\r
156 \r
157 Change looks good...\r
158 \r
159 \r
160 Tomi\r
161 \r
162 \r
163 > +      (message "Warning -- marking message read failed.")\r
164 > +      (unless notmuch-show--seen-has-errored\r
165 > +        (setq notmuch-show--seen-has-errored 't)\r
166 > +        (setq header-line-format\r
167 > +              (concat header-line-format\r
168 > +                      (propertize "  [some mark read tag changes may have failed]"\r
169 > +                                  'face font-lock-warning-face)))))))))\r
170 >  \r
171 >  (defun notmuch-show-filter-thread (query)\r
172 >    "Filter or LIMIT the current thread based on a new query string.\r