Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / d0 / f73f28ac3067945d3d6f9c79a883062c09b0a1
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 00AE66DE0A87\r
6  for <notmuch@notmuchmail.org>; Sun, 14 Feb 2016 13:29:08 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.274\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.274 tagged_above=-999 required=5 tests=[AWL=0.296,\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 4BBgytSeopoh for <notmuch@notmuchmail.org>;\r
19  Sun, 14 Feb 2016 13:29:05 -0800 (PST)\r
20 Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com\r
21  [74.125.82.68]) by arlo.cworth.org (Postfix) with ESMTPS id A87396DE0943 for\r
22  <notmuch@notmuchmail.org>; Sun, 14 Feb 2016 13:29:04 -0800 (PST)\r
23 Received: by mail-wm0-f68.google.com with SMTP id a4so7528268wme.3\r
24  for <notmuch@notmuchmail.org>; Sun, 14 Feb 2016 13:29:04 -0800 (PST)\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
26  h=from:to:subject:in-reply-to:references:user-agent:date:message-id\r
27  :mime-version:content-type;\r
28  bh=XA7mEG78e7r9y6lLIJuzTF7y4+9tyTiQRFNnPf3KoEE=;\r
29  b=0v8PLIMTr+YC1nMNY5S58mluVcHEeecnb/X8Y7ubkDxhldQllfsOjD7LGWQC9h9HcC\r
30  9WAfFAdKHmuXHTQhw31lGWi94i4NmB7zJ9Wzchjdw/eKfO8En33jVwXnQAjNHYFBnybM\r
31  ZcSqfJ7NH8RWxp/RQlQpxjjFohvnY5pmpElmhLF3Jt8HYw1fFjGclf4X4oq2JACKBA7/\r
32  tujB+TMHpADJ2G8MeCeoGxWNFvt0bTYcVgh3RuBkLobPUhcGJhVtI9TfGKkGSBNpj0Z3\r
33  te28KHlUa2QHa5e1yJjp8/raaRU+m/Ub54/BpHnK2jERVl5IhlZ9Gir82Mb73vdbm830\r
34  IDDw==\r
35 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
36  d=1e100.net; s=20130820;\r
37  h=x-gm-message-state:from:to:subject:in-reply-to:references\r
38  :user-agent:date:message-id:mime-version:content-type;\r
39  bh=XA7mEG78e7r9y6lLIJuzTF7y4+9tyTiQRFNnPf3KoEE=;\r
40  b=F4eguX8CSc88OWV8yKTR2h4y1Eilivijj3+yOmECQJOpBa1kHOptaMEdaJApk4C/RT\r
41  a6JekneLeE7F27mQQxWr8dee7kqMYWWzf42uar8EoF2MPZ5q5gHRfcUuNBJvnGdCYi7G\r
42  wwTXc5JJolWQY6tRel4qTYp/PB+5yFF7dkCtjlfmJ8VJTLvq73YszTVGQjDVKehk3yoE\r
43  IvZ/OgoLA/UhqLBi23ZqD4RozhS+PWV8OudXMuy8RQrxO998FU+ZEODrG8fXpiJbsNFV\r
44  BaaCLl/sshX+c2F7S7dqLlyHRz8r88Dd2JmE2cD7yCl0xRbct9pS0zZBwXesF62OCg1e\r
45  mdSA==\r
46 X-Gm-Message-State:\r
47  AG10YOTK4MlSnZdX/PWJg1cbLcMjqxMm41apocbOEa+eBLccvMWqgzEHvfhYLMR302X6UQ==\r
48 X-Received: by 10.28.100.7 with SMTP id y7mr7061250wmb.87.1455485343170;\r
49  Sun, 14 Feb 2016 13:29:03 -0800 (PST)\r
50 Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162])\r
51  by smtp.gmail.com with ESMTPSA id v191sm12578514wme.1.2016.02.14.13.29.02\r
52  (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
53  Sun, 14 Feb 2016 13:29:02 -0800 (PST)\r
54 From: Mark Walters <markwalters1009@gmail.com>\r
55 To: David Edmondson <dme@dme.org>, notmuch@notmuchmail.org\r
56 Subject: Re: [PATCH v3] emacs: Report a lack of matches when calling\r
57  `notmuch-show'.\r
58 In-Reply-To: <1455179607-16870-2-git-send-email-dme@dme.org>\r
59 References: <1455179607-16870-1-git-send-email-dme@dme.org>\r
60  <1455179607-16870-2-git-send-email-dme@dme.org>\r
61 User-Agent: Notmuch/0.18.1+485~gca076ce (http://notmuchmail.org) Emacs/24.4.1\r
62  (x86_64-pc-linux-gnu)\r
63 Date: Sun, 14 Feb 2016 21:29:01 +0000\r
64 Message-ID: <87vb5rrnfm.fsf@qmul.ac.uk>\r
65 MIME-Version: 1.0\r
66 Content-Type: text/plain\r
67 X-BeenThere: notmuch@notmuchmail.org\r
68 X-Mailman-Version: 2.1.20\r
69 Precedence: list\r
70 List-Id: "Use and development of the notmuch mail system."\r
71  <notmuch.notmuchmail.org>\r
72 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
73  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
74 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
75 List-Post: <mailto:notmuch@notmuchmail.org>\r
76 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
77 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
78  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
79 X-List-Received-Date: Sun, 14 Feb 2016 21:29:08 -0000\r
80 \r
81 \r
82 Just to confirm that this LGTM +1.\r
83 \r
84 Best wishes\r
85 \r
86 Mark\r
87 \r
88 On Thu, 11 Feb 2016, David Edmondson <dme@dme.org> wrote:\r
89 > If the basic query passed to `notmuch-show' generates no results, ring\r
90 > the bell and inform the user that no messages matched the query rather\r
91 > than displaying an empty buffer and showing an obscure error.\r
92 >\r
93 > Similarly when refreshing a `notmuch-show' buffer and no messages match.\r
94 > ---\r
95 >  emacs/notmuch-show.el | 144 +++++++++++++++++++++++++++++---------------------\r
96 >  emacs/notmuch.el      |   6 ++-\r
97 >  2 files changed, 89 insertions(+), 61 deletions(-)\r
98 >\r
99 > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
100 > index 3345878..4629c64 100644\r
101 > --- a/emacs/notmuch-show.el\r
102 > +++ b/emacs/notmuch-show.el\r
103 > @@ -153,27 +153,21 @@ indentation."\r
104 >  \r
105 >  (defvar notmuch-show-thread-id nil)\r
106 >  (make-variable-buffer-local 'notmuch-show-thread-id)\r
107 > -(put 'notmuch-show-thread-id 'permanent-local t)\r
108 >  \r
109 >  (defvar notmuch-show-parent-buffer nil)\r
110 >  (make-variable-buffer-local 'notmuch-show-parent-buffer)\r
111 > -(put 'notmuch-show-parent-buffer 'permanent-local t)\r
112 >  \r
113 >  (defvar notmuch-show-query-context nil)\r
114 >  (make-variable-buffer-local 'notmuch-show-query-context)\r
115 > -(put 'notmuch-show-query-context 'permanent-local t)\r
116 >  \r
117 >  (defvar notmuch-show-process-crypto nil)\r
118 >  (make-variable-buffer-local 'notmuch-show-process-crypto)\r
119 > -(put 'notmuch-show-process-crypto 'permanent-local t)\r
120 >  \r
121 >  (defvar notmuch-show-elide-non-matching-messages nil)\r
122 >  (make-variable-buffer-local 'notmuch-show-elide-non-matching-messages)\r
123 > -(put 'notmuch-show-elide-non-matching-messages 'permanent-local t)\r
124 >  \r
125 >  (defvar notmuch-show-indent-content t)\r
126 >  (make-variable-buffer-local 'notmuch-show-indent-content)\r
127 > -(put 'notmuch-show-indent-content 'permanent-local t)\r
128 >  \r
129 >  (defvar notmuch-show-attachment-debug nil\r
130 >    "If t log stdout and stderr from attachment handlers\r
131 > @@ -1197,71 +1191,101 @@ non-nil.\r
132 >  The optional BUFFER-NAME provides the name of the buffer in\r
133 >  which the message thread is shown. If it is nil (which occurs\r
134 >  when the command is called interactively) the argument to the\r
135 > -function is used."\r
136 > +function is used.\r
137 > +\r
138 > +Returns the buffer containing the messages, or NIL if no messages\r
139 > +matched."\r
140 >    (interactive "sNotmuch show: \nP")\r
141 >    (let ((buffer-name (generate-new-buffer-name\r
142 >                     (or buffer-name\r
143 >                         (concat "*notmuch-" thread-id "*")))))\r
144 >      (switch-to-buffer (get-buffer-create buffer-name))\r
145 > -    ;; Set the default value for `notmuch-show-process-crypto' in this\r
146 > -    ;; buffer.\r
147 > -    (setq notmuch-show-process-crypto notmuch-crypto-process-mime)\r
148 > -    ;; Set the default value for\r
149 > -    ;; `notmuch-show-elide-non-matching-messages' in this buffer. If\r
150 > -    ;; elide-toggle is set, invert the default.\r
151 > -    (setq notmuch-show-elide-non-matching-messages notmuch-show-only-matching-messages)\r
152 > -    (if elide-toggle\r
153 > -     (setq notmuch-show-elide-non-matching-messages (not notmuch-show-elide-non-matching-messages)))\r
154 > +    ;; No need to track undo information for this buffer.\r
155 > +    (setq buffer-undo-list t)\r
156 > +\r
157 > +    (notmuch-show-mode)\r
158 >  \r
159 > +    ;; Set various buffer local variables to their appropriate initial\r
160 > +    ;; state. Do this after enabling `notmuch-show-mode' so that they\r
161 > +    ;; aren't wiped out.\r
162 >      (setq notmuch-show-thread-id thread-id\r
163 >         notmuch-show-parent-buffer parent-buffer\r
164 > -       notmuch-show-query-context query-context)\r
165 > -    (notmuch-show-build-buffer)\r
166 > -    (notmuch-show-goto-first-wanted-message)\r
167 > -    (current-buffer)))\r
168 > +       notmuch-show-query-context query-context\r
169 >  \r
170 > -(defun notmuch-show-build-buffer ()\r
171 > -  (let ((inhibit-read-only t))\r
172 > +       notmuch-show-process-crypto notmuch-crypto-process-mime\r
173 > +       ;; If `elide-toggle', invert the default value.\r
174 > +       notmuch-show-elide-non-matching-messages\r
175 > +       (if elide-toggle\r
176 > +           (not notmuch-show-only-matching-messages)\r
177 > +         notmuch-show-only-matching-messages))\r
178 >  \r
179 > -    (notmuch-show-mode)\r
180 >      (add-hook 'post-command-hook #'notmuch-show-command-hook nil t)\r
181 > -\r
182 > -    ;; Don't track undo information for this buffer\r
183 > -    (set 'buffer-undo-list t)\r
184 > +    (jit-lock-register #'notmuch-show-buttonise-links)\r
185 >  \r
186 >      (notmuch-tag-clear-cache)\r
187 > -    (erase-buffer)\r
188 > -    (goto-char (point-min))\r
189 > -    (save-excursion\r
190 > -      (let* ((basic-args (list notmuch-show-thread-id))\r
191 > -          (args (if notmuch-show-query-context\r
192 > -                    (append (list "\'") basic-args\r
193 > -                            (list "and (" notmuch-show-query-context ")\'"))\r
194 > -                  (append (list "\'") basic-args (list "\'"))))\r
195 > -          (cli-args (cons "--exclude=false"\r
196 > -                          (when notmuch-show-elide-non-matching-messages\r
197 > -                            (list "--entire-thread=false")))))\r
198 > -\r
199 > -     (notmuch-show-insert-forest (notmuch-query-get-threads (append cli-args args)))\r
200 > -     ;; If the query context reduced the results to nothing, run\r
201 > -     ;; the basic query.\r
202 > -     (when (and (eq (buffer-size) 0)\r
203 > -                notmuch-show-query-context)\r
204 > -       (notmuch-show-insert-forest\r
205 > -        (notmuch-query-get-threads (append cli-args basic-args)))))\r
206 > -\r
207 > -      (jit-lock-register #'notmuch-show-buttonise-links)\r
208 > -\r
209 > -      (notmuch-show-mapc (lambda () (notmuch-show-set-prop :orig-tags (notmuch-show-get-tags))))\r
210 > +\r
211 > +    (let ((inhibit-read-only t))\r
212 > +      (if (notmuch-show--build-buffer)\r
213 > +       ;; Messages were inserted into the buffer.\r
214 > +       (current-buffer)\r
215 > +\r
216 > +     ;; No messages were inserted - presumably none matched the\r
217 > +     ;; query.\r
218 > +     (kill-buffer (current-buffer))\r
219 > +     (ding)\r
220 > +     (message "No messages matched the query!")\r
221 > +     nil))))\r
222 > +\r
223 > +(defun notmuch-show--build-buffer (&optional state)\r
224 > +  "Display messages matching the current buffer context.\r
225 > +\r
226 > +Apply the previously saved STATE if supplied, otherwise show the\r
227 > +first relevant message.\r
228 > +\r
229 > +If no messages match the query return NIL."\r
230 > +  (let* ((basic-args (list notmuch-show-thread-id))\r
231 > +      (args (if notmuch-show-query-context\r
232 > +                (append (list "\'") basic-args\r
233 > +                        (list "and (" notmuch-show-query-context ")\'"))\r
234 > +              (append (list "\'") basic-args (list "\'"))))\r
235 > +      (cli-args (cons "--exclude=false"\r
236 > +                      (when notmuch-show-elide-non-matching-messages\r
237 > +                        (list "--entire-thread=false"))))\r
238 > +\r
239 > +      (forest (or (notmuch-query-get-threads (append cli-args args))\r
240 > +                  ;; If a query context reduced the number of\r
241 > +                  ;; results to zero, try again without it.\r
242 > +                  (and notmuch-show-query-context\r
243 > +                       (notmuch-query-get-threads (append cli-args basic-args)))))\r
244 > +\r
245 > +      ;; Must be reset every time we are going to start inserting\r
246 > +      ;; messages into the buffer.\r
247 > +      (notmuch-show-previous-subject ""))\r
248 > +\r
249 > +    (when forest\r
250 > +      (notmuch-show-insert-forest forest)\r
251 > +\r
252 > +      ;; Store the original tags for each message so that we can\r
253 > +      ;; display changes.\r
254 > +      (notmuch-show-mapc\r
255 > +       (lambda () (notmuch-show-set-prop :orig-tags (notmuch-show-get-tags))))\r
256 >  \r
257 >        ;; Set the header line to the subject of the first message.\r
258 >        (setq header-line-format\r
259 >           (replace-regexp-in-string "%" "%%"\r
260 > -                         (notmuch-sanitize\r
261 > -                          (notmuch-show-strip-re\r
262 > -                           (notmuch-show-get-subject)))))\r
263 > +                                   (notmuch-sanitize\r
264 > +                                    (notmuch-show-strip-re\r
265 > +                                     (notmuch-show-get-subject)))))\r
266 >  \r
267 > -      (run-hooks 'notmuch-show-hook))))\r
268 > +      (run-hooks 'notmuch-show-hook)\r
269 > +\r
270 > +      (if state\r
271 > +       (notmuch-show-apply-state state)\r
272 > +     ;; With no state to apply, just go to the first message.\r
273 > +     (notmuch-show-goto-first-wanted-message)))\r
274 > +\r
275 > +    ;; Report back to the caller whether any messages matched.\r
276 > +    forest))\r
277 >  \r
278 >  (defun notmuch-show-capture-state ()\r
279 >    "Capture the state of the current buffer.\r
280 > @@ -1320,17 +1344,17 @@ reset based on the original query."\r
281 >    (let ((inhibit-read-only t)\r
282 >       (state (unless reset-state\r
283 >                (notmuch-show-capture-state))))\r
284 > -    ;; erase-buffer does not seem to remove overlays, which can lead\r
285 > +    ;; `erase-buffer' does not seem to remove overlays, which can lead\r
286 >      ;; to weird effects such as remaining images, so remove them\r
287 >      ;; manually.\r
288 >      (remove-overlays)\r
289 >      (erase-buffer)\r
290 > -    (notmuch-show-build-buffer)\r
291 > -    (if state\r
292 > -     (notmuch-show-apply-state state)\r
293 > -      ;; We're resetting state, so navigate to the first open message\r
294 > -      ;; and mark it read, just like opening a new show buffer.\r
295 > -      (notmuch-show-goto-first-wanted-message))))\r
296 > +\r
297 > +    (unless (notmuch-show--build-buffer state)\r
298 > +      ;; No messages were inserted.\r
299 > +      (kill-buffer (current-buffer))\r
300 > +      (ding)\r
301 > +      (message "Refreshing the buffer resulted in no messages!"))))\r
302 >  \r
303 >  (defvar notmuch-show-stash-map\r
304 >    (let ((map (make-sparse-keymap)))\r
305 > diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
306 > index 463b926..3100b97 100644\r
307 > --- a/emacs/notmuch.el\r
308 > +++ b/emacs/notmuch.el\r
309 > @@ -458,7 +458,11 @@ no messages in the region then return nil."\r
310 >    (notmuch-search-properties-in-region :subject beg end))\r
311 >  \r
312 >  (defun notmuch-search-show-thread (&optional elide-toggle)\r
313 > -  "Display the currently selected thread."\r
314 > +  "Display the currently selected thread.\r
315 > +\r
316 > +With a prefix argument, invert the default value of\r
317 > +`notmuch-show-only-matching-messages' when displaying the\r
318 > +thread."\r
319 >    (interactive "P")\r
320 >    (let ((thread-id (notmuch-search-find-thread-id))\r
321 >       (subject (notmuch-search-find-subject)))\r
322 > -- \r
323 > 2.1.4\r
324 >\r
325 > _______________________________________________\r
326 > notmuch mailing list\r
327 > notmuch@notmuchmail.org\r
328 > https://notmuchmail.org/mailman/listinfo/notmuch\r