1 ;;; mime-view.el --- interactive MIME viewer for GNU Emacs
3 ;; Copyright (C) 1995,96,97,98,99,2000 Free Software Foundation, Inc.
5 ;; Author: MORIOKA Tomohiko <tomo@m17n.org>
7 ;; Renamed: 1994/08/31 from tm-body.el
8 ;; Renamed: 1997/02/19 from tm-view.el
9 ;; Keywords: MIME, multimedia, mail, news
11 ;; This file is part of SEMI (Sample of Elastic MIME Interfaces).
13 ;; This program is free software; you can redistribute it and/or
14 ;; modify it under the terms of the GNU General Public License as
15 ;; published by the Free Software Foundation; either version 2, or (at
16 ;; your option) any later version.
18 ;; This program is distributed in the hope that it will be useful, but
19 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 ;; General Public License for more details.
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
26 ;; Boston, MA 02111-1307, USA.
40 (defconst mime-view-version
41 (concat (mime-product-name mime-user-interface-product) " MIME-View "
42 (mapconcat #'number-to-string
43 (mime-product-version mime-user-interface-product) ".")
44 " (" (mime-product-code-name mime-user-interface-product) ")"))
50 (defgroup mime-view nil
54 (defcustom mime-situation-examples-file "~/.mime-example"
55 "*File name of situation-examples demonstrated by user."
59 (defcustom mime-preview-move-scroll nil
60 "*Decides whether to scroll when moving to next entity.
61 When t, scroll the buffer. Non-nil but not t means scroll when
62 the next entity is within next-screen-context-lines from top or
63 buttom. Nil means don't scroll at all."
65 :type '(choice (const :tag "Off" nil)
67 (sexp :tag "Situation" 1)))
69 (defcustom mime-view-mailcap-files
70 (let ((files '("/etc/mailcap" "/usr/etc/mailcap" "~/.mailcap")))
71 (or (member mime-mailcap-file files)
72 (setq files (cons mime-mailcap-file files)))
74 "List of mailcap files."
79 ;;; @ in raw-buffer (representation space)
82 (defvar mime-preview-buffer nil
83 "MIME-preview buffer corresponding with the (raw) buffer.")
84 (make-variable-buffer-local 'mime-preview-buffer)
87 (defvar mime-raw-representation-type-alist
88 '((mime-show-message-mode . binary)
89 (mime-temp-message-mode . binary)
91 "Alist of major-mode vs. representation-type of mime-raw-buffer.
92 Each element looks like (SYMBOL . REPRESENTATION-TYPE). SYMBOL is
93 major-mode or t. t means default. REPRESENTATION-TYPE must be
94 `binary' or `cooked'.")
97 ;;; @ in preview-buffer (presentation space)
100 (defvar mime-mother-buffer nil
101 "Mother buffer corresponding with the (MIME-preview) buffer.
102 If current MIME-preview buffer is generated by other buffer, such as
103 message/partial, it is called `mother-buffer'.")
104 (make-variable-buffer-local 'mime-mother-buffer)
106 ;; (defvar mime-raw-buffer nil
107 ;; "Raw buffer corresponding with the (MIME-preview) buffer.")
108 ;; (make-variable-buffer-local 'mime-raw-buffer)
110 (defvar mime-preview-original-window-configuration nil
111 "Window-configuration before mime-view-mode is called.")
112 (make-variable-buffer-local 'mime-preview-original-window-configuration)
114 (defun mime-preview-original-major-mode (&optional recursive point)
115 "Return major-mode of original buffer.
116 If optional argument RECURSIVE is non-nil and current buffer has
117 mime-mother-buffer, it returns original major-mode of the
119 (if (and recursive mime-mother-buffer)
121 (set-buffer mime-mother-buffer)
122 (mime-preview-original-major-mode recursive))
123 (cdr (assq 'major-mode
124 (get-text-property (or point
125 (if (> (point) (buffer-size))
126 (max (1- (point-max)) (point-min))
128 'mime-view-situation)))))
131 ;;; @ entity information
134 (defun mime-entity-situation (entity &optional situation)
135 "Return situation of ENTITY."
136 (let (rest param name)
138 (unless (assq 'type situation)
139 (setq rest (or (mime-entity-content-type entity)
140 (make-mime-content-type 'text 'plain))
141 situation (cons (car rest) situation)
143 (unless (assq 'subtype situation)
145 (setq rest (or (cdr (mime-entity-content-type entity))
146 '((subtype . plain)))))
147 (setq situation (cons (car rest) situation)
150 (setq param (car rest))
151 (or (assoc (car param) situation)
152 (setq situation (cons param situation)))
153 (setq rest (cdr rest)))
155 ;; Content-Disposition
157 (unless (assq 'disposition-type situation)
158 (setq rest (mime-entity-content-disposition entity))
160 (setq situation (cons (cons 'disposition-type
161 (mime-content-disposition-type rest))
163 rest (mime-content-disposition-parameters rest))))
165 (setq param (car rest)
167 (if (cond ((string= name "filename")
168 (if (assq 'filename situation)
170 (setq name 'filename)))
171 ((string= name "creation-date")
172 (if (assq 'creation-date situation)
174 (setq name 'creation-date)))
175 ((string= name "modification-date")
176 (if (assq 'modification-date situation)
178 (setq name 'modification-date)))
179 ((string= name "read-date")
180 (if (assq 'read-date situation)
182 (setq name 'read-date)))
183 ((string= name "size")
184 (if (assq 'size situation)
187 (t (setq name (cons 'disposition name))
188 (if (assoc name situation)
192 (cons (cons name (cdr param))
194 (setq rest (cdr rest)))
196 ;; Content-Transfer-Encoding
197 (or (assq 'encoding situation)
199 (cons (cons 'encoding (or (mime-entity-encoding entity)
205 (defsubst mime-delq-null-situation (situations field
206 &rest ignored-values)
209 (let* ((situation (car situations))
210 (cell (assq field situation)))
212 (or (memq (cdr cell) ignored-values)
213 (setq dest (cons situation dest)))))
214 (setq situations (cdr situations)))
217 (defun mime-compare-situation-with-example (situation example)
218 (let ((example (copy-alist example))
221 (let* ((cell (car situation))
223 (ecell (assoc key example)))
225 (if (equal cell ecell)
226 (setq match (1+ match))
227 (setq example (delq ecell example)))))
228 (setq situation (cdr situation)))
229 (cons match example)))
231 (defun mime-sort-situation (situation)
241 (disposition-type . 6)))
244 (let ((ret (assq a-t order)))
246 (setq a-order (cdr ret))
250 (let ((ret (assq b-t order)))
252 (setq b-order (cdr ret))
255 (if (= a-order b-order)
256 (string< (format "%s" a-t)(format "%s" b-t))
257 (< a-order b-order))))))
259 (defun mime-unify-situations (entity-situation
260 condition situation-examples
261 &optional required-name ignored-value
264 (in-calist-package 'mime-view)
266 (ctree-find-calist condition entity-situation
269 (setq ret (mime-delq-null-situation ret required-name
271 (or (assq 'ignore-examples entity-situation)
279 (let ((situation (car rest))
280 (examples situation-examples))
283 (mime-compare-situation-with-example
284 situation (caar examples)))
285 (ret-score (car ret)))
286 (cond ((> ret-score max-score)
287 (setq max-score ret-score
288 max-escore (cdar examples)
289 max-examples (list (cdr ret))
290 max-situations (list situation)))
291 ((= ret-score max-score)
292 (cond ((> (cdar examples) max-escore)
293 (setq max-escore (cdar examples)
294 max-examples (list (cdr ret))
295 max-situations (list situation)))
296 ((= (cdar examples) max-escore)
298 (cons (cdr ret) max-examples))
299 (or (member situation max-situations)
301 (cons situation max-situations))))))))
302 (setq examples (cdr examples))))
303 (setq rest (cdr rest)))
305 (setq ret max-situations)
307 (let* ((example (car max-examples))
309 (assoc example situation-examples)))
311 (setcdr cell (1+ (cdr cell)))
312 (setq situation-examples
313 (cons (cons example 0)
314 situation-examples))))
315 (setq max-examples (cdr max-examples)))))))
316 (cons ret situation-examples)
317 ;; ret: list of situations
318 ;; situation-examples: new examples (notoce that contents of
319 ;; argument `situation-examples' has bees modified)
322 (defun mime-view-entity-title (entity)
323 (or (mime-entity-read-field entity 'Content-Description)
324 (mime-entity-read-field entity 'Subject)
325 (mime-entity-filename entity)
328 (defvar mime-preview-situation-example-list nil)
329 (defvar mime-preview-situation-example-list-max-size 16)
330 ;; (defvar mime-preview-situation-example-condition nil)
332 (defun mime-find-entity-preview-situation (entity
333 &optional default-situation)
335 (mime-unify-situations
336 (append (mime-entity-situation entity)
338 mime-preview-condition
339 mime-preview-situation-example-list)))
340 (setq mime-preview-situation-example-list
346 (defvar mime-acting-situation-example-list nil)
347 (defvar mime-acting-situation-example-list-max-size 16)
348 (defvar mime-situation-examples-file-coding-system nil)
350 (defun mime-view-read-situation-examples-file (&optional file)
352 (setq file mime-situation-examples-file))
354 (file-readable-p file))
356 (insert-file-contents file)
357 (setq mime-situation-examples-file-coding-system
358 (and (boundp 'buffer-file-coding-system)
359 buffer-file-coding-system)
361 ;; ((boundp 'buffer-file-coding-system)
362 ;; (symbol-value 'buffer-file-coding-system))
363 ;; ((boundp 'file-coding-system)
364 ;; (symbol-value 'file-coding-system))
367 (condition-case error
369 (error (message "%s is broken: %s" file (cdr error))))
373 (while (and (> (length mime-preview-situation-example-list)
374 mime-preview-situation-example-list-max-size)
376 (setq mime-preview-situation-example-list
377 (mime-reduce-situation-examples
378 mime-preview-situation-example-list))
380 (error (setq mime-preview-situation-example-list nil)))
381 ;; (let ((rest mime-preview-situation-example-list))
383 ;; (ctree-set-calist-strictly 'mime-preview-condition
385 ;; (setq rest (cdr rest))))
388 (while (and (> (length mime-acting-situation-example-list)
389 mime-acting-situation-example-list-max-size)
391 (setq mime-acting-situation-example-list
392 (mime-reduce-situation-examples
393 mime-acting-situation-example-list))
395 (error (setq mime-acting-situation-example-list nil))))))
397 (defun mime-save-situation-examples ()
398 (if (or mime-preview-situation-example-list
399 mime-acting-situation-example-list)
400 (let ((file mime-situation-examples-file))
402 (insert ";;; " (file-name-nondirectory file) "\n")
403 (insert "\n;; This file is generated automatically by "
404 mime-view-version "\n\n")
405 (insert ";;; Code:\n\n")
406 (if mime-preview-situation-example-list
407 (pp `(setq mime-preview-situation-example-list
408 ',mime-preview-situation-example-list)
410 (if mime-acting-situation-example-list
411 (pp `(setq mime-acting-situation-example-list
412 ',mime-acting-situation-example-list)
415 (file-name-nondirectory file)
417 (setq buffer-file-coding-system
418 mime-situation-examples-file-coding-system)
420 ;; ((boundp 'buffer-file-coding-system)
421 ;; (setq buffer-file-coding-system
422 ;; mime-situation-examples-file-coding-system))
423 ;; ((boundp 'file-coding-system)
424 ;; (setq file-coding-system
425 ;; mime-situation-examples-file-coding-system)))
426 (setq buffer-file-name file)
429 (add-hook 'kill-emacs-hook 'mime-save-situation-examples)
431 (defun mime-reduce-situation-examples (situation-examples)
432 (let ((len (length situation-examples))
440 ir situation-examples)
444 jr situation-examples)
448 (setq ret (mime-compare-situation-with-example (car ic)(car jc))
450 det-ret (+ (length (car ic))(length (car jc)))
451 det-org (length (cdr ret))
452 freq (+ (cdr ic)(cdr jc)))
453 (cond ((< max-sim sim)
460 dest (cons (cdr ret) freq)))
462 (cond ((> min-det-ret det-ret)
463 (setq min-det-ret det-ret
468 dest (cons (cdr ret) freq)))
469 ((= min-det-ret det-ret)
470 (cond ((> min-det-org det-org)
471 (setq min-det-org det-org
475 dest (cons (cdr ret) freq)))
476 ((= min-det-org det-org)
477 (cond ((> min-freq freq)
481 dest (cons (cdr ret) freq)))))))))))
490 (setq jr (nthcdr (1- d-j) situation-examples))
491 (setcdr jr (cddr jr))
493 (setq situation-examples
494 (cdr situation-examples))
495 (setq ir (nthcdr (1- d-i) situation-examples))
496 (setcdr ir (cddr ir)))
497 (if (setq ir (assoc (car dest) situation-examples))
499 (setcdr ir (+ (cdr ir)(cdr dest)))
501 (cons dest situation-examples)
502 ;; situation-examples may be modified.
506 ;;; @ presentation of preview
512 ;;; @@@ predicate function
515 ;; (defun mime-view-entity-button-visible-p (entity)
516 ;; "Return non-nil if header of ENTITY is visible.
517 ;; Please redefine this function if you want to change default setting."
518 ;; (let ((media-type (mime-entity-media-type entity))
519 ;; (media-subtype (mime-entity-media-subtype entity)))
520 ;; (or (not (eq media-type 'application))
521 ;; (and (not (eq media-subtype 'x-selection))
522 ;; (or (not (eq media-subtype 'octet-stream))
523 ;; (let ((mother-entity (mime-entity-parent entity)))
524 ;; (or (not (eq (mime-entity-media-type mother-entity)
526 ;; (not (eq (mime-entity-media-subtype mother-entity)
531 ;;; @@@ entity button generator
534 (defun mime-view-insert-entity-button (entity)
535 "Insert entity-button of ENTITY."
536 (let ((entity-node-id (mime-entity-node-id entity))
537 (params (mime-entity-parameters entity))
538 (subject (mime-view-entity-title entity)))
540 (let ((access-type (assoc "access-type" params))
541 (num (or (cdr (assoc "x-part-number" params))
542 (if (consp entity-node-id)
545 (format "%s" (1+ num))))
546 (reverse entity-node-id) ".")
549 (let ((server (assoc "server" params)))
550 (setq access-type (cdr access-type))
552 (format "%s %s ([%s] %s)"
553 num subject access-type (cdr server))
554 (let ((site (cdr (assoc "site" params)))
555 (dir (cdr (assoc "directory" params)))
556 (url (cdr (assoc "url" params))))
558 (format "%s %s ([%s] %s)"
559 num subject access-type url)
560 (format "%s %s ([%s] %s:%s)"
561 num subject access-type site dir))))))
563 (let ((media-type (mime-entity-media-type entity))
564 (media-subtype (mime-entity-media-subtype entity))
565 (charset (cdr (assoc "charset" params)))
566 (encoding (mime-entity-encoding entity)))
570 (format " <%s/%s%s%s>"
571 media-type media-subtype
573 (concat "; " charset)
576 (concat " (" encoding ")")
578 (if (>= (+ (current-column)(length rest))(window-width))
581 (function mime-preview-play-current-entity))))
587 (defvar mime-header-presentation-method-alist nil
588 "Alist of major mode vs. corresponding header-presentation-method functions.
589 Each element looks like (SYMBOL . FUNCTION).
590 SYMBOL must be major mode in raw-buffer or t. t means default.
591 Interface of FUNCTION must be (ENTITY SITUATION).")
593 (defvar mime-view-ignored-field-list
594 '(".*Received:" ".*Path:" ".*Id:" "^References:"
595 "^Replied:" "^Errors-To:"
596 "^Lines:" "^Sender:" ".*Host:" "^Xref:"
597 "^Content-Type:" "^Precedence:"
598 "^Status:" "^X-VM-.*:")
599 "All fields that match this list will be hidden in MIME preview buffer.
600 Each elements are regexp of field-name.")
602 (defvar mime-view-visible-field-list '("^Dnas.*:" "^Message-Id:")
603 "All fields that match this list will be displayed in MIME preview buffer.
604 Each elements are regexp of field-name.")
610 ;;; @@@ predicate function
613 (in-calist-package 'mime-view)
615 (defun mime-calist::field-match-method-as-default-rule (calist
616 field-type field-value)
617 (let ((s-field (assq field-type calist)))
618 (cond ((null s-field)
619 (cons (cons field-type field-value) calist))
622 (define-calist-field-match-method
623 'header #'mime-calist::field-match-method-as-default-rule)
625 (define-calist-field-match-method
626 'body #'mime-calist::field-match-method-as-default-rule)
629 (defvar mime-preview-condition nil
630 "Condition-tree about how to display entity.")
632 (ctree-set-calist-strictly
633 'mime-preview-condition '((type . application)(subtype . octet-stream)
636 (ctree-set-calist-strictly
637 'mime-preview-condition '((type . application)(subtype . octet-stream)
640 (ctree-set-calist-strictly
641 'mime-preview-condition '((type . application)(subtype . octet-stream)
645 (ctree-set-calist-strictly
646 'mime-preview-condition '((type . application)(subtype . pgp)
649 (ctree-set-calist-strictly
650 'mime-preview-condition '((type . application)(subtype . x-latex)
653 (ctree-set-calist-strictly
654 'mime-preview-condition '((type . application)(subtype . x-selection)
657 (ctree-set-calist-strictly
658 'mime-preview-condition '((type . application)(subtype . x-comment)
661 (ctree-set-calist-strictly
662 'mime-preview-condition '((type . message)(subtype . delivery-status)
665 (ctree-set-calist-strictly
666 'mime-preview-condition
668 (body-presentation-method . mime-display-text/plain)))
670 (defvar mime-preview-fill-flowed-text
671 (module-installed-p 'flow-fill)
672 "If non-nil, fill RFC2646 \"flowed\" text.")
674 (autoload 'fill-flowed "flow-fill")
676 (ctree-set-calist-strictly
677 'mime-preview-condition
680 (body-presentation-method . mime-display-text/plain)))
682 (ctree-set-calist-strictly
683 'mime-preview-condition
684 '((type . text)(subtype . enriched)
686 (body-presentation-method . mime-display-text/enriched)))
688 (ctree-set-calist-strictly
689 'mime-preview-condition
690 '((type . text)(subtype . richtext)
692 (body-presentation-method . mime-display-text/richtext)))
694 (autoload 'mime-display-application/x-postpet "postpet")
696 (ctree-set-calist-strictly
697 'mime-preview-condition
698 '((type . application)(subtype . x-postpet)
700 (body-presentation-method . mime-display-application/x-postpet)))
702 (ctree-set-calist-strictly
703 'mime-preview-condition
704 '((type . text)(subtype . t)
706 (body-presentation-method . mime-display-text/plain)))
708 (ctree-set-calist-strictly
709 'mime-preview-condition
710 '((type . multipart)(subtype . alternative)
712 (body-presentation-method . mime-display-multipart/alternative)))
714 (ctree-set-calist-strictly
715 'mime-preview-condition
716 '((type . multipart)(subtype . t)
718 (body-presentation-method . mime-display-multipart/mixed)))
720 (ctree-set-calist-strictly
721 'mime-preview-condition
722 '((type . message)(subtype . partial)
724 (body-presentation-method . mime-display-message/partial-button)))
726 (ctree-set-calist-strictly
727 'mime-preview-condition
728 '((type . message)(subtype . rfc822)
730 (body-presentation-method . mime-display-multipart/mixed)
731 (childrens-situation (header . visible)
732 (entity-button . invisible))))
734 (ctree-set-calist-strictly
735 'mime-preview-condition
736 '((type . message)(subtype . news)
738 (body-presentation-method . mime-display-multipart/mixed)
739 (childrens-situation (header . visible)
740 (entity-button . invisible))))
743 ;;; @@@ entity presentation
746 (defun mime-display-text/plain (entity situation)
748 (narrow-to-region (point-max)(point-max))
750 (mime-insert-text-content entity)
752 (message "Can't decode current entity.")
754 (run-hooks 'mime-text-decode-hook)
755 (goto-char (point-max))
756 (if (not (eq (char-after (1- (point))) ?\n))
758 (if (and mime-preview-fill-flowed-text
759 (equal (cdr (assoc "format" situation)) "flowed"))
761 (mime-add-url-buttons)
762 (run-hooks 'mime-display-text/plain-hook)))
764 (defun mime-display-text/richtext (entity situation)
766 (narrow-to-region (point-max)(point-max))
767 (mime-insert-text-content entity)
768 (run-hooks 'mime-text-decode-hook)
769 (let ((beg (point-min)))
770 (remove-text-properties beg (point-max) '(face nil))
771 (richtext-decode beg (point-max)))))
773 (defun mime-display-text/enriched (entity situation)
775 (narrow-to-region (point-max)(point-max))
776 (mime-insert-text-content entity)
777 (run-hooks 'mime-text-decode-hook)
778 (let ((beg (point-min)))
779 (remove-text-properties beg (point-max) '(face nil))
780 (enriched-decode beg (point-max)))))
782 (defvar mime-view-announcement-for-message/partial
783 "This is message/partial style split message.")
785 (defun mime-display-message/partial-button (&optional entity situation)
787 (goto-char (point-max))
788 (if (not (search-backward "\n\n" nil t))
790 (goto-char (point-max))
791 (mime-insert-button mime-view-announcement-for-message/partial
792 #'mime-preview-play-current-entity)))
794 (defun mime-display-multipart/mixed (entity situation)
795 (let ((children (mime-entity-children entity))
796 (original-major-mode-cell (assq 'major-mode situation))
798 (cdr (assq 'childrens-situation situation))))
799 (if original-major-mode-cell
800 (setq default-situation
801 (cons original-major-mode-cell default-situation)))
803 (mime-display-entity (car children) nil default-situation)
804 (setq children (cdr children)))))
806 (defcustom mime-view-type-subtype-score-alist
807 '(((text . enriched) . 3)
808 ((text . richtext) . 2)
811 "Alist MEDIA-TYPE vs corresponding score.
812 MEDIA-TYPE must be (TYPE . SUBTYPE), TYPE or t. t means default."
814 :type '(repeat (cons (choice :tag "Media-Type"
815 (cons :tag "Type/Subtype"
816 (symbol :tag "Primary-type")
817 (symbol :tag "Subtype"))
819 (const :tag "Default" t))
822 (defun mime-display-multipart/alternative (entity situation)
823 (let* ((children (mime-entity-children entity))
824 (original-major-mode-cell (assq 'major-mode situation))
826 (cdr (assq 'childrens-situation situation)))
831 (if original-major-mode-cell
832 (setq default-situation
833 (cons original-major-mode-cell default-situation)))
838 (mime-find-entity-preview-situation
839 child default-situation)))
840 (if (cdr (assq 'body-presentation-method situation))
845 (cdr (assq 'type situation))
846 (cdr (assq 'subtype situation)))
847 mime-view-type-subtype-score-alist)
849 (cdr (assq 'type situation))
850 mime-view-type-subtype-score-alist)
853 mime-view-type-subtype-score-alist)))))
854 (if (> score max-score)
862 (let ((child (car children))
863 (situation (car situations)))
864 (mime-display-entity child (if (= i p)
866 (put-alist 'body 'invisible
867 (copy-alist situation)))))
868 (setq children (cdr children)
869 situations (cdr situations)
873 ;;; @ acting-condition
876 (defvar mime-acting-condition nil
877 "Condition-tree about how to process entity.")
879 (defun mime-view-read-mailcap-files (&optional files)
881 (setq files mime-view-mailcap-files))
884 (setq file (car files))
885 (if (file-readable-p file)
886 (setq entries (append entries (mime-parse-mailcap-file file))))
887 (setq files (cdr files)))
889 (let ((entry (car entries))
892 (let* ((field (car entry))
893 (field-type (car field)))
894 (cond ((eq field-type 'view) (setq view field))
895 ((eq field-type 'print) (setq print field))
896 ((memq field-type '(compose composetyped edit)))
897 (t (setq shared (cons field shared))))
899 (setq entry (cdr entry)))
900 (setq shared (nreverse shared))
901 (ctree-set-calist-with-default
902 'mime-acting-condition
903 (append shared (list '(mode . "play")(cons 'method (cdr view)))))
905 (ctree-set-calist-with-default
906 'mime-acting-condition
908 (list '(mode . "print")(cons 'method (cdr view)))))))
909 (setq entries (cdr entries)))))
911 (mime-view-read-mailcap-files)
913 (ctree-set-calist-strictly
914 'mime-acting-condition
915 '((type . application)(subtype . octet-stream)
917 (method . mime-detect-content)))
919 (ctree-set-calist-with-default
920 'mime-acting-condition
922 (method . mime-save-content)))
924 (ctree-set-calist-strictly
925 'mime-acting-condition
926 '((type . text)(subtype . x-rot13-47)(mode . "play")
927 (method . mime-view-caesar)))
928 (ctree-set-calist-strictly
929 'mime-acting-condition
930 '((type . text)(subtype . x-rot13-47-48)(mode . "play")
931 (method . mime-view-caesar)))
933 (ctree-set-calist-strictly
934 'mime-acting-condition
935 '((type . message)(subtype . rfc822)(mode . "play")
936 (method . mime-view-message/rfc822)))
937 (ctree-set-calist-strictly
938 'mime-acting-condition
939 '((type . message)(subtype . partial)(mode . "play")
940 (method . mime-store-message/partial-piece)))
942 (ctree-set-calist-strictly
943 'mime-acting-condition
944 '((type . message)(subtype . external-body)
945 ("access-type" . "anon-ftp")
946 (method . mime-view-message/external-anon-ftp)))
948 (ctree-set-calist-strictly
949 'mime-acting-condition
950 '((type . message)(subtype . external-body)
951 ("access-type" . "url")
952 (method . mime-view-message/external-url)))
954 (ctree-set-calist-strictly
955 'mime-acting-condition
956 '((type . application)(subtype . octet-stream)
957 (method . mime-save-content)))
960 ;;; @ quitting method
963 (defvar mime-preview-quitting-method-alist
964 '((mime-show-message-mode
965 . mime-preview-quitting-method-for-mime-show-message-mode))
966 "Alist of major-mode vs. quitting-method of mime-view.")
968 (defvar mime-preview-over-to-previous-method-alist nil
969 "Alist of major-mode vs. over-to-previous-method of mime-view.")
971 (defvar mime-preview-over-to-next-method-alist nil
972 "Alist of major-mode vs. over-to-next-method of mime-view.")
975 ;;; @ following method
978 (defvar mime-preview-following-method-alist nil
979 "Alist of major-mode vs. following-method of mime-view.")
981 (defvar mime-view-following-required-fields-list
988 (defun mime-display-entity (entity &optional situation
989 default-situation preview-buffer)
991 (setq preview-buffer (current-buffer)))
992 (let* (e nb ne nhb nbb)
993 (in-calist-package 'mime-view)
996 (mime-find-entity-preview-situation entity default-situation)))
997 (let ((button-is-invisible
998 (eq (cdr (or (assq '*entity-button situation)
999 (assq 'entity-button situation)))
1002 (eq (cdr (or (assq '*header situation)
1003 (assq 'header situation)))
1006 (eq (cdr (or (assq '*body situation)
1007 (assq 'body situation)))
1009 (children (mime-entity-children entity)))
1010 (set-buffer preview-buffer)
1012 (narrow-to-region nb nb)
1013 (or button-is-invisible
1014 ;; (if (mime-view-entity-button-visible-p entity)
1015 (mime-view-insert-entity-button entity)
1018 (if header-is-visible
1019 (let ((header-presentation-method
1020 (or (cdr (assq 'header-presentation-method situation))
1021 (cdr (assq (cdr (assq 'major-mode situation))
1022 mime-header-presentation-method-alist)))))
1024 (if header-presentation-method
1025 (funcall header-presentation-method entity situation)
1026 (mime-insert-header entity
1027 mime-view-ignored-field-list
1028 mime-view-visible-field-list))
1029 (mime-add-url-buttons)
1030 (run-hooks 'mime-display-header-hook)
1031 (put-text-property nhb (point-max) 'mime-view-entity-header entity)
1032 (goto-char (point-max))
1037 (let ((body-presentation-method
1038 (cdr (assq 'body-presentation-method situation))))
1039 (if (functionp body-presentation-method)
1040 (funcall body-presentation-method entity situation)
1041 (mime-display-text/plain entity situation)))
1042 (when button-is-invisible
1043 (goto-char (point-max))
1044 (mime-view-insert-entity-button entity))
1045 (unless header-is-visible
1046 (goto-char (point-max))
1048 (setq ne (point-max))
1050 (put-text-property nb ne 'mime-view-entity entity)
1051 (put-text-property nb ne 'mime-view-situation situation)
1052 (put-text-property nbb ne 'mime-view-entity-body entity)
1054 (if (and children body-is-visible)
1055 (let ((body-presentation-method
1056 (cdr (assq 'body-presentation-method situation))))
1057 (if (functionp body-presentation-method)
1058 (funcall body-presentation-method entity situation)
1059 (mime-display-multipart/mixed entity situation)))))))
1062 ;;; @ MIME viewer mode
1065 (defconst mime-view-popup-menu-list
1067 ["Move to upper entity" mime-preview-move-to-upper]
1068 ["Move to previous entity" mime-preview-move-to-previous]
1069 ["Move to next entity" mime-preview-move-to-next]
1070 ["Scroll-down" mime-preview-scroll-down-entity]
1071 ["Scroll-up" mime-preview-scroll-up-entity]
1072 ["Play current entity" mime-preview-play-current-entity]
1073 ["Extract current entity" mime-preview-extract-current-entity]
1074 ["Print current entity" mime-preview-print-current-entity])
1075 "Menu for MIME Viewer")
1077 (defun mime-view-popup-menu (event)
1078 "Popup the menu in the MIME Viewer buffer"
1080 (mime-popup-menu-popup mime-view-popup-menu-list event))
1082 ;;; The current local map is taken precendence over `widget-keymap',
1083 ;;; because GNU Emacs' widget implementation doesn't set `local-map' property.
1084 ;;; So we need to specify derivation.
1085 (defvar widget-keymap)
1086 (defun mime-view-maybe-inherit-widget-keymap ()
1087 (when (boundp 'widget-keymap)
1088 (set-keymap-parent (current-local-map) widget-keymap)))
1090 (add-hook 'mime-view-define-keymap-hook 'mime-view-maybe-inherit-widget-keymap)
1092 (defun mime-view-define-keymap (&optional default)
1093 (let ((mime-view-mode-map (if (keymapp default)
1094 (copy-keymap default)
1095 (make-sparse-keymap))))
1096 (define-key mime-view-mode-map
1097 "u" (function mime-preview-move-to-upper))
1098 (define-key mime-view-mode-map
1099 "p" (function mime-preview-move-to-previous))
1100 (define-key mime-view-mode-map
1101 "n" (function mime-preview-move-to-next))
1102 (define-key mime-view-mode-map
1103 "\e\t" (function mime-preview-move-to-previous))
1104 (define-key mime-view-mode-map
1105 "\t" (function mime-preview-move-to-next))
1106 (define-key mime-view-mode-map
1107 " " (function mime-preview-scroll-up-entity))
1108 (define-key mime-view-mode-map
1109 "\M- " (function mime-preview-scroll-down-entity))
1110 (define-key mime-view-mode-map
1111 "\177" (function mime-preview-scroll-down-entity))
1112 (define-key mime-view-mode-map
1113 "\C-m" (function mime-preview-next-line-entity))
1114 (define-key mime-view-mode-map
1115 "\C-\M-m" (function mime-preview-previous-line-entity))
1116 (define-key mime-view-mode-map
1117 "v" (function mime-preview-play-current-entity))
1118 (define-key mime-view-mode-map
1119 "e" (function mime-preview-extract-current-entity))
1120 (define-key mime-view-mode-map
1121 "\C-c\C-p" (function mime-preview-print-current-entity))
1123 (define-key mime-view-mode-map
1124 "\C-c\C-t\C-f" (function mime-preview-toggle-header))
1125 (define-key mime-view-mode-map
1126 "\C-c\C-th" (function mime-preview-toggle-header))
1127 (define-key mime-view-mode-map
1128 "\C-c\C-t\C-c" (function mime-preview-toggle-content))
1130 (define-key mime-view-mode-map
1131 "\C-c\C-v\C-f" (function mime-preview-show-header))
1132 (define-key mime-view-mode-map
1133 "\C-c\C-vh" (function mime-preview-show-header))
1134 (define-key mime-view-mode-map
1135 "\C-c\C-v\C-c" (function mime-preview-show-content))
1137 (define-key mime-view-mode-map
1138 "\C-c\C-d\C-f" (function mime-preview-hide-header))
1139 (define-key mime-view-mode-map
1140 "\C-c\C-dh" (function mime-preview-hide-header))
1141 (define-key mime-view-mode-map
1142 "\C-c\C-d\C-c" (function mime-preview-hide-content))
1144 (define-key mime-view-mode-map
1145 "a" (function mime-preview-follow-current-entity))
1146 (define-key mime-view-mode-map
1147 "q" (function mime-preview-quit))
1148 (define-key mime-view-mode-map
1149 "\C-c\C-x" (function mime-preview-kill-buffer))
1150 ;; (define-key mime-view-mode-map
1151 ;; "<" (function beginning-of-buffer))
1152 ;; (define-key mime-view-mode-map
1153 ;; ">" (function end-of-buffer))
1154 (define-key mime-view-mode-map
1155 "?" (function describe-mode))
1156 (define-key mime-view-mode-map
1157 [tab] (function mime-preview-move-to-next))
1158 (define-key mime-view-mode-map
1159 [delete] (function mime-preview-scroll-down-entity))
1160 (define-key mime-view-mode-map
1161 [backspace] (function mime-preview-scroll-down-entity))
1162 (if (functionp default)
1163 (if (featurep 'xemacs)
1164 (set-keymap-default-binding mime-view-mode-map default)
1165 (setq mime-view-mode-map
1166 (append mime-view-mode-map (list (cons t default))))))
1167 (define-key mime-view-mode-map
1168 [down-mouse-3] (function mime-view-popup-menu))
1169 ;; (run-hooks 'mime-view-define-keymap-hook)
1170 mime-view-mode-map))
1172 (defvar mime-view-mode-default-map (mime-view-define-keymap))
1175 (defsubst mime-maybe-hide-echo-buffer ()
1176 "Clear mime-echo buffer and delete window for it."
1177 (let ((buf (get-buffer mime-echo-buffer-name)))
1182 (let ((win (get-buffer-window buf)))
1184 (delete-window win)))
1185 (bury-buffer buf)))))
1187 (defvar mime-view-redisplay nil)
1190 (defun mime-display-message (message &optional preview-buffer
1191 mother default-keymap-or-function
1192 original-major-mode keymap)
1193 "View MESSAGE in MIME-View mode.
1195 Optional argument PREVIEW-BUFFER specifies the buffer of the
1196 presentation. It must be either nil or a name of preview buffer.
1198 Optional argument MOTHER specifies mother-buffer of the preview-buffer.
1200 Optional argument DEFAULT-KEYMAP-OR-FUNCTION is nil, keymap or
1201 function. If it is a keymap, keymap of MIME-View mode will be added
1202 to it. If it is a function, it will be bound as default binding of
1203 keymap of MIME-View mode.
1205 Optional argument ORIGINAL-MAJOR-MODE is major-mode of representation
1206 buffer of MESSAGE. If it is nil, current `major-mode' is used.
1208 Optional argument KEYMAP is keymap of MIME-View mode. If it is
1209 non-nil, DEFAULT-KEYMAP-OR-FUNCTION is ignored. If it is nil,
1210 `mime-view-mode-default-map' is used."
1211 (mime-maybe-hide-echo-buffer)
1212 (let ((win-conf (current-window-configuration)))
1214 (setq preview-buffer
1215 (concat "*Preview-" (mime-entity-name message) "*")))
1216 (or original-major-mode
1217 (setq original-major-mode major-mode))
1218 (let ((inhibit-read-only t))
1219 (set-buffer (get-buffer-create preview-buffer))
1223 (setq mime-mother-buffer mother))
1224 (setq mime-preview-original-window-configuration win-conf)
1225 (setq major-mode 'mime-view-mode)
1226 (setq mode-name "MIME-View")
1227 (mime-display-entity message nil
1228 `((entity-button . invisible)
1230 (major-mode . ,original-major-mode))
1234 (if default-keymap-or-function
1235 (mime-view-define-keymap default-keymap-or-function)
1236 mime-view-mode-default-map)))
1238 (next-single-property-change (point-min) 'mime-view-entity)))
1241 (goto-char (point-min))
1242 (search-forward "\n\n" nil t)))
1243 (run-hooks 'mime-view-mode-hook)
1244 (set-buffer-modified-p nil)
1245 (setq buffer-read-only t)
1249 (defun mime-view-buffer (&optional raw-buffer preview-buffer mother
1250 default-keymap-or-function
1251 representation-type)
1252 "View RAW-BUFFER in MIME-View mode.
1253 Optional argument PREVIEW-BUFFER is either nil or a name of preview
1255 Optional argument DEFAULT-KEYMAP-OR-FUNCTION is nil, keymap or
1256 function. If it is a keymap, keymap of MIME-View mode will be added
1257 to it. If it is a function, it will be bound as default binding of
1258 keymap of MIME-View mode.
1259 Optional argument REPRESENTATION-TYPE is representation-type of
1260 message. It must be nil, `binary' or `cooked'. If it is nil,
1261 `cooked' is used as default."
1264 (setq raw-buffer (current-buffer)))
1265 (or representation-type
1266 (setq representation-type
1268 (set-buffer raw-buffer)
1269 (cdr (or (assq major-mode mime-raw-representation-type-alist)
1270 (assq t mime-raw-representation-type-alist))))))
1271 (if (eq representation-type 'binary)
1272 (setq representation-type 'buffer))
1273 (setq preview-buffer (mime-display-message
1274 (mime-open-entity representation-type raw-buffer)
1275 preview-buffer mother default-keymap-or-function))
1276 (or (get-buffer-window preview-buffer)
1277 (let ((r-win (get-buffer-window raw-buffer)))
1279 (set-window-buffer r-win preview-buffer)
1280 (let ((m-win (and mother (get-buffer-window mother))))
1282 (set-window-buffer m-win preview-buffer)
1283 (switch-to-buffer preview-buffer)))))))
1285 (defun mime-view-mode (&optional mother ctl encoding
1286 raw-buffer preview-buffer
1287 default-keymap-or-function)
1288 "Major mode for viewing MIME message.
1290 Here is a list of the standard keys for mime-view-mode.
1295 u Move to upper content
1296 p or M-TAB Move to previous content
1297 n or TAB Move to next content
1298 SPC Scroll up or move to next content
1299 M-SPC or DEL Scroll down or move to previous content
1300 RET Move to next line
1301 M-RET Move to previous line
1302 v Decode current content as `play mode'
1303 e Decode current content as `extract mode'
1304 C-c C-p Decode current content as `print mode'
1305 a Followup to current content.
1307 button-2 Move to point under the mouse cursor
1308 and decode current content as `play mode'
1311 (unless mime-view-redisplay
1313 (if raw-buffer (set-buffer raw-buffer))
1316 (or (assq major-mode mime-raw-representation-type-alist)
1317 (assq t mime-raw-representation-type-alist)))))
1318 (if (eq type 'binary)
1319 (setq type 'buffer))
1320 (setq mime-message-structure (mime-open-entity type raw-buffer))
1321 (or (mime-entity-content-type mime-message-structure)
1322 (mime-entity-set-content-type mime-message-structure ctl)))
1323 (or (mime-entity-encoding mime-message-structure)
1324 (mime-entity-set-encoding mime-message-structure encoding))))
1325 (mime-display-message mime-message-structure preview-buffer
1326 mother default-keymap-or-function))
1332 (defun mime-preview-find-boundary-info (&optional get-mother)
1336 (while (null (setq entity
1337 (get-text-property (point) 'mime-view-entity)))
1339 (setq p-beg (previous-single-property-change (point) 'mime-view-entity))
1340 (setq entity-node-id (mime-entity-node-id entity))
1341 (setq len (length entity-node-id))
1344 (if (eq (next-single-property-change (point-min)
1349 ((eq (next-single-property-change p-beg 'mime-view-entity)
1351 (setq p-beg (point))))
1352 (setq p-end (next-single-property-change p-beg 'mime-view-entity))
1354 (setq p-end (point-max)))
1355 ((null entity-node-id)
1356 (setq p-end (point-max)))
1363 (next-single-property-change
1364 (point) 'mime-view-entity))
1366 (let ((rc (mime-entity-node-id
1367 (get-text-property (1- (point))
1368 'mime-view-entity))))
1369 (or (and (>= (setq i (- (length rc) len)) 0)
1370 (equal entity-node-id (nthcdr i rc)))
1373 (setq p-end (point-max))))))
1374 (vector p-beg p-end entity)))
1380 (autoload 'mime-preview-play-current-entity "mime-play"
1381 "Play current entity." t)
1383 (defun mime-preview-extract-current-entity (&optional ignore-examples)
1384 "Extract current entity into file (maybe).
1385 It decodes current entity to call internal or external method as
1386 \"extract\" mode. The method is selected from variable
1387 `mime-acting-condition'."
1389 (mime-preview-play-current-entity ignore-examples "extract"))
1391 (defun mime-preview-print-current-entity (&optional ignore-examples)
1392 "Print current entity (maybe).
1393 It decodes current entity to call internal or external method as
1394 \"print\" mode. The method is selected from variable
1395 `mime-acting-condition'."
1397 (mime-preview-play-current-entity ignore-examples "print"))
1403 (defun mime-preview-follow-current-entity ()
1404 "Write follow message to current entity.
1405 It calls following-method selected from variable
1406 `mime-preview-following-method-alist'."
1408 (let ((entity (mime-preview-find-boundary-info t))
1411 (setq p-beg (aref entity 0)
1412 p-end (aref entity 1)
1413 entity (aref entity 2))
1414 (if (get-text-property p-beg 'mime-view-entity-body)
1417 (next-single-property-change
1418 p-beg 'mime-view-entity-body nil
1419 (or (next-single-property-change p-beg 'mime-view-entity)
1421 (let* ((mode (mime-preview-original-major-mode 'recursive))
1422 (entity-node-id (mime-entity-node-id entity))
1424 (format "%s-%s" (buffer-name) (reverse entity-node-id)))
1426 (the-buf (current-buffer))
1429 (set-buffer (setq new-buf (get-buffer-create new-name)))
1432 (insert-buffer-substring the-buf pb-beg p-end)
1433 (goto-char (point-min))
1434 (let ((current-entity
1435 (if (and (eq (mime-entity-media-type entity) 'message)
1436 (eq (mime-entity-media-subtype entity) 'rfc822))
1437 (car (mime-entity-children entity))
1439 (while (and current-entity
1440 (if (and (eq (mime-entity-media-type
1441 current-entity) 'message)
1442 (eq (mime-entity-media-subtype
1443 current-entity) 'rfc822))
1445 (mime-insert-header current-entity fields)
1447 (setq fields (std11-collect-field-names)
1448 current-entity (mime-entity-parent current-entity))))
1449 (let ((rest mime-view-following-required-fields-list)
1452 (setq field-name (car rest))
1453 (or (std11-field-body field-name)
1456 (set-buffer the-buf)
1457 (let ((entity (when mime-mother-buffer
1458 (set-buffer mime-mother-buffer)
1459 (get-text-property (point)
1460 'mime-view-entity))))
1462 (null (setq ret (mime-entity-fetch-field
1463 entity field-name))))
1464 (setq entity (mime-entity-parent entity)))))
1466 (insert (concat field-name ": " ret "\n")))))
1467 (setq rest (cdr rest)))))
1468 (let ((f (cdr (assq mode mime-preview-following-method-alist))))
1473 "Sorry, following method for %s is not implemented yet."
1480 (defun mime-preview-move-to-upper ()
1481 "Move to upper entity.
1482 If there is no upper entity, call function `mime-preview-quit'."
1485 (while (null (setq cinfo
1486 (get-text-property (point) 'mime-view-entity)))
1488 (let ((r (mime-entity-parent cinfo))
1491 (while (setq point (previous-single-property-change
1492 (point) 'mime-view-entity))
1494 (when (eq r (get-text-property (point) 'mime-view-entity))
1495 (if (or (eq mime-preview-move-scroll t)
1496 (and mime-preview-move-scroll
1499 (move-to-window-line -1)
1500 (forward-line (* -1 next-screen-context-lines))
1503 (recenter next-screen-context-lines))
1505 (mime-preview-quit)))))
1507 (defun mime-preview-move-to-previous ()
1508 "Move to previous entity.
1509 If there is no previous entity, it calls function registered in
1510 variable `mime-preview-over-to-previous-method-alist'."
1512 (while (and (not (bobp))
1513 (null (get-text-property (point) 'mime-view-entity)))
1515 (let ((point (previous-single-property-change (point) 'mime-view-entity)))
1517 (>= point (point-min)))
1518 (if (get-text-property (1- point) 'mime-view-entity)
1519 (progn (goto-char point)
1521 (or (eq mime-preview-move-scroll t)
1522 (and mime-preview-move-scroll
1525 (move-to-window-line 0)
1526 (forward-line next-screen-context-lines)
1529 (recenter (* -1 next-screen-context-lines))))
1530 (goto-char (1- point))
1531 (mime-preview-move-to-previous))
1532 (let ((f (assq (mime-preview-original-major-mode)
1533 mime-preview-over-to-previous-method-alist)))
1535 (funcall (cdr f)))))))
1537 (defun mime-preview-move-to-next ()
1538 "Move to next entity.
1539 If there is no previous entity, it calls function registered in
1540 variable `mime-preview-over-to-next-method-alist'."
1542 (while (and (not (eobp))
1543 (null (get-text-property (point) 'mime-view-entity)))
1545 (let ((point (next-single-property-change (point) 'mime-view-entity)))
1547 (<= point (point-max)))
1550 (if (null (get-text-property point 'mime-view-entity))
1551 (mime-preview-move-to-next)
1553 (or (eq mime-preview-move-scroll t)
1554 (and mime-preview-move-scroll
1557 (move-to-window-line -1)
1559 (* -1 next-screen-context-lines))
1562 (recenter next-screen-context-lines))))
1563 (let ((f (assq (mime-preview-original-major-mode)
1564 mime-preview-over-to-next-method-alist)))
1566 (funcall (cdr f)))))))
1568 (defun mime-preview-scroll-up-entity (&optional h)
1569 "Scroll up current entity.
1570 If reached to (point-max), it calls function registered in variable
1571 `mime-preview-over-to-next-method-alist'."
1574 (let ((f (assq (mime-preview-original-major-mode)
1575 mime-preview-over-to-next-method-alist)))
1579 (or (next-single-property-change (point) 'mime-view-entity)
1581 (bottom (window-end (selected-window))))
1584 (progn (goto-char point)
1585 (recenter next-screen-context-lines))
1589 (goto-char (point-max))))))))
1591 (defun mime-preview-scroll-down-entity (&optional h)
1592 "Scroll down current entity.
1593 If reached to (point-min), it calls function registered in variable
1594 `mime-preview-over-to-previous-method-alist'."
1597 (let ((f (assq (mime-preview-original-major-mode)
1598 mime-preview-over-to-previous-method-alist)))
1602 (or (previous-single-property-change (point) 'mime-view-entity)
1604 (top (window-start (selected-window))))
1607 (progn (goto-char point)
1608 (recenter (* -1 next-screen-context-lines)))
1611 (beginning-of-buffer
1612 (goto-char (point-min))))))))
1614 (defun mime-preview-next-line-entity (&optional lines)
1615 "Scroll up one line (or prefix LINES lines).
1616 If LINES is negative, scroll down LINES lines."
1618 (mime-preview-scroll-up-entity (or lines 1)))
1620 (defun mime-preview-previous-line-entity (&optional lines)
1621 "Scrroll down one line (or prefix LINES lines).
1622 If LINES is negative, scroll up LINES lines."
1624 (mime-preview-scroll-down-entity (or lines 1)))
1630 (defun mime-preview-toggle-display (type &optional display)
1631 (let ((situation (mime-preview-find-boundary-info))
1632 (sym (intern (concat "*" (symbol-name type))))
1634 (setq p-beg (aref situation 0)
1635 p-end (aref situation 1)
1636 entity (aref situation 2)
1637 situation (get-text-property p-beg 'mime-view-situation))
1638 (cond ((eq display 'invisible)
1643 (eq (cdr (or (assq sym situation)
1644 (assq type situation)))
1646 (setq situation (put-alist sym (if display
1651 (let ((inhibit-read-only t))
1652 (delete-region p-beg p-end)
1653 (mime-display-entity entity situation)))
1654 (let ((ret (assoc situation mime-preview-situation-example-list)))
1656 (setcdr ret (1+ (cdr ret)))
1657 (add-to-list 'mime-preview-situation-example-list
1658 (cons situation 0))))))
1660 (defun mime-preview-toggle-header (&optional force-visible)
1662 (mime-preview-toggle-display 'header force-visible))
1664 (defun mime-preview-toggle-content (&optional force-visible)
1666 (mime-preview-toggle-display 'body force-visible))
1668 (defun mime-preview-show-header ()
1670 (mime-preview-toggle-display 'header 'visible))
1672 (defun mime-preview-show-content ()
1674 (mime-preview-toggle-display 'body 'visible))
1676 (defun mime-preview-hide-header ()
1678 (mime-preview-toggle-display 'header 'invisible))
1680 (defun mime-preview-hide-content ()
1682 (mime-preview-toggle-display 'body 'invisible))
1688 (defun mime-preview-quit ()
1689 "Quit from MIME-preview buffer.
1690 It calls function registered in variable
1691 `mime-preview-quitting-method-alist'."
1693 (let ((r (assq (mime-preview-original-major-mode)
1694 mime-preview-quitting-method-alist)))
1696 (funcall (cdr r)))))
1698 (defun mime-preview-kill-buffer ()
1700 (kill-buffer (current-buffer)))
1706 (provide 'mime-view)
1709 (setq mime-situation-examples-file nil)
1710 ;; to avoid to read situation-examples-file at compile time.
1713 (mime-view-read-situation-examples-file)
1715 ;;; mime-view.el ends here