]> git.notmuchmail.org Git - notmuch/blob - emacs/notmuch-show.el
emacs: Allow indentation of multipart children.
[notmuch] / emacs / notmuch-show.el
1 ;; notmuch-show.el --- displaying notmuch forests.
2 ;;
3 ;; Copyright © Carl Worth
4 ;; Copyright © David Edmondson
5 ;;
6 ;; This file is part of Notmuch.
7 ;;
8 ;; Notmuch is free software: you can redistribute it and/or modify it
9 ;; under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation, either version 3 of the License, or
11 ;; (at your option) any later version.
12 ;;
13 ;; Notmuch is distributed in the hope that it will be useful, but
14 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 ;; General Public License for more details.
17 ;;
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with Notmuch.  If not, see <http://www.gnu.org/licenses/>.
20 ;;
21 ;; Authors: Carl Worth <cworth@cworth.org>
22 ;;          David Edmondson <dme@dme.org>
23
24 (eval-when-compile (require 'cl))
25 (require 'mm-view)
26 (require 'message)
27 (require 'mm-decode)
28 (require 'mailcap)
29
30 (require 'notmuch-lib)
31 (require 'notmuch-query)
32 (require 'notmuch-wash)
33 (require 'notmuch-mua)
34
35 (declare-function notmuch-call-notmuch-process "notmuch" (&rest args))
36 (declare-function notmuch-fontify-headers "notmuch" nil)
37 (declare-function notmuch-select-tag-with-completion "notmuch" (prompt &rest search-terms))
38 (declare-function notmuch-search-show-thread "notmuch" nil)
39
40 (defcustom notmuch-message-headers '("Subject" "To" "Cc" "Date")
41   "Headers that should be shown in a message, in this order.
42
43 For an open message, all of these headers will be made visible
44 according to `notmuch-message-headers-visible' or can be toggled
45 with `notmuch-show-toggle-headers'. For a closed message, only
46 the first header in the list will be visible."
47   :group 'notmuch
48   :type '(repeat string))
49
50 (defcustom notmuch-message-headers-visible t
51   "Should the headers be visible by default?
52
53 If this value is non-nil, then all of the headers defined in
54 `notmuch-message-headers' will be visible by default in the display
55 of each message. Otherwise, these headers will be hidden and
56 `notmuch-show-toggle-headers' can be used to make the visible for
57 any given message."
58   :group 'notmuch
59   :type 'boolean)
60
61 (defcustom notmuch-show-relative-dates t
62   "Display relative dates in the message summary line."
63   :group 'notmuch
64   :type 'boolean)
65
66 (defvar notmuch-show-markup-headers-hook '(notmuch-show-colour-headers)
67   "A list of functions called to decorate the headers listed in
68 `notmuch-message-headers'.")
69
70 (defcustom notmuch-show-hook nil
71   "Functions called after populating a `notmuch-show' buffer."
72   :group 'notmuch
73   :type 'hook)
74
75 (defcustom notmuch-show-insert-text/plain-hook '(notmuch-wash-excerpt-citations)
76   "Functions used to improve the display of text/plain parts."
77   :group 'notmuch
78   :type 'hook
79   :options '(notmuch-wash-convert-inline-patch-to-part
80              notmuch-wash-wrap-long-lines
81              notmuch-wash-tidy-citations
82              notmuch-wash-elide-blank-lines
83              notmuch-wash-excerpt-citations))
84
85 (defcustom notmuch-show-indent-multipart nil
86   "Should the sub-parts of a multipart/* part be indented?"
87   ;; dme: Not sure which is a good default.
88   :group 'notmuch
89   :type 'boolean)
90
91 (defmacro with-current-notmuch-show-message (&rest body)
92   "Evaluate body with current buffer set to the text of current message"
93   `(save-excursion
94      (let ((id (notmuch-show-get-message-id)))
95        (let ((buf (generate-new-buffer (concat "*notmuch-msg-" id "*"))))
96          (with-current-buffer buf
97             (call-process notmuch-command nil t nil "show" "--format=raw" id)
98            ,@body)
99          (kill-buffer buf)))))
100
101 (defun notmuch-show-view-all-mime-parts ()
102   "Use external viewers to view all attachments from the current message."
103   (interactive)
104   (with-current-notmuch-show-message
105    ; We ovverride the mm-inline-media-tests to indicate which message
106    ; parts are already sufficiently handled by the original
107    ; presentation of the message in notmuch-show mode. These parts
108    ; will be inserted directly into the temporary buffer of
109    ; with-current-notmuch-show-message and silently discarded.
110    ;
111    ; Any MIME part not explicitly mentioned here will be handled by an
112    ; external viewer as configured in the various mailcap files.
113    (let ((mm-inline-media-tests '(
114                                   ("text/.*" ignore identity)
115                                   ("application/pgp-signature" ignore identity)
116                                   ("multipart/alternative" ignore identity)
117                                   ("multipart/mixed" ignore identity)
118                                   ("multipart/related" ignore identity)
119                                  )))
120      (mm-display-parts (mm-dissect-buffer)))))
121
122 (defun notmuch-foreach-mime-part (function mm-handle)
123   (cond ((stringp (car mm-handle))
124          (dolist (part (cdr mm-handle))
125            (notmuch-foreach-mime-part function part)))
126         ((bufferp (car mm-handle))
127          (funcall function mm-handle))
128         (t (dolist (part mm-handle)
129              (notmuch-foreach-mime-part function part)))))
130
131 (defun notmuch-count-attachments (mm-handle)
132   (let ((count 0))
133     (notmuch-foreach-mime-part
134      (lambda (p)
135        (let ((disposition (mm-handle-disposition p)))
136          (and (listp disposition)
137               (or (equal (car disposition) "attachment")
138                   (and (equal (car disposition) "inline")
139                        (assq 'filename disposition)))
140               (incf count))))
141      mm-handle)
142     count))
143
144 (defun notmuch-save-attachments (mm-handle &optional queryp)
145   (notmuch-foreach-mime-part
146    (lambda (p)
147      (let ((disposition (mm-handle-disposition p)))
148        (and (listp disposition)
149             (or (equal (car disposition) "attachment")
150                 (and (equal (car disposition) "inline")
151                      (assq 'filename disposition)))
152             (or (not queryp)
153                 (y-or-n-p
154                  (concat "Save '" (cdr (assq 'filename disposition)) "' ")))
155             (mm-save-part p))))
156    mm-handle))
157
158 (defun notmuch-show-save-attachments ()
159   "Save all attachments from the current message."
160   (interactive)
161   (with-current-notmuch-show-message
162    (let ((mm-handle (mm-dissect-buffer)))
163      (notmuch-save-attachments
164       mm-handle (> (notmuch-count-attachments mm-handle) 1))))
165   (message "Done"))
166
167 (defun notmuch-show-fontify-header ()
168   (let ((face (cond
169                ((looking-at "[Tt]o:")
170                 'message-header-to)
171                ((looking-at "[Bb]?[Cc][Cc]:")
172                 'message-header-cc)
173                ((looking-at "[Ss]ubject:")
174                 'message-header-subject)
175                ((looking-at "[Ff]rom:")
176                 'message-header-from)
177                (t
178                 'message-header-other))))
179
180     (overlay-put (make-overlay (point) (re-search-forward ":"))
181                  'face 'message-header-name)
182     (overlay-put (make-overlay (point) (re-search-forward ".*$"))
183                  'face face)))
184
185 (defun notmuch-show-colour-headers ()
186   "Apply some colouring to the current headers."
187   (goto-char (point-min))
188   (while (looking-at "^[A-Za-z][-A-Za-z0-9]*:")
189     (notmuch-show-fontify-header)
190     (forward-line)))
191
192 (defun notmuch-show-spaces-n (n)
193   "Return a string comprised of `n' spaces."
194   (make-string n ? ))
195
196 (defun notmuch-show-update-tags (tags)
197   "Update the displayed tags of the current message."
198   (save-excursion
199     (goto-char (notmuch-show-message-top))
200     (if (re-search-forward "(\\([^()]*\\))$" (line-end-position) t)
201         (let ((inhibit-read-only t))
202           (replace-match (concat "("
203                                  (propertize (mapconcat 'identity tags " ")
204                                              'face 'notmuch-tag-face)
205                                  ")"))))))
206
207 (defun notmuch-show-insert-headerline (headers date tags depth)
208   "Insert a notmuch style headerline based on HEADERS for a
209 message at DEPTH in the current thread."
210   (let ((start (point)))
211     (insert (notmuch-show-spaces-n depth)
212             (plist-get headers :From)
213             " ("
214             date
215             ") ("
216             (propertize (mapconcat 'identity tags " ")
217                         'face 'notmuch-tag-face)
218             ")\n")
219     (overlay-put (make-overlay start (point)) 'face 'notmuch-message-summary-face)))
220
221 (defun notmuch-show-insert-header (header header-value)
222   "Insert a single header."
223   (insert header ": " header-value "\n"))
224
225 (defun notmuch-show-insert-headers (headers)
226   "Insert the headers of the current message."
227   (let ((start (point)))
228     (mapc '(lambda (header)
229              (let* ((header-symbol (intern (concat ":" header)))
230                     (header-value (plist-get headers header-symbol)))
231                (if (and header-value
232                         (not (string-equal "" header-value)))
233                    (notmuch-show-insert-header header header-value))))
234           notmuch-message-headers)
235     (save-excursion
236       (save-restriction
237         (narrow-to-region start (point-max))
238         (run-hooks 'notmuch-show-markup-headers-hook)))))
239
240 (define-button-type 'notmuch-show-part-button-type
241   'action 'notmuch-show-part-button-action
242   'follow-link t
243   'face 'message-mml)
244
245 (defun notmuch-show-insert-part-header (nth content-type declared-type &optional name comment)
246   (insert-button
247    (concat "[ "
248            (if name (concat name ": ") "")
249            declared-type
250            (if (not (string-equal declared-type content-type))
251                (concat " (as " content-type ")")
252              "")
253            (or comment "")
254            " ]\n")
255    :type 'notmuch-show-part-button-type
256    :notmuch-part nth
257    :notmuch-filename name))
258
259 ;; Functions handling particular MIME parts.
260
261 (defun notmuch-show-save-part (message-id nth &optional filename)
262   (with-temp-buffer
263     ;; Always acquires the part via `notmuch part', even if it is
264     ;; available in the JSON output.
265     (insert (notmuch-show-get-bodypart-internal message-id nth))
266     (let ((file (read-file-name
267                  "Filename to save as: "
268                  (or mailcap-download-directory "~/")
269                  nil nil
270                  filename))
271           (require-final-newline nil)
272           (coding-system-for-write 'no-conversion))
273       (write-region (point-min) (point-max) file))))
274
275 (defun notmuch-show-mm-display-part-inline (msg part content-type content)
276   "Use the mm-decode/mm-view functions to display a part in the
277 current buffer, if possible."
278   (let ((display-buffer (current-buffer)))
279     (with-temp-buffer
280       (insert content)
281       (let ((handle (mm-make-handle (current-buffer) (list content-type))))
282         (set-buffer display-buffer)
283         (if (and (mm-inlinable-p handle)
284                  (mm-inlined-p handle))
285             (progn
286               (mm-display-part handle)
287               t)
288           nil)))))
289
290 (defvar notmuch-show-multipart/alternative-discouraged
291   '(
292     ;; Avoid HTML parts.
293     "text/html"
294     ;; multipart/related usually contain a text/html part and some associated graphics.
295     "multipart/related"
296     ))
297
298 (defun notmuch-show-multipart/*-to-list (part)
299   (mapcar '(lambda (inner-part) (plist-get inner-part :content-type))
300           (plist-get part :content)))
301
302 (defun notmuch-show-multipart/alternative-choose (types)
303   ;; Based on `mm-preferred-alternative-precedence'.
304   (let ((seq types))
305     (dolist (pref (reverse notmuch-show-multipart/alternative-discouraged))
306       (dolist (elem (copy-sequence seq))
307         (when (string-match pref elem)
308           (setq seq (nconc (delete elem seq) (list elem))))))
309     seq))
310
311 (defun notmuch-show-insert-part-multipart/alternative (msg part content-type nth depth declared-type)
312   (notmuch-show-insert-part-header nth declared-type content-type nil)
313   (let ((chosen-type (car (notmuch-show-multipart/alternative-choose (notmuch-show-multipart/*-to-list part))))
314         (inner-parts (plist-get part :content))
315         (start (point)))
316     ;; This inserts all parts of the chosen type rather than just one,
317     ;; but it's not clear that this is the wrong thing to do - which
318     ;; should be chosen if there are more than one that match?
319     (mapc (lambda (inner-part)
320             (let ((inner-type (plist-get inner-part :content-type)))
321               (if (string= chosen-type inner-type)
322                   (notmuch-show-insert-bodypart msg inner-part depth)
323                 (notmuch-show-insert-part-header (plist-get inner-part :id) inner-type inner-type nil " (not shown)"))))
324           inner-parts)
325
326     (when notmuch-show-indent-multipart
327       (indent-rigidly start (point) 1)))
328   t)
329
330 (defun notmuch-show-insert-part-multipart/* (msg part content-type nth depth declared-type)
331   (notmuch-show-insert-part-header nth declared-type content-type nil)
332   (let ((inner-parts (plist-get part :content))
333         (start (point)))
334     ;; Show all of the parts.
335     (mapc (lambda (inner-part)
336             (notmuch-show-insert-bodypart msg inner-part depth))
337           inner-parts)
338
339     (when notmuch-show-indent-multipart
340       (indent-rigidly start (point) 1)))
341   t)
342
343 (defun notmuch-show-insert-part-message/rfc822 (msg part content-type nth depth declared-type)
344   (let* ((message-part (plist-get part :content))
345          (inner-parts (plist-get message-part :content)))
346     (notmuch-show-insert-part-header nth declared-type content-type nil)
347     ;; Override `notmuch-message-headers' to force `From' to be
348     ;; displayed.
349     (let ((notmuch-message-headers '("From" "Subject" "To" "Cc" "Date")))
350       (notmuch-show-insert-headers (plist-get part :headers)))
351     ;; Blank line after headers to be compatible with the normal
352     ;; message display.
353     (insert "\n")
354
355     ;; Show all of the parts.
356     (mapc (lambda (inner-part)
357             (notmuch-show-insert-bodypart msg inner-part depth))
358           inner-parts))
359   t)
360
361 (defun notmuch-show-insert-part-text/plain (msg part content-type nth depth declared-type)
362   (let ((start (point)))
363     ;; If this text/plain part is not the first part in the message,
364     ;; insert a header to make this clear.
365     (if (> nth 1)
366         (notmuch-show-insert-part-header nth declared-type content-type (plist-get part :filename)))
367     (insert (notmuch-show-get-bodypart-content msg part nth))
368     (save-excursion
369       (save-restriction
370         (narrow-to-region start (point-max))
371         (run-hook-with-args 'notmuch-show-insert-text/plain-hook depth))))
372   t)
373
374 (defun notmuch-show-insert-part-application/octet-stream (msg part content-type nth depth declared-type)
375   ;; If we can deduce a MIME type from the filename of the attachment,
376   ;; do so and pass it on to the handler for that type.
377   (if (plist-get part :filename)
378       (let ((extension (file-name-extension (plist-get part :filename)))
379             mime-type)
380         (if extension
381             (progn
382               (mailcap-parse-mimetypes)
383               (setq mime-type (mailcap-extension-to-mime extension))
384               (if (and mime-type
385                        (not (string-equal mime-type "application/octet-stream")))
386                   (notmuch-show-insert-bodypart-internal msg part mime-type nth depth content-type)
387                 nil))
388           nil))))
389
390 (defun notmuch-show-insert-part-*/* (msg part content-type nth depth declared-type)
391   ;; This handler _must_ succeed - it is the handler of last resort.
392   (notmuch-show-insert-part-header nth content-type declared-type (plist-get part :filename))
393   (let ((content (notmuch-show-get-bodypart-content msg part nth)))
394     (if content
395         (notmuch-show-mm-display-part-inline msg part content-type content)))
396   t)
397
398 ;; Functions for determining how to handle MIME parts.
399
400 (defun notmuch-show-split-content-type (content-type)
401   (split-string content-type "/"))
402
403 (defun notmuch-show-handlers-for (content-type)
404   "Return a list of content handlers for a part of type CONTENT-TYPE."
405   (let (result)
406     (mapc (lambda (func)
407             (if (functionp func)
408                 (push func result)))
409           ;; Reverse order of prefrence.
410           (list (intern (concat "notmuch-show-insert-part-*/*"))
411                 (intern (concat
412                          "notmuch-show-insert-part-"
413                          (car (notmuch-show-split-content-type content-type))
414                          "/*"))
415                 (intern (concat "notmuch-show-insert-part-" content-type))))
416     result))
417
418 ;; Helper for parts which are generally not included in the default
419 ;; JSON output.
420
421 (defun notmuch-show-get-bodypart-internal (message-id part-number)
422   (with-temp-buffer
423     (let ((coding-system-for-read 'no-conversion))
424       (call-process notmuch-command nil t nil
425                     "part" (format "--part=%s" part-number) message-id)
426       (buffer-string))))
427
428 (defun notmuch-show-get-bodypart-content (msg part nth)
429   (or (plist-get part :content)
430       (notmuch-show-get-bodypart-internal (concat "id:" (plist-get msg :id)) nth)))
431
432 ;; \f
433
434 (defun notmuch-show-insert-bodypart-internal (msg part content-type nth depth declared-type)
435   (let ((handlers (notmuch-show-handlers-for content-type)))
436     ;; Run the content handlers until one of them returns a non-nil
437     ;; value.
438     (while (and handlers
439                 (not (funcall (car handlers) msg part content-type nth depth declared-type)))
440       (setq handlers (cdr handlers))))
441   t)
442
443 (defun notmuch-show-insert-bodypart (msg part depth)
444   "Insert the body part PART at depth DEPTH in the current thread."
445   (let ((content-type (downcase (plist-get part :content-type)))
446         (nth (plist-get part :id)))
447     (notmuch-show-insert-bodypart-internal msg part content-type nth depth content-type))
448   ;; Some of the body part handlers leave point somewhere up in the
449   ;; part, so we make sure that we're down at the end.
450   (goto-char (point-max))
451   ;; Ensure that the part ends with a carriage return.
452   (if (not (bolp))
453       (insert "\n")))
454
455 (defun notmuch-show-insert-body (msg body depth)
456   "Insert the body BODY at depth DEPTH in the current thread."
457   (mapc '(lambda (part) (notmuch-show-insert-bodypart msg part depth)) body))
458
459 (defun notmuch-show-make-symbol (type)
460   (make-symbol (concat "notmuch-show-" type)))
461
462 (defun notmuch-show-strip-re (string)
463   (replace-regexp-in-string "\\([Rr]e: *\\)+" "" string))
464
465 (defvar notmuch-show-previous-subject "")
466 (make-variable-buffer-local 'notmuch-show-previous-subject)
467
468 (defun notmuch-show-insert-msg (msg depth)
469   "Insert the message MSG at depth DEPTH in the current thread."
470   (let* ((headers (plist-get msg :headers))
471          ;; Indentation causes the buffer offset of the start/end
472          ;; points to move, so we must use markers.
473          message-start message-end
474          content-start content-end
475          headers-start headers-end
476          body-start body-end
477          (headers-invis-spec (notmuch-show-make-symbol "header"))
478          (message-invis-spec (notmuch-show-make-symbol "message"))
479          (bare-subject (notmuch-show-strip-re (plist-get headers :Subject))))
480
481     ;; Set `buffer-invisibility-spec' to `nil' (a list), otherwise
482     ;; removing items from `buffer-invisibility-spec' (which is what
483     ;; `notmuch-show-headers-visible' and
484     ;; `notmuch-show-message-visible' do) is a no-op and has no
485     ;; effect. This caused threads with only matching messages to have
486     ;; those messages hidden initially because
487     ;; `buffer-invisibility-spec' stayed `t'.
488     ;;
489     ;; This needs to be set here (rather than just above the call to
490     ;; `notmuch-show-headers-visible') because some of the part
491     ;; rendering or body washing functions
492     ;; (e.g. `notmuch-wash-text/plain-citations') manipulate
493     ;; `buffer-invisibility-spec').
494     (when (eq buffer-invisibility-spec t)
495       (setq buffer-invisibility-spec nil))
496
497     (setq message-start (point-marker))
498
499     (notmuch-show-insert-headerline headers
500                                     (or (if notmuch-show-relative-dates
501                                             (plist-get msg :date_relative)
502                                           nil)
503                                         (plist-get headers :Date))
504                                     (plist-get msg :tags) depth)
505
506     (setq content-start (point-marker))
507
508     ;; Set `headers-start' to point after the 'Subject:' header to be
509     ;; compatible with the existing implementation. This just sets it
510     ;; to after the first header.
511     (notmuch-show-insert-headers headers)
512     ;; Headers should include a blank line (backwards compatibility).
513     (insert "\n")
514     (save-excursion
515       (goto-char content-start)
516       ;; If the subject of this message is the same as that of the
517       ;; previous message, don't display it when this message is
518       ;; collapsed.
519       (when (not (string= notmuch-show-previous-subject
520                           bare-subject))
521         (forward-line 1))
522       (setq headers-start (point-marker)))
523     (setq headers-end (point-marker))
524
525     (setq notmuch-show-previous-subject bare-subject)
526
527     (setq body-start (point-marker))
528     (notmuch-show-insert-body msg (plist-get msg :body) depth)
529     ;; Ensure that the body ends with a newline.
530     (if (not (bolp))
531         (insert "\n"))
532     (setq body-end (point-marker))
533     (setq content-end (point-marker))
534
535     ;; Indent according to the depth in the thread.
536     (indent-rigidly content-start content-end depth)
537
538     (setq message-end (point-max-marker))
539
540     ;; Save the extents of this message over the whole text of the
541     ;; message.
542     (put-text-property message-start message-end :notmuch-message-extent (cons message-start message-end))
543
544     (plist-put msg :headers-invis-spec headers-invis-spec)
545     (overlay-put (make-overlay headers-start headers-end) 'invisible headers-invis-spec)
546
547     (plist-put msg :message-invis-spec message-invis-spec)
548     (overlay-put (make-overlay body-start body-end) 'invisible message-invis-spec)
549
550     ;; Save the properties for this message. Currently this saves the
551     ;; entire message (augmented it with other stuff), which seems
552     ;; like overkill. We might save a reduced subset (for example, not
553     ;; the content).
554     (notmuch-show-set-message-properties msg)
555
556     ;; Set header visibility.
557     (notmuch-show-headers-visible msg notmuch-message-headers-visible)
558
559     ;; Message visibility depends on whether it matched the search
560     ;; criteria.
561     (notmuch-show-message-visible msg (plist-get msg :match))))
562
563 (defun notmuch-show-insert-tree (tree depth)
564   "Insert the message tree TREE at depth DEPTH in the current thread."
565   (let ((msg (car tree))
566         (replies (cadr tree)))
567     (notmuch-show-insert-msg msg depth)
568     (notmuch-show-insert-thread replies (1+ depth))))
569
570 (defun notmuch-show-insert-thread (thread depth)
571   "Insert the thread THREAD at depth DEPTH in the current forest."
572   (mapc '(lambda (tree) (notmuch-show-insert-tree tree depth)) thread))
573
574 (defun notmuch-show-insert-forest (forest)
575   "Insert the forest of threads FOREST."
576   (mapc '(lambda (thread) (notmuch-show-insert-thread thread 0)) forest))
577
578 (defvar notmuch-show-parent-buffer nil)
579
580 ;;;###autoload
581 (defun notmuch-show (thread-id &optional parent-buffer query-context buffer-name)
582   "Run \"notmuch show\" with the given thread ID and display results.
583
584 The optional PARENT-BUFFER is the notmuch-search buffer from
585 which this notmuch-show command was executed, (so that the
586 next thread from that buffer can be show when done with this
587 one).
588
589 The optional QUERY-CONTEXT is a notmuch search term. Only
590 messages from the thread matching this search term are shown if
591 non-nil.
592
593 The optional BUFFER-NAME provides the neame of the buffer in
594 which the message thread is shown. If it is nil (which occurs
595 when the command is called interactively) the argument to the
596 function is used. "
597   (interactive "sNotmuch show: ")
598   (let ((buffer (get-buffer-create (generate-new-buffer-name
599                                     (or buffer-name
600                                         (concat "*notmuch-" thread-id "*")))))
601         (inhibit-read-only t))
602     (switch-to-buffer buffer)
603     (notmuch-show-mode)
604     (set (make-local-variable 'notmuch-show-parent-buffer) parent-buffer)
605     (erase-buffer)
606     (goto-char (point-min))
607     (save-excursion
608       (let* ((basic-args (list thread-id))
609              (args (if query-context
610                        (append (list "\'") basic-args (list "and (" query-context ")\'"))
611                      (append (list "\'") basic-args (list "\'")))))
612         (notmuch-show-insert-forest (notmuch-query-get-threads args))
613         ;; If the query context reduced the results to nothing, run
614         ;; the basic query.
615         (when (and (eq (buffer-size) 0)
616                    query-context)
617           (notmuch-show-insert-forest
618            (notmuch-query-get-threads basic-args))))
619
620       ;; Enable buttonisation of URLs and email addresses in the
621       ;; buffer.
622       (goto-address-mode t)
623       ;; Act on visual lines rather than logical lines.
624       (visual-line-mode t)
625
626       (run-hooks 'notmuch-show-hook))
627
628     ;; Move straight to the first open message
629     (if (not (notmuch-show-message-visible-p))
630         (notmuch-show-next-open-message))
631
632     ;; Set the header line to the subject of the first open message.
633     (setq header-line-format (notmuch-show-strip-re (notmuch-show-get-subject)))
634
635     (notmuch-show-mark-read)))
636
637 (defvar notmuch-show-stash-map
638   (let ((map (make-sparse-keymap)))
639     (define-key map "c" 'notmuch-show-stash-cc)
640     (define-key map "d" 'notmuch-show-stash-date)
641     (define-key map "F" 'notmuch-show-stash-filename)
642     (define-key map "f" 'notmuch-show-stash-from)
643     (define-key map "i" 'notmuch-show-stash-message-id)
644     (define-key map "s" 'notmuch-show-stash-subject)
645     (define-key map "T" 'notmuch-show-stash-tags)
646     (define-key map "t" 'notmuch-show-stash-to)
647     map)
648   "Submap for stash commands")
649 (fset 'notmuch-show-stash-map notmuch-show-stash-map)
650
651 (defvar notmuch-show-mode-map
652       (let ((map (make-sparse-keymap)))
653         (define-key map "?" 'notmuch-help)
654         (define-key map "q" 'notmuch-kill-this-buffer)
655         (define-key map (kbd "<C-tab>") 'widget-backward)
656         (define-key map (kbd "M-TAB") 'notmuch-show-previous-button)
657         (define-key map (kbd "<backtab>") 'notmuch-show-previous-button)
658         (define-key map (kbd "TAB") 'notmuch-show-next-button)
659         (define-key map "s" 'notmuch-search)
660         (define-key map "m" 'notmuch-mua-mail)
661         (define-key map "f" 'notmuch-show-forward-message)
662         (define-key map "r" 'notmuch-show-reply)
663         (define-key map "|" 'notmuch-show-pipe-message)
664         (define-key map "w" 'notmuch-show-save-attachments)
665         (define-key map "V" 'notmuch-show-view-raw-message)
666         (define-key map "v" 'notmuch-show-view-all-mime-parts)
667         (define-key map "c" 'notmuch-show-stash-map)
668         (define-key map "h" 'notmuch-show-toggle-headers)
669         (define-key map "-" 'notmuch-show-remove-tag)
670         (define-key map "+" 'notmuch-show-add-tag)
671         (define-key map "x" 'notmuch-show-archive-thread-then-exit)
672         (define-key map "a" 'notmuch-show-archive-thread)
673         (define-key map "N" 'notmuch-show-next-message)
674         (define-key map "P" 'notmuch-show-previous-message)
675         (define-key map "n" 'notmuch-show-next-open-message)
676         (define-key map "p" 'notmuch-show-previous-open-message)
677         (define-key map (kbd "DEL") 'notmuch-show-rewind)
678         (define-key map " " 'notmuch-show-advance-and-archive)
679         (define-key map (kbd "M-RET") 'notmuch-show-open-or-close-all)
680         (define-key map (kbd "RET") 'notmuch-show-toggle-message)
681         map)
682       "Keymap for \"notmuch show\" buffers.")
683 (fset 'notmuch-show-mode-map notmuch-show-mode-map)
684
685 (defun notmuch-show-mode ()
686   "Major mode for viewing a thread with notmuch.
687
688 This buffer contains the results of the \"notmuch show\" command
689 for displaying a single thread of email from your email archives.
690
691 By default, various components of email messages, (citations,
692 signatures, already-read messages), are hidden. You can make
693 these parts visible by clicking with the mouse button or by
694 pressing RET after positioning the cursor on a hidden part, (for
695 which \\[notmuch-show-next-button] and \\[notmuch-show-previous-button] are helpful).
696
697 Reading the thread sequentially is well-supported by pressing
698 \\[notmuch-show-advance-and-archive]. This will scroll the current message (if necessary), advance
699 to the next message, or advance to the next thread (if already on
700 the last message of a thread).
701
702 Other commands are available to read or manipulate the thread
703 more selectively, (such as '\\[notmuch-show-next-message]' and '\\[notmuch-show-previous-message]' to advance to messages
704 without removing any tags, and '\\[notmuch-show-archive-thread]' to archive an entire thread
705 without scrolling through with \\[notmuch-show-advance-and-archive]).
706
707 You can add or remove arbitary tags from the current message with
708 '\\[notmuch-show-add-tag]' or '\\[notmuch-show-remove-tag]'.
709
710 All currently available key bindings:
711
712 \\{notmuch-show-mode-map}"
713   (interactive)
714   (kill-all-local-variables)
715   (use-local-map notmuch-show-mode-map)
716   (setq major-mode 'notmuch-show-mode
717         mode-name "notmuch-show")
718   (setq buffer-read-only t))
719
720 (defun notmuch-show-move-to-message-top ()
721   (goto-char (notmuch-show-message-top)))
722
723 (defun notmuch-show-move-to-message-bottom ()
724   (goto-char (notmuch-show-message-bottom)))
725
726 (defun notmuch-show-message-adjust ()
727   (recenter 0))
728
729 ;; Movement related functions.
730
731 ;; There's some strangeness here where a text property applied to a
732 ;; region a->b is not found when point is at b. We walk backwards
733 ;; until finding the property.
734 (defun notmuch-show-message-extent ()
735   (let (r)
736     (save-excursion
737       (while (not (setq r (get-text-property (point) :notmuch-message-extent)))
738         (backward-char)))
739     r))
740
741 (defun notmuch-show-message-top ()
742   (car (notmuch-show-message-extent)))
743
744 (defun notmuch-show-message-bottom ()
745   (cdr (notmuch-show-message-extent)))
746
747 (defun notmuch-show-goto-message-next ()
748   (let ((start (point)))
749     (notmuch-show-move-to-message-bottom)
750     (if (not (eobp))
751         t
752       (goto-char start)
753       nil)))
754
755 (defun notmuch-show-goto-message-previous ()
756   (notmuch-show-move-to-message-top)
757   (if (bobp)
758       nil
759     (backward-char)
760     (notmuch-show-move-to-message-top)
761     t))
762
763 (defun notmuch-show-move-past-invisible-forward ()
764   (while (point-invisible-p)
765     (forward-char)))
766
767 (defun notmuch-show-move-past-invisible-backward ()
768   (while (point-invisible-p)
769     (backward-char)))
770
771 ;; Functions relating to the visibility of messages and their
772 ;; components.
773
774 (defun notmuch-show-element-visible (props visible-p spec-property)
775   (let ((spec (plist-get props spec-property)))
776     (if visible-p
777         (remove-from-invisibility-spec spec)
778       (add-to-invisibility-spec spec))))
779
780 (defun notmuch-show-message-visible (props visible-p)
781   (if visible-p
782       ;; When making the message visible, the headers may or not be
783       ;; visible. So we check that property separately.
784       (let ((headers-visible (plist-get props :headers-visible)))
785         (notmuch-show-element-visible props headers-visible :headers-invis-spec)
786         (notmuch-show-element-visible props t :message-invis-spec))
787     (notmuch-show-element-visible props nil :headers-invis-spec)
788     (notmuch-show-element-visible props nil :message-invis-spec))
789
790   (notmuch-show-set-prop :message-visible visible-p props))
791
792 (defun notmuch-show-headers-visible (props visible-p)
793   (if (plist-get props :message-visible)
794       (notmuch-show-element-visible props visible-p :headers-invis-spec))
795   (notmuch-show-set-prop :headers-visible visible-p props))
796
797 ;; Functions for setting and getting attributes of the current
798 ;; message.
799
800 (defun notmuch-show-set-message-properties (props)
801   (save-excursion
802     (notmuch-show-move-to-message-top)
803     (put-text-property (point) (+ (point) 1) :notmuch-message-properties props)))
804
805 (defun notmuch-show-get-message-properties ()
806   (save-excursion
807     (notmuch-show-move-to-message-top)
808     (get-text-property (point) :notmuch-message-properties)))
809
810 (defun notmuch-show-set-prop (prop val &optional props)
811   (let ((inhibit-read-only t)
812         (props (or props
813                    (notmuch-show-get-message-properties))))
814     (plist-put props prop val)
815     (notmuch-show-set-message-properties props)))
816
817 (defun notmuch-show-get-prop (prop &optional props)
818   (let ((props (or props
819                    (notmuch-show-get-message-properties))))
820     (plist-get props prop)))
821
822 (defun notmuch-show-get-message-id ()
823   "Return the message id of the current message."
824   (concat "id:\"" (notmuch-show-get-prop :id) "\""))
825
826 ;; dme: Would it make sense to use a macro for many of these?
827
828 (defun notmuch-show-get-filename ()
829   "Return the filename of the current message."
830   (notmuch-show-get-prop :filename))
831
832 (defun notmuch-show-get-header (header)
833   "Return the named header of the current message, if any."
834   (plist-get (notmuch-show-get-prop :headers) header))
835
836 (defun notmuch-show-get-cc ()
837   (notmuch-show-get-header :Cc))
838
839 (defun notmuch-show-get-date ()
840   (notmuch-show-get-header :Date))
841
842 (defun notmuch-show-get-from ()
843   (notmuch-show-get-header :From))
844
845 (defun notmuch-show-get-subject ()
846   (notmuch-show-get-header :Subject))
847
848 (defun notmuch-show-get-to ()
849   (notmuch-show-get-header :To))
850
851 (defun notmuch-show-set-tags (tags)
852   "Set the tags of the current message."
853   (notmuch-show-set-prop :tags tags)
854   (notmuch-show-update-tags tags))
855
856 (defun notmuch-show-get-tags ()
857   "Return the tags of the current message."
858   (notmuch-show-get-prop :tags))
859
860 (defun notmuch-show-message-visible-p ()
861   "Is the current message visible?"
862   (notmuch-show-get-prop :message-visible))
863
864 (defun notmuch-show-headers-visible-p ()
865   "Are the headers of the current message visible?"
866   (notmuch-show-get-prop :headers-visible))
867
868 (defun notmuch-show-mark-read ()
869   "Mark the current message as read."
870   (notmuch-show-remove-tag "unread"))
871
872 ;; Functions for getting attributes of several messages in the current
873 ;; thread.
874
875 (defun notmuch-show-get-message-ids-for-open-messages ()
876   "Return a list of all message IDs for open messages in the current thread."
877   (save-excursion
878     (let (message-ids done)
879       (goto-char (point-min))
880       (while (not done)
881         (if (notmuch-show-message-visible-p)
882             (setq message-ids (append message-ids (list (notmuch-show-get-message-id)))))
883         (setq done (not (notmuch-show-goto-message-next)))
884         )
885       message-ids
886       )))
887
888 ;; Commands typically bound to keys.
889
890 (defun notmuch-show-advance-and-archive ()
891   "Advance through thread and archive.
892
893 This command is intended to be one of the simplest ways to
894 process a thread of email. It does the following:
895
896 If the current message in the thread is not yet fully visible,
897 scroll by a near screenful to read more of the message.
898
899 Otherwise, (the end of the current message is already within the
900 current window), advance to the next open message.
901
902 Finally, if there is no further message to advance to, and this
903 last message is already read, then archive the entire current
904 thread, (remove the \"inbox\" tag from each message). Also kill
905 this buffer, and display the next thread from the search from
906 which this thread was originally shown."
907   (interactive)
908   (let ((end-of-this-message (notmuch-show-message-bottom)))
909     (cond
910      ;; Ideally we would test `end-of-this-message' against the result
911      ;; of `window-end', but that doesn't account for the fact that
912      ;; the end of the message might be hidden, so we have to actually
913      ;; go to the end, walk back over invisible text and then see if
914      ;; point is visible.
915      ((save-excursion
916         (goto-char (- end-of-this-message 1))
917         (notmuch-show-move-past-invisible-backward)
918         (> (point) (window-end)))
919       ;; The bottom of this message is not visible - scroll.
920       (scroll-up nil))
921
922      ((not (= end-of-this-message (point-max)))
923       ;; This is not the last message - move to the next visible one.
924       (notmuch-show-next-open-message))
925
926      (t
927       ;; This is the last message - archive the thread.
928       (notmuch-show-archive-thread)))))
929
930 (defun notmuch-show-rewind ()
931   "Backup through the thread, (reverse scrolling compared to \\[notmuch-show-advance-and-archive]).
932
933 Specifically, if the beginning of the previous email is fewer
934 than `window-height' lines from the current point, move to it
935 just like `notmuch-show-previous-message'.
936
937 Otherwise, just scroll down a screenful of the current message.
938
939 This command does not modify any message tags, (it does not undo
940 any effects from previous calls to
941 `notmuch-show-advance-and-archive'."
942   (interactive)
943   (let ((start-of-message (notmuch-show-message-top))
944         (start-of-window (window-start)))
945     (cond
946       ;; Either this message is properly aligned with the start of the
947       ;; window or the start of this message is not visible on the
948       ;; screen - scroll.
949      ((or (= start-of-message start-of-window)
950           (< start-of-message start-of-window))
951       (scroll-down)
952       ;; If a small number of lines from the previous message are
953       ;; visible, realign so that the top of the current message is at
954       ;; the top of the screen.
955       (if (<= (count-screen-lines (window-start) start-of-message)
956               next-screen-context-lines)
957           (progn
958             (goto-char (notmuch-show-message-top))
959             (notmuch-show-message-adjust)))
960       ;; Move to the top left of the window.
961       (goto-char (window-start)))
962      (t
963       ;; Move to the previous message.
964       (notmuch-show-previous-message)))))
965
966 (defun notmuch-show-reply ()
967   "Reply to the current message."
968   (interactive)
969   (notmuch-mua-reply (notmuch-show-get-message-id)))
970
971 (defun notmuch-show-forward-message ()
972   "Forward the current message."
973   (interactive)
974   (with-current-notmuch-show-message
975    (notmuch-mua-forward-message)))
976
977 (defun notmuch-show-next-message ()
978   "Show the next message."
979   (interactive)
980   (if (notmuch-show-goto-message-next)
981       (progn
982         (notmuch-show-mark-read)
983         (notmuch-show-message-adjust))
984     (goto-char (point-max))))
985
986 (defun notmuch-show-previous-message ()
987   "Show the previous message."
988   (interactive)
989   (notmuch-show-goto-message-previous)
990   (notmuch-show-mark-read)
991   (notmuch-show-message-adjust))
992
993 (defun notmuch-show-next-open-message ()
994   "Show the next message."
995   (interactive)
996   (let (r)
997     (while (and (setq r (notmuch-show-goto-message-next))
998                 (not (notmuch-show-message-visible-p))))
999     (if r
1000         (progn
1001           (notmuch-show-mark-read)
1002           (notmuch-show-message-adjust))
1003       (goto-char (point-max)))))
1004
1005 (defun notmuch-show-previous-open-message ()
1006   "Show the previous message."
1007   (interactive)
1008   (while (and (notmuch-show-goto-message-previous)
1009               (not (notmuch-show-message-visible-p))))
1010   (notmuch-show-mark-read)
1011   (notmuch-show-message-adjust))
1012
1013 (defun notmuch-show-view-raw-message ()
1014   "View the file holding the current message."
1015   (interactive)
1016   (let* ((id (notmuch-show-get-message-id))
1017          (buf (get-buffer-create (concat "*notmuch-raw-" id "*"))))
1018     (call-process notmuch-command nil buf nil "show" "--format=raw" id)
1019     (switch-to-buffer buf)
1020     (goto-char (point-min))
1021     (set-buffer-modified-p nil)
1022     (view-buffer buf 'kill-buffer-if-not-modified)))
1023
1024 (defun notmuch-show-pipe-message (entire-thread command)
1025   "Pipe the contents of the current message (or thread) to the given command.
1026
1027 The given command will be executed with the raw contents of the
1028 current email message as stdin. Anything printed by the command
1029 to stdout or stderr will appear in the *notmuch-pipe* buffer.
1030
1031 When invoked with a prefix argument, the command will receive all
1032 open messages in the current thread (formatted as an mbox) rather
1033 than only the current message."
1034   (interactive "P\nsPipe message to command: ")
1035   (let (shell-command)
1036     (if entire-thread
1037         (setq shell-command 
1038               (concat notmuch-command " show --format=mbox "
1039                       (shell-quote-argument
1040                        (mapconcat 'identity (notmuch-show-get-message-ids-for-open-messages) " OR "))
1041                       " | " command))
1042       (setq shell-command
1043             (concat notmuch-command " show --format=raw "
1044                     (shell-quote-argument (notmuch-show-get-message-id)) " | " command)))
1045     (let ((buf (get-buffer-create (concat "*notmuch-pipe*"))))
1046       (with-current-buffer buf
1047         (setq buffer-read-only nil)
1048         (erase-buffer)
1049         (let ((exit-code (call-process-shell-command shell-command nil buf)))
1050           (goto-char (point-max))
1051           (set-buffer-modified-p nil)
1052           (setq buffer-read-only t)
1053           (unless (zerop exit-code)
1054             (switch-to-buffer-other-window buf)
1055             (message (format "Command '%s' exited abnormally with code %d"
1056                              shell-command exit-code))))))))
1057
1058 (defun notmuch-show-add-tags-worker (current-tags add-tags)
1059   "Add to `current-tags' with any tags from `add-tags' not
1060 currently present and return the result."
1061   (let ((result-tags (copy-sequence current-tags)))
1062     (mapc (lambda (add-tag)
1063             (unless (member add-tag current-tags)
1064               (setq result-tags (push add-tag result-tags))))
1065             add-tags)
1066     (sort result-tags 'string<)))
1067
1068 (defun notmuch-show-del-tags-worker (current-tags del-tags)
1069   "Remove any tags in `del-tags' from `current-tags' and return
1070 the result."
1071   (let ((result-tags (copy-sequence current-tags)))
1072     (mapc (lambda (del-tag)
1073             (setq result-tags (delete del-tag result-tags)))
1074           del-tags)
1075     result-tags))
1076
1077 (defun notmuch-show-add-tag (&rest toadd)
1078   "Add a tag to the current message."
1079   (interactive
1080    (list (notmuch-select-tag-with-completion "Tag to add: ")))
1081
1082   (let* ((current-tags (notmuch-show-get-tags))
1083          (new-tags (notmuch-show-add-tags-worker current-tags toadd)))
1084
1085     (unless (equal current-tags new-tags)
1086       (apply 'notmuch-call-notmuch-process
1087              (append (cons "tag"
1088                            (mapcar (lambda (s) (concat "+" s)) toadd))
1089                      (cons (notmuch-show-get-message-id) nil)))
1090       (notmuch-show-set-tags new-tags))))
1091
1092 (defun notmuch-show-remove-tag (&rest toremove)
1093   "Remove a tag from the current message."
1094   (interactive
1095    (list (notmuch-select-tag-with-completion
1096           "Tag to remove: " (notmuch-show-get-message-id))))
1097
1098   (let* ((current-tags (notmuch-show-get-tags))
1099          (new-tags (notmuch-show-del-tags-worker current-tags toremove)))
1100
1101     (unless (equal current-tags new-tags)
1102       (apply 'notmuch-call-notmuch-process
1103              (append (cons "tag"
1104                            (mapcar (lambda (s) (concat "-" s)) toremove))
1105                      (cons (notmuch-show-get-message-id) nil)))
1106       (notmuch-show-set-tags new-tags))))
1107
1108 (defun notmuch-show-toggle-headers ()
1109   "Toggle the visibility of the current message headers."
1110   (interactive)
1111   (let ((props (notmuch-show-get-message-properties)))
1112     (notmuch-show-headers-visible
1113      props
1114      (not (plist-get props :headers-visible))))
1115   (force-window-update))
1116
1117 (defun notmuch-show-toggle-message ()
1118   "Toggle the visibility of the current message."
1119   (interactive)
1120   (let ((props (notmuch-show-get-message-properties)))
1121     (notmuch-show-message-visible
1122      props
1123      (not (plist-get props :message-visible))))
1124   (force-window-update))
1125
1126 (defun notmuch-show-open-or-close-all ()
1127   "Set the visibility all of the messages in the current thread.
1128 By default make all of the messages visible. With a prefix
1129 argument, hide all of the messages."
1130   (interactive)
1131   (save-excursion
1132     (goto-char (point-min))
1133     (loop do (notmuch-show-message-visible (notmuch-show-get-message-properties)
1134                                            (not current-prefix-arg))
1135           until (not (notmuch-show-goto-message-next))))
1136   (force-window-update))
1137
1138 (defun notmuch-show-next-button ()
1139   "Advance point to the next button in the buffer."
1140   (interactive)
1141   (forward-button 1))
1142
1143 (defun notmuch-show-previous-button ()
1144   "Move point back to the previous button in the buffer."
1145   (interactive)
1146   (backward-button 1))
1147
1148 (defun notmuch-show-archive-thread-internal (show-next)
1149   ;; Remove the tag from the current set of messages.
1150   (goto-char (point-min))
1151   (loop do (notmuch-show-remove-tag "inbox")
1152         until (not (notmuch-show-goto-message-next)))
1153   ;; Move to the next item in the search results, if any.
1154   (let ((parent-buffer notmuch-show-parent-buffer))
1155     (notmuch-kill-this-buffer)
1156     (if parent-buffer
1157         (progn
1158           (switch-to-buffer parent-buffer)
1159           (forward-line)
1160           (if show-next
1161               (notmuch-search-show-thread))))))
1162
1163 (defun notmuch-show-archive-thread ()
1164   "Archive each message in thread, then show next thread from search.
1165
1166 Archive each message currently shown by removing the \"inbox\"
1167 tag from each. Then kill this buffer and show the next thread
1168 from the search from which this thread was originally shown.
1169
1170 Note: This command is safe from any race condition of new messages
1171 being delivered to the same thread. It does not archive the
1172 entire thread, but only the messages shown in the current
1173 buffer."
1174   (interactive)
1175   (notmuch-show-archive-thread-internal t))
1176
1177 (defun notmuch-show-archive-thread-then-exit ()
1178   "Archive each message in thread, then exit back to search results."
1179   (interactive)
1180   (notmuch-show-archive-thread-internal nil))
1181
1182 (defun notmuch-show-stash-cc ()
1183   "Copy CC field of current message to kill-ring."
1184   (interactive)
1185   (notmuch-common-do-stash (notmuch-show-get-cc)))
1186
1187 (defun notmuch-show-stash-date ()
1188   "Copy date of current message to kill-ring."
1189   (interactive)
1190   (notmuch-common-do-stash (notmuch-show-get-date)))
1191
1192 (defun notmuch-show-stash-filename ()
1193   "Copy filename of current message to kill-ring."
1194   (interactive)
1195   (notmuch-common-do-stash (notmuch-show-get-filename)))
1196
1197 (defun notmuch-show-stash-from ()
1198   "Copy From address of current message to kill-ring."
1199   (interactive)
1200   (notmuch-common-do-stash (notmuch-show-get-from)))
1201
1202 (defun notmuch-show-stash-message-id ()
1203   "Copy message ID of current message to kill-ring."
1204   (interactive)
1205   (notmuch-common-do-stash (notmuch-show-get-message-id)))
1206
1207 (defun notmuch-show-stash-subject ()
1208   "Copy Subject field of current message to kill-ring."
1209   (interactive)
1210   (notmuch-common-do-stash (notmuch-show-get-subject)))
1211
1212 (defun notmuch-show-stash-tags ()
1213   "Copy tags of current message to kill-ring as a comma separated list."
1214   (interactive)
1215   (notmuch-common-do-stash (mapconcat 'identity (notmuch-show-get-tags) ",")))
1216
1217 (defun notmuch-show-stash-to ()
1218   "Copy To address of current message to kill-ring."
1219   (interactive)
1220   (notmuch-common-do-stash (notmuch-show-get-to)))
1221
1222 ;; Commands typically bound to buttons.
1223
1224 (defun notmuch-show-part-button-action (button)
1225   (let ((nth (button-get button :notmuch-part)))
1226     (if nth
1227         (notmuch-show-save-part (notmuch-show-get-message-id) nth
1228                                 (button-get button :notmuch-filename))
1229       (message "Not a valid part (is it a fake part?)."))))
1230
1231 ;;
1232
1233 (provide 'notmuch-show)