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)))
70 ;;; @ in raw-buffer (representation space)
73 (defvar mime-preview-buffer nil
74 "MIME-preview buffer corresponding with the (raw) buffer.")
75 (make-variable-buffer-local 'mime-preview-buffer)
78 (defvar mime-raw-representation-type-alist
79 '((mime-show-message-mode . binary)
80 (mime-temp-message-mode . binary)
83 "Alist of major-mode vs. representation-type of mime-raw-buffer.
84 Each element looks like (SYMBOL . REPRESENTATION-TYPE). SYMBOL is
85 major-mode or t. t means default. REPRESENTATION-TYPE must be
86 `binary' or `cooked'.")
89 ;;; @ in preview-buffer (presentation space)
92 (defvar mime-mother-buffer nil
93 "Mother buffer corresponding with the (MIME-preview) buffer.
94 If current MIME-preview buffer is generated by other buffer, such as
95 message/partial, it is called `mother-buffer'.")
96 (make-variable-buffer-local 'mime-mother-buffer)
98 ;; (defvar mime-raw-buffer nil
99 ;; "Raw buffer corresponding with the (MIME-preview) buffer.")
100 ;; (make-variable-buffer-local 'mime-raw-buffer)
102 (defvar mime-preview-original-window-configuration nil
103 "Window-configuration before mime-view-mode is called.")
104 (make-variable-buffer-local 'mime-preview-original-window-configuration)
106 (defun mime-preview-original-major-mode (&optional recursive point)
107 "Return major-mode of original buffer.
108 If optional argument RECURSIVE is non-nil and current buffer has
109 mime-mother-buffer, it returns original major-mode of the
111 (if (and recursive mime-mother-buffer)
113 (set-buffer mime-mother-buffer)
114 (mime-preview-original-major-mode recursive)
116 (cdr (assq 'major-mode
117 (get-text-property (or point
118 (if (> (point) (buffer-size))
119 (max (1- (point-max)) (point-min))
121 'mime-view-situation)))))
124 ;;; @ entity information
127 (defun mime-entity-situation (entity &optional situation)
128 "Return situation of ENTITY."
129 (let (rest param name)
131 (unless (assq 'type situation)
132 (setq rest (or (mime-entity-content-type entity)
133 (make-mime-content-type 'text 'plain))
134 situation (cons (car rest) situation)
137 (unless (assq 'subtype situation)
139 (setq rest (or (cdr (mime-entity-content-type entity))
140 '((subtype . plain)))))
141 (setq situation (cons (car rest) situation)
145 (setq param (car rest))
146 (or (assoc (car param) situation)
147 (setq situation (cons param situation)))
148 (setq rest (cdr rest)))
150 ;; Content-Disposition
152 (unless (assq 'disposition-type situation)
153 (setq rest (mime-entity-content-disposition entity))
155 (setq situation (cons (cons 'disposition-type
156 (mime-content-disposition-type rest))
158 rest (mime-content-disposition-parameters rest))
161 (setq param (car rest)
163 (if (cond ((string= name "filename")
164 (if (assq 'filename situation)
166 (setq name 'filename)))
167 ((string= name "creation-date")
168 (if (assq 'creation-date situation)
170 (setq name 'creation-date)))
171 ((string= name "modification-date")
172 (if (assq 'modification-date situation)
174 (setq name 'modification-date)))
175 ((string= name "read-date")
176 (if (assq 'read-date situation)
178 (setq name 'read-date)))
179 ((string= name "size")
180 (if (assq 'size situation)
183 (t (setq name (cons 'disposition name))
184 (if (assoc name situation)
188 (cons (cons name (cdr param))
190 (setq rest (cdr rest)))
192 ;; Content-Transfer-Encoding
193 (or (assq 'encoding situation)
195 (cons (cons 'encoding (or (mime-entity-encoding entity)
201 (defsubst mime-delq-null-situation (situations field
202 &rest ignored-values)
205 (let* ((situation (car situations))
206 (cell (assq field situation)))
208 (or (memq (cdr cell) ignored-values)
209 (setq dest (cons situation dest))
211 (setq situations (cdr situations)))
214 (defun mime-compare-situation-with-example (situation example)
215 (let ((example (copy-alist example))
218 (let* ((cell (car situation))
220 (ecell (assoc key example)))
222 (if (equal cell ecell)
223 (setq match (1+ match))
224 (setq example (delq ecell example))
227 (setq situation (cdr situation))
232 (defun mime-sort-situation (situation)
242 (disposition-type . 6)
246 (let ((ret (assq a-t order)))
248 (setq a-order (cdr ret))
254 (let ((ret (assq b-t order)))
256 (setq b-order (cdr ret))
261 (if (= a-order b-order)
262 (string< (format "%s" a-t)(format "%s" b-t))
267 (defun mime-unify-situations (entity-situation
268 condition situation-examples
269 &optional required-name ignored-value
272 (in-calist-package 'mime-view)
274 (ctree-find-calist condition entity-situation
277 (setq ret (mime-delq-null-situation ret required-name
279 (or (assq 'ignore-examples entity-situation)
287 (let ((situation (car rest))
288 (examples situation-examples))
291 (mime-compare-situation-with-example
292 situation (caar examples)))
293 (ret-score (car ret)))
294 (cond ((> ret-score max-score)
295 (setq max-score ret-score
296 max-escore (cdar examples)
297 max-examples (list (cdr ret))
298 max-situations (list situation))
300 ((= ret-score max-score)
301 (cond ((> (cdar examples) max-escore)
302 (setq max-escore (cdar examples)
303 max-examples (list (cdr ret))
304 max-situations (list situation))
306 ((= (cdar examples) max-escore)
308 (cons (cdr ret) max-examples))
309 (or (member situation max-situations)
311 (cons situation max-situations)))
313 (setq examples (cdr examples))))
314 (setq rest (cdr rest)))
316 (setq ret max-situations)
318 (let* ((example (car max-examples))
320 (assoc example situation-examples)))
322 (setcdr cell (1+ (cdr cell)))
323 (setq situation-examples
324 (cons (cons example 0)
327 (setq max-examples (cdr max-examples))
329 (cons ret situation-examples)
330 ;; ret: list of situations
331 ;; situation-examples: new examples (notoce that contents of
332 ;; argument `situation-examples' has bees modified)
335 (defun mime-view-entity-title (entity)
336 (or (mime-entity-read-field entity 'Content-Description)
337 (mime-entity-read-field entity 'Subject)
338 (mime-entity-filename entity)
341 (defvar mime-preview-situation-example-list nil)
342 (defvar mime-preview-situation-example-list-max-size 16)
343 ;; (defvar mime-preview-situation-example-condition nil)
345 (defun mime-find-entity-preview-situation (entity
346 &optional default-situation)
348 (mime-unify-situations
349 (append (mime-entity-situation entity)
351 mime-preview-condition
352 mime-preview-situation-example-list)))
353 (setq mime-preview-situation-example-list
359 (defvar mime-acting-situation-example-list nil)
360 (defvar mime-acting-situation-example-list-max-size 16)
361 (defvar mime-situation-examples-file-coding-system nil)
363 (defun mime-view-read-situation-examples-file (&optional file)
365 (setq file mime-situation-examples-file))
366 (if (file-readable-p file)
368 (insert-file-contents file)
369 (setq mime-situation-examples-file-coding-system
370 (and (boundp 'buffer-file-coding-system)
371 buffer-file-coding-system)
373 ;; ((boundp 'buffer-file-coding-system)
374 ;; (symbol-value 'buffer-file-coding-system))
375 ;; ((boundp 'file-coding-system)
376 ;; (symbol-value 'file-coding-system))
385 (while (and (> (length mime-preview-situation-example-list)
386 mime-preview-situation-example-list-max-size)
388 (setq mime-preview-situation-example-list
389 (mime-reduce-situation-examples
390 mime-preview-situation-example-list))
392 (error (setq mime-preview-situation-example-list nil)))
393 ;; (let ((rest mime-preview-situation-example-list))
395 ;; (ctree-set-calist-strictly 'mime-preview-condition
397 ;; (setq rest (cdr rest))))
400 (while (and (> (length mime-acting-situation-example-list)
401 mime-acting-situation-example-list-max-size)
403 (setq mime-acting-situation-example-list
404 (mime-reduce-situation-examples
405 mime-acting-situation-example-list))
407 (error (setq mime-acting-situation-example-list nil))))))
409 (defun mime-save-situation-examples ()
410 (if (or mime-preview-situation-example-list
411 mime-acting-situation-example-list)
412 (let ((file mime-situation-examples-file))
414 (insert ";;; " (file-name-nondirectory file) "\n")
415 (insert "\n;; This file is generated automatically by "
416 mime-view-version "\n\n")
417 (insert ";;; Code:\n\n")
418 (if mime-preview-situation-example-list
419 (pp `(setq mime-preview-situation-example-list
420 ',mime-preview-situation-example-list)
422 (if mime-acting-situation-example-list
423 (pp `(setq mime-acting-situation-example-list
424 ',mime-acting-situation-example-list)
427 (file-name-nondirectory file)
429 (setq buffer-file-coding-system
430 mime-situation-examples-file-coding-system)
432 ;; ((boundp 'buffer-file-coding-system)
433 ;; (setq buffer-file-coding-system
434 ;; mime-situation-examples-file-coding-system))
435 ;; ((boundp 'file-coding-system)
436 ;; (setq file-coding-system
437 ;; mime-situation-examples-file-coding-system)))
438 (setq buffer-file-name file)
441 (add-hook 'kill-emacs-hook 'mime-save-situation-examples)
443 (defun mime-reduce-situation-examples (situation-examples)
444 (let ((len (length situation-examples))
452 ir situation-examples)
456 jr situation-examples)
460 (setq ret (mime-compare-situation-with-example (car ic)(car jc))
462 det-ret (+ (length (car ic))(length (car jc)))
463 det-org (length (cdr ret))
464 freq (+ (cdr ic)(cdr jc)))
465 (cond ((< max-sim sim)
472 dest (cons (cdr ret) freq))
475 (cond ((> min-det-ret det-ret)
476 (setq min-det-ret det-ret
481 dest (cons (cdr ret) freq))
483 ((= min-det-ret det-ret)
484 (cond ((> min-det-org det-org)
485 (setq min-det-org det-org
489 dest (cons (cdr ret) freq))
491 ((= min-det-org det-org)
492 (cond ((> min-freq freq)
496 dest (cons (cdr ret) freq))
510 (setq jr (nthcdr (1- d-j) situation-examples))
511 (setcdr jr (cddr jr))
513 (setq situation-examples
514 (cdr situation-examples))
515 (setq ir (nthcdr (1- d-i) situation-examples))
516 (setcdr ir (cddr ir))
518 (if (setq ir (assoc (car dest) situation-examples))
520 (setcdr ir (+ (cdr ir)(cdr dest)))
522 (cons dest situation-examples)
523 ;; situation-examples may be modified.
527 ;;; @ presentation of preview
533 ;;; @@@ predicate function
536 ;; (defun mime-view-entity-button-visible-p (entity)
537 ;; "Return non-nil if header of ENTITY is visible.
538 ;; Please redefine this function if you want to change default setting."
539 ;; (let ((media-type (mime-entity-media-type entity))
540 ;; (media-subtype (mime-entity-media-subtype entity)))
541 ;; (or (not (eq media-type 'application))
542 ;; (and (not (eq media-subtype 'x-selection))
543 ;; (or (not (eq media-subtype 'octet-stream))
544 ;; (let ((mother-entity (mime-entity-parent entity)))
545 ;; (or (not (eq (mime-entity-media-type mother-entity)
547 ;; (not (eq (mime-entity-media-subtype mother-entity)
552 ;;; @@@ entity button generator
555 (defun mime-view-insert-entity-button (entity)
556 "Insert entity-button of ENTITY."
557 (let ((entity-node-id (mime-entity-node-id entity))
558 (params (mime-entity-parameters entity))
559 (subject (mime-view-entity-title entity)))
561 (let ((access-type (assoc "access-type" params))
562 (num (or (cdr (assoc "x-part-number" params))
563 (if (consp entity-node-id)
566 (format "%s" (1+ num))
568 (reverse entity-node-id) ".")
572 (let ((server (assoc "server" params)))
573 (setq access-type (cdr access-type))
575 (format "%s %s ([%s] %s)"
576 num subject access-type (cdr server))
577 (let ((site (cdr (assoc "site" params)))
578 (dir (cdr (assoc "directory" params)))
579 (url (cdr (assoc "url" params)))
582 (format "%s %s ([%s] %s)"
583 num subject access-type url)
584 (format "%s %s ([%s] %s:%s)"
585 num subject access-type site dir))
589 (let ((media-type (mime-entity-media-type entity))
590 (media-subtype (mime-entity-media-subtype entity))
591 (charset (cdr (assoc "charset" params)))
592 (encoding (mime-entity-encoding entity)))
596 (format " <%s/%s%s%s>"
597 media-type media-subtype
599 (concat "; " charset)
602 (concat " (" encoding ")")
604 (if (>= (+ (current-column)(length rest))(window-width))
608 (function mime-preview-play-current-entity))
615 (defvar mime-header-presentation-method-alist nil
616 "Alist of major mode vs. corresponding header-presentation-method functions.
617 Each element looks like (SYMBOL . FUNCTION).
618 SYMBOL must be major mode in raw-buffer or t. t means default.
619 Interface of FUNCTION must be (ENTITY SITUATION).")
621 (defvar mime-view-ignored-field-list
622 '(".*Received:" ".*Path:" ".*Id:" "^References:"
623 "^Replied:" "^Errors-To:"
624 "^Lines:" "^Sender:" ".*Host:" "^Xref:"
625 "^Content-Type:" "^Precedence:"
626 "^Status:" "^X-VM-.*:")
627 "All fields that match this list will be hidden in MIME preview buffer.
628 Each elements are regexp of field-name.")
630 (defvar mime-view-visible-field-list '("^Dnas.*:" "^Message-Id:")
631 "All fields that match this list will be displayed in MIME preview buffer.
632 Each elements are regexp of field-name.")
638 ;;; @@@ predicate function
641 (in-calist-package 'mime-view)
643 (defun mime-calist::field-match-method-as-default-rule (calist
644 field-type field-value)
645 (let ((s-field (assq field-type calist)))
646 (cond ((null s-field)
647 (cons (cons field-type field-value) calist)
651 (define-calist-field-match-method
652 'header #'mime-calist::field-match-method-as-default-rule)
654 (define-calist-field-match-method
655 'body #'mime-calist::field-match-method-as-default-rule)
658 (defvar mime-preview-condition nil
659 "Condition-tree about how to display entity.")
661 (ctree-set-calist-strictly
662 'mime-preview-condition '((type . application)(subtype . octet-stream)
665 (ctree-set-calist-strictly
666 'mime-preview-condition '((type . application)(subtype . octet-stream)
669 (ctree-set-calist-strictly
670 'mime-preview-condition '((type . application)(subtype . octet-stream)
674 (ctree-set-calist-strictly
675 'mime-preview-condition '((type . application)(subtype . pgp)
678 (ctree-set-calist-strictly
679 'mime-preview-condition '((type . application)(subtype . x-latex)
682 (ctree-set-calist-strictly
683 'mime-preview-condition '((type . application)(subtype . x-selection)
686 (ctree-set-calist-strictly
687 'mime-preview-condition '((type . application)(subtype . x-comment)
690 (ctree-set-calist-strictly
691 'mime-preview-condition '((type . message)(subtype . delivery-status)
694 (ctree-set-calist-strictly
695 'mime-preview-condition
697 (body-presentation-method . mime-display-text/plain)))
699 (ctree-set-calist-strictly
700 'mime-preview-condition
703 (body-presentation-method . mime-display-text/plain)))
705 (ctree-set-calist-strictly
706 'mime-preview-condition
707 '((type . text)(subtype . enriched)
709 (body-presentation-method . mime-display-text/enriched)))
711 (ctree-set-calist-strictly
712 'mime-preview-condition
713 '((type . text)(subtype . richtext)
715 (body-presentation-method . mime-display-text/richtext)))
717 (autoload 'mime-display-application/x-postpet "postpet")
719 (ctree-set-calist-strictly
720 'mime-preview-condition
721 '((type . application)(subtype . x-postpet)
723 (body-presentation-method . mime-display-application/x-postpet)))
725 (ctree-set-calist-strictly
726 'mime-preview-condition
727 '((type . text)(subtype . t)
729 (body-presentation-method . mime-display-text/plain)))
731 (ctree-set-calist-strictly
732 'mime-preview-condition
733 '((type . multipart)(subtype . alternative)
735 (body-presentation-method . mime-display-multipart/alternative)))
737 (ctree-set-calist-strictly
738 'mime-preview-condition
739 '((type . multipart)(subtype . t)
741 (body-presentation-method . mime-display-multipart/mixed)))
743 (ctree-set-calist-strictly
744 'mime-preview-condition
745 '((type . message)(subtype . partial)
747 (body-presentation-method . mime-display-message/partial-button)))
749 (ctree-set-calist-strictly
750 'mime-preview-condition
751 '((type . message)(subtype . rfc822)
753 (body-presentation-method . mime-display-multipart/mixed)
754 (childrens-situation (header . visible)
755 (entity-button . invisible))))
757 (ctree-set-calist-strictly
758 'mime-preview-condition
759 '((type . message)(subtype . news)
761 (body-presentation-method . mime-display-multipart/mixed)
762 (childrens-situation (header . visible)
763 (entity-button . invisible))))
766 ;;; @@@ entity presentation
769 (defun mime-display-text/plain (entity situation)
771 (narrow-to-region (point-max)(point-max))
773 (mime-insert-text-content entity)
775 (message "Can't decode current entity.")
777 (run-hooks 'mime-text-decode-hook)
778 (goto-char (point-max))
779 (if (not (eq (char-after (1- (point))) ?\n))
782 (mime-add-url-buttons)
783 (run-hooks 'mime-display-text/plain-hook)
786 (defun mime-display-text/richtext (entity situation)
788 (narrow-to-region (point-max)(point-max))
789 (mime-insert-text-content entity)
790 (run-hooks 'mime-text-decode-hook)
791 (let ((beg (point-min)))
792 (remove-text-properties beg (point-max) '(face nil))
793 (richtext-decode beg (point-max))
796 (defun mime-display-text/enriched (entity situation)
798 (narrow-to-region (point-max)(point-max))
799 (mime-insert-text-content entity)
800 (run-hooks 'mime-text-decode-hook)
801 (let ((beg (point-min)))
802 (remove-text-properties beg (point-max) '(face nil))
803 (enriched-decode beg (point-max))
807 (defvar mime-view-announcement-for-message/partial
808 (if (and (>= emacs-major-version 19) window-system)
810 \[[ This is message/partial style split message. ]]
811 \[[ Please press `v' key in this buffer ]]
812 \[[ or click here by mouse button-2. ]]"
814 \[[ This is message/partial style split message. ]]
815 \[[ Please press `v' key in this buffer. ]]"
818 (defun mime-display-message/partial-button (&optional entity situation)
820 (goto-char (point-max))
821 (if (not (search-backward "\n\n" nil t))
824 (goto-char (point-max))
825 (narrow-to-region (point-max)(point-max))
826 (insert mime-view-announcement-for-message/partial)
827 (mime-add-button (point-min)(point-max)
828 #'mime-preview-play-current-entity)
831 (defun mime-display-multipart/mixed (entity situation)
832 (let ((children (mime-entity-children entity))
833 (original-major-mode-cell (assq 'major-mode situation))
835 (cdr (assq 'childrens-situation situation))))
836 (if original-major-mode-cell
837 (setq default-situation
838 (cons original-major-mode-cell default-situation)))
840 (mime-display-entity (car children) nil default-situation)
841 (setq children (cdr children))
844 (defcustom mime-view-type-subtype-score-alist
845 '(((text . enriched) . 3)
846 ((text . richtext) . 2)
849 "Alist MEDIA-TYPE vs corresponding score.
850 MEDIA-TYPE must be (TYPE . SUBTYPE), TYPE or t. t means default."
852 :type '(repeat (cons (choice :tag "Media-Type"
853 (cons :tag "Type/Subtype"
854 (symbol :tag "Primary-type")
855 (symbol :tag "Subtype"))
857 (const :tag "Default" t))
860 (defun mime-display-multipart/alternative (entity situation)
861 (let* ((children (mime-entity-children entity))
862 (original-major-mode-cell (assq 'major-mode situation))
864 (cdr (assq 'childrens-situation situation)))
869 (if original-major-mode-cell
870 (setq default-situation
871 (cons original-major-mode-cell default-situation)))
876 (mime-find-entity-preview-situation
877 child default-situation)))
878 (if (cdr (assq 'body-presentation-method situation))
883 (cdr (assq 'type situation))
884 (cdr (assq 'subtype situation)))
885 mime-view-type-subtype-score-alist)
887 (cdr (assq 'type situation))
888 mime-view-type-subtype-score-alist)
891 mime-view-type-subtype-score-alist)
893 (if (> score max-score)
903 (let ((child (car children))
904 (situation (car situations)))
905 (mime-display-entity child (if (= i p)
907 (put-alist 'body 'invisible
908 (copy-alist situation)))))
909 (setq children (cdr children)
910 situations (cdr situations)
914 ;;; @ acting-condition
917 (defvar mime-acting-condition nil
918 "Condition-tree about how to process entity.")
920 (defun mime-view-read-mailcap ()
921 (if (file-readable-p mime-mailcap-file)
922 (let ((entries (mime-parse-mailcap-file)))
924 (let ((entry (car entries))
927 (let* ((field (car entry))
928 (field-type (car field)))
929 (cond ((eq field-type 'view) (setq view field))
930 ((eq field-type 'print) (setq print field))
931 ((memq field-type '(compose composetyped edit)))
932 (t (setq shared (cons field shared))))
934 (setq entry (cdr entry)))
935 (setq shared (nreverse shared))
936 (ctree-set-calist-with-default
937 'mime-acting-condition
938 (append shared (list '(mode . "play")(cons 'method (cdr view)))))
940 (ctree-set-calist-with-default
941 'mime-acting-condition
943 (list '(mode . "print")(cons 'method (cdr view)))))))
944 (setq entries (cdr entries))))))
946 (mime-view-read-mailcap)
948 (ctree-set-calist-strictly
949 'mime-acting-condition
950 '((type . application)(subtype . octet-stream)
952 (method . mime-detect-content)
955 (ctree-set-calist-with-default
956 'mime-acting-condition
958 (method . mime-save-content)))
960 (ctree-set-calist-strictly
961 'mime-acting-condition
962 '((type . text)(subtype . x-rot13-47)(mode . "play")
963 (method . mime-view-caesar)
965 (ctree-set-calist-strictly
966 'mime-acting-condition
967 '((type . text)(subtype . x-rot13-47-48)(mode . "play")
968 (method . mime-view-caesar)
971 (ctree-set-calist-strictly
972 'mime-acting-condition
973 '((type . message)(subtype . rfc822)(mode . "play")
974 (method . mime-view-message/rfc822)
976 (ctree-set-calist-strictly
977 'mime-acting-condition
978 '((type . message)(subtype . partial)(mode . "play")
979 (method . mime-store-message/partial-piece)
982 (ctree-set-calist-strictly
983 'mime-acting-condition
984 '((type . message)(subtype . external-body)
985 ("access-type" . "anon-ftp")
986 (method . mime-view-message/external-anon-ftp)
989 (ctree-set-calist-strictly
990 'mime-acting-condition
991 '((type . message)(subtype . external-body)
992 ("access-type" . "url")
993 (method . mime-view-message/external-url)
996 (ctree-set-calist-strictly
997 'mime-acting-condition
998 '((type . application)(subtype . octet-stream)
999 (method . mime-save-content)
1003 ;;; @ quitting method
1006 (defvar mime-preview-quitting-method-alist
1007 '((mime-show-message-mode
1008 . mime-preview-quitting-method-for-mime-show-message-mode))
1009 "Alist of major-mode vs. quitting-method of mime-view.")
1011 (defvar mime-preview-over-to-previous-method-alist nil
1012 "Alist of major-mode vs. over-to-previous-method of mime-view.")
1014 (defvar mime-preview-over-to-next-method-alist nil
1015 "Alist of major-mode vs. over-to-next-method of mime-view.")
1018 ;;; @ following method
1021 (defvar mime-preview-following-method-alist nil
1022 "Alist of major-mode vs. following-method of mime-view.")
1024 (defvar mime-view-following-required-fields-list
1031 (defun mime-display-entity (entity &optional situation
1032 default-situation preview-buffer)
1034 (setq preview-buffer (current-buffer)))
1035 (let* (e nb ne nhb nbb)
1036 (in-calist-package 'mime-view)
1039 (mime-find-entity-preview-situation entity default-situation)))
1040 (let ((button-is-invisible
1041 (eq (cdr (or (assq '*entity-button situation)
1042 (assq 'entity-button situation)))
1045 (eq (cdr (or (assq '*header situation)
1046 (assq 'header situation)))
1049 (eq (cdr (or (assq '*body situation)
1050 (assq 'body situation)))
1052 (children (mime-entity-children entity)))
1053 (set-buffer preview-buffer)
1055 (narrow-to-region nb nb)
1056 (or button-is-invisible
1057 ;; (if (mime-view-entity-button-visible-p entity)
1058 (mime-view-insert-entity-button entity)
1061 (if header-is-visible
1062 (let ((header-presentation-method
1063 (or (cdr (assq 'header-presentation-method situation))
1064 (cdr (assq (cdr (assq 'major-mode situation))
1065 mime-header-presentation-method-alist)))))
1067 (if header-presentation-method
1068 (funcall header-presentation-method entity situation)
1069 (mime-insert-header entity
1070 mime-view-ignored-field-list
1071 mime-view-visible-field-list))
1072 (run-hooks 'mime-display-header-hook)
1073 (put-text-property nhb (point-max) 'mime-view-entity-header entity)
1074 (goto-char (point-max))
1079 (let ((body-presentation-method
1080 (cdr (assq 'body-presentation-method situation))))
1081 (if (functionp body-presentation-method)
1082 (funcall body-presentation-method entity situation)
1083 (mime-display-text/plain entity situation)))
1084 (when button-is-invisible
1085 (goto-char (point-max))
1086 (mime-view-insert-entity-button entity)
1088 (unless header-is-visible
1089 (goto-char (point-max))
1092 (setq ne (point-max))
1094 (put-text-property nb ne 'mime-view-entity entity)
1095 (put-text-property nb ne 'mime-view-situation situation)
1096 (put-text-property nbb ne 'mime-view-entity-body entity)
1098 (if (and children body-is-visible)
1099 (let ((body-presentation-method
1100 (cdr (assq 'body-presentation-method situation))))
1101 (if (functionp body-presentation-method)
1102 (funcall body-presentation-method entity situation)
1103 (mime-display-multipart/mixed entity situation))))
1107 ;;; @ MIME viewer mode
1110 (defconst mime-view-menu-title "MIME-View")
1111 (defconst mime-view-menu-list
1112 '((up "Move to upper entity" mime-preview-move-to-upper)
1113 (previous "Move to previous entity" mime-preview-move-to-previous)
1114 (next "Move to next entity" mime-preview-move-to-next)
1115 (scroll-down "Scroll-down" mime-preview-scroll-down-entity)
1116 (scroll-up "Scroll-up" mime-preview-scroll-up-entity)
1117 (play "Play current entity" mime-preview-play-current-entity)
1118 (extract "Extract current entity" mime-preview-extract-current-entity)
1119 (print "Print current entity" mime-preview-print-current-entity)
1121 "Menu for MIME Viewer")
1123 (cond ((featurep 'xemacs)
1124 (defvar mime-view-xemacs-popup-menu
1125 (cons mime-view-menu-title
1128 (vector (nth 1 item)(nth 2 item) t)
1130 mime-view-menu-list)))
1131 (defun mime-view-xemacs-popup-menu (event)
1132 "Popup the menu in the MIME Viewer buffer"
1134 (select-window (event-window event))
1135 (set-buffer (event-buffer event))
1136 (popup-menu 'mime-view-xemacs-popup-menu))
1137 (defvar mouse-button-2 'button2)
1138 (defvar mouse-button-3 'button3)
1141 (defvar mime-view-popup-menu
1142 (let ((menu (make-sparse-keymap mime-view-menu-title)))
1146 (list (intern (nth 1 item)) 'menu-item
1147 (nth 1 item)(nth 2 item))
1149 mime-view-menu-list))))
1150 (defun mime-view-popup-menu (event)
1151 "Popup the menu in the MIME Viewer buffer"
1153 (let ((menu mime-view-popup-menu) events func)
1154 (setq events (x-popup-menu t menu))
1156 (setq func (lookup-key menu (apply #'vector events)))
1159 (defvar mouse-button-2 [mouse-2])
1160 (defvar mouse-button-3 [mouse-3])
1163 (defun mime-view-define-keymap (&optional default)
1164 (let ((mime-view-mode-map (if (keymapp default)
1165 (copy-keymap default)
1166 (make-sparse-keymap))))
1167 (define-key mime-view-mode-map
1168 "u" (function mime-preview-move-to-upper))
1169 (define-key mime-view-mode-map
1170 "p" (function mime-preview-move-to-previous))
1171 (define-key mime-view-mode-map
1172 "n" (function mime-preview-move-to-next))
1173 (define-key mime-view-mode-map
1174 "\e\t" (function mime-preview-move-to-previous))
1175 (define-key mime-view-mode-map
1176 "\t" (function mime-preview-move-to-next))
1177 (define-key mime-view-mode-map
1178 " " (function mime-preview-scroll-up-entity))
1179 (define-key mime-view-mode-map
1180 "\M- " (function mime-preview-scroll-down-entity))
1181 (define-key mime-view-mode-map
1182 "\177" (function mime-preview-scroll-down-entity))
1183 (define-key mime-view-mode-map
1184 "\C-m" (function mime-preview-next-line-entity))
1185 (define-key mime-view-mode-map
1186 "\C-\M-m" (function mime-preview-previous-line-entity))
1187 (define-key mime-view-mode-map
1188 "v" (function mime-preview-play-current-entity))
1189 (define-key mime-view-mode-map
1190 "e" (function mime-preview-extract-current-entity))
1191 (define-key mime-view-mode-map
1192 "\C-c\C-p" (function mime-preview-print-current-entity))
1194 (define-key mime-view-mode-map
1195 "\C-c\C-t\C-f" (function mime-preview-toggle-header))
1196 (define-key mime-view-mode-map
1197 "\C-c\C-th" (function mime-preview-toggle-header))
1198 (define-key mime-view-mode-map
1199 "\C-c\C-t\C-c" (function mime-preview-toggle-content))
1201 (define-key mime-view-mode-map
1202 "\C-c\C-v\C-f" (function mime-preview-show-header))
1203 (define-key mime-view-mode-map
1204 "\C-c\C-vh" (function mime-preview-show-header))
1205 (define-key mime-view-mode-map
1206 "\C-c\C-v\C-c" (function mime-preview-show-content))
1208 (define-key mime-view-mode-map
1209 "\C-c\C-d\C-f" (function mime-preview-hide-header))
1210 (define-key mime-view-mode-map
1211 "\C-c\C-dh" (function mime-preview-hide-header))
1212 (define-key mime-view-mode-map
1213 "\C-c\C-d\C-c" (function mime-preview-hide-content))
1215 (define-key mime-view-mode-map
1216 "a" (function mime-preview-follow-current-entity))
1217 (define-key mime-view-mode-map
1218 "q" (function mime-preview-quit))
1219 (define-key mime-view-mode-map
1220 "\C-c\C-x" (function mime-preview-kill-buffer))
1221 ;; (define-key mime-view-mode-map
1222 ;; "<" (function beginning-of-buffer))
1223 ;; (define-key mime-view-mode-map
1224 ;; ">" (function end-of-buffer))
1225 (define-key mime-view-mode-map
1226 "?" (function describe-mode))
1227 (define-key mime-view-mode-map
1228 [tab] (function mime-preview-move-to-next))
1229 (define-key mime-view-mode-map
1230 [delete] (function mime-preview-scroll-down-entity))
1231 (define-key mime-view-mode-map
1232 [backspace] (function mime-preview-scroll-down-entity))
1233 (if (functionp default)
1234 (cond ((featurep 'xemacs)
1235 (set-keymap-default-binding mime-view-mode-map default)
1238 (setq mime-view-mode-map
1239 (append mime-view-mode-map (list (cons t default))))
1242 (define-key mime-view-mode-map
1243 mouse-button-2 (function mime-button-dispatcher))
1245 (cond ((featurep 'xemacs)
1246 (define-key mime-view-mode-map
1247 mouse-button-3 (function mime-view-xemacs-popup-menu))
1249 ((>= emacs-major-version 19)
1250 (define-key mime-view-mode-map
1251 mouse-button-3 (function mime-view-popup-menu))
1252 (define-key mime-view-mode-map [menu-bar mime-view]
1253 (cons mime-view-menu-title
1254 (make-sparse-keymap mime-view-menu-title)))
1257 (define-key mime-view-mode-map
1258 (vector 'menu-bar 'mime-view (car item))
1259 (cons (nth 1 item)(nth 2 item)))
1261 (reverse mime-view-menu-list))
1263 ;; (run-hooks 'mime-view-define-keymap-hook)
1264 mime-view-mode-map))
1266 (defvar mime-view-mode-default-map (mime-view-define-keymap))
1269 (defsubst mime-maybe-hide-echo-buffer ()
1270 "Clear mime-echo buffer and delete window for it."
1271 (let ((buf (get-buffer mime-echo-buffer-name)))
1276 (let ((win (get-buffer-window buf)))
1283 (defvar mime-view-redisplay nil)
1286 (defun mime-display-message (message &optional preview-buffer
1287 mother default-keymap-or-function
1288 original-major-mode keymap)
1289 "View MESSAGE in MIME-View mode.
1291 Optional argument PREVIEW-BUFFER specifies the buffer of the
1292 presentation. It must be either nil or a name of preview buffer.
1294 Optional argument MOTHER specifies mother-buffer of the preview-buffer.
1296 Optional argument DEFAULT-KEYMAP-OR-FUNCTION is nil, keymap or
1297 function. If it is a keymap, keymap of MIME-View mode will be added
1298 to it. If it is a function, it will be bound as default binding of
1299 keymap of MIME-View mode.
1301 Optional argument ORIGINAL-MAJOR-MODE is major-mode of representation
1302 buffer of MESSAGE. If it is nil, current `major-mode' is used.
1304 Optional argument KEYMAP is keymap of MIME-View mode. If it is
1305 non-nil, DEFAULT-KEYMAP-OR-FUNCTION is ignored. If it is nil,
1306 `mime-view-mode-default-map' is used."
1307 (mime-maybe-hide-echo-buffer)
1308 (let ((win-conf (current-window-configuration)))
1310 (setq preview-buffer
1311 (concat "*Preview-" (mime-entity-name message) "*")))
1312 (or original-major-mode
1313 (setq original-major-mode major-mode))
1314 (let ((inhibit-read-only t))
1315 (set-buffer (get-buffer-create preview-buffer))
1319 (setq mime-mother-buffer mother))
1320 (setq mime-preview-original-window-configuration win-conf)
1321 (setq major-mode 'mime-view-mode)
1322 (setq mode-name "MIME-View")
1323 (mime-display-entity message nil
1324 `((entity-button . invisible)
1326 (major-mode . ,original-major-mode))
1330 (if default-keymap-or-function
1331 (mime-view-define-keymap default-keymap-or-function)
1332 mime-view-mode-default-map)))
1334 (next-single-property-change (point-min) 'mime-view-entity)))
1337 (goto-char (point-min))
1338 (search-forward "\n\n" nil t)))
1339 (run-hooks 'mime-view-mode-hook)
1340 (set-buffer-modified-p nil)
1341 (setq buffer-read-only t)
1345 (defun mime-view-buffer (&optional raw-buffer preview-buffer mother
1346 default-keymap-or-function
1347 representation-type)
1348 "View RAW-BUFFER in MIME-View mode.
1349 Optional argument PREVIEW-BUFFER is either nil or a name of preview
1351 Optional argument DEFAULT-KEYMAP-OR-FUNCTION is nil, keymap or
1352 function. If it is a keymap, keymap of MIME-View mode will be added
1353 to it. If it is a function, it will be bound as default binding of
1354 keymap of MIME-View mode.
1355 Optional argument REPRESENTATION-TYPE is representation-type of
1356 message. It must be nil, `binary' or `cooked'. If it is nil,
1357 `cooked' is used as default."
1360 (setq raw-buffer (current-buffer)))
1361 (or representation-type
1362 (setq representation-type
1364 (set-buffer raw-buffer)
1365 (cdr (or (assq major-mode mime-raw-representation-type-alist)
1366 (assq t mime-raw-representation-type-alist)))
1368 (if (eq representation-type 'binary)
1369 (setq representation-type 'buffer)
1371 (setq preview-buffer (mime-display-message
1372 (mime-open-entity representation-type raw-buffer)
1373 preview-buffer mother default-keymap-or-function))
1374 (or (get-buffer-window preview-buffer)
1375 (let ((r-win (get-buffer-window raw-buffer)))
1377 (set-window-buffer r-win preview-buffer)
1378 (let ((m-win (and mother (get-buffer-window mother))))
1380 (set-window-buffer m-win preview-buffer)
1381 (switch-to-buffer preview-buffer)
1384 (defun mime-view-mode (&optional mother ctl encoding
1385 raw-buffer preview-buffer
1386 default-keymap-or-function)
1387 "Major mode for viewing MIME message.
1389 Here is a list of the standard keys for mime-view-mode.
1394 u Move to upper content
1395 p or M-TAB Move to previous content
1396 n or TAB Move to next content
1397 SPC Scroll up or move to next content
1398 M-SPC or DEL Scroll down or move to previous content
1399 RET Move to next line
1400 M-RET Move to previous line
1401 v Decode current content as `play mode'
1402 e Decode current content as `extract mode'
1403 C-c C-p Decode current content as `print mode'
1404 a Followup to current content.
1406 button-2 Move to point under the mouse cursor
1407 and decode current content as `play mode'
1410 (unless mime-view-redisplay
1412 (if raw-buffer (set-buffer raw-buffer))
1415 (or (assq major-mode mime-raw-representation-type-alist)
1416 (assq t mime-raw-representation-type-alist)))))
1417 (if (eq type 'binary)
1420 (setq mime-message-structure (mime-open-entity type raw-buffer))
1421 (or (mime-entity-content-type mime-message-structure)
1422 (mime-entity-set-content-type mime-message-structure ctl))
1424 (or (mime-entity-encoding mime-message-structure)
1425 (mime-entity-set-encoding mime-message-structure encoding))
1427 (mime-display-message mime-message-structure preview-buffer
1428 mother default-keymap-or-function)
1435 (defun mime-preview-find-boundary-info (&optional get-mother)
1439 (while (null (setq entity
1440 (get-text-property (point) 'mime-view-entity)))
1442 (setq p-beg (previous-single-property-change (point) 'mime-view-entity))
1443 (setq entity-node-id (mime-entity-node-id entity))
1444 (setq len (length entity-node-id))
1447 (if (eq (next-single-property-change (point-min)
1453 ((eq (next-single-property-change p-beg 'mime-view-entity)
1455 (setq p-beg (point))
1457 (setq p-end (next-single-property-change p-beg 'mime-view-entity))
1459 (setq p-end (point-max))
1461 ((null entity-node-id)
1462 (setq p-end (point-max))
1470 (next-single-property-change
1471 (point) 'mime-view-entity))
1473 (let ((rc (mime-entity-node-id
1474 (get-text-property (1- (point))
1475 'mime-view-entity))))
1476 (or (and (>= (setq i (- (length rc) len)) 0)
1477 (equal entity-node-id (nthcdr i rc)))
1480 (setq p-end (point-max))))
1482 (vector p-beg p-end entity)))
1488 (autoload 'mime-preview-play-current-entity "mime-play"
1489 "Play current entity." t)
1491 (defun mime-preview-extract-current-entity (&optional ignore-examples)
1492 "Extract current entity into file (maybe).
1493 It decodes current entity to call internal or external method as
1494 \"extract\" mode. The method is selected from variable
1495 `mime-acting-condition'."
1497 (mime-preview-play-current-entity ignore-examples "extract")
1500 (defun mime-preview-print-current-entity (&optional ignore-examples)
1501 "Print current entity (maybe).
1502 It decodes current entity to call internal or external method as
1503 \"print\" mode. The method is selected from variable
1504 `mime-acting-condition'."
1506 (mime-preview-play-current-entity ignore-examples "print")
1513 (defun mime-preview-follow-current-entity ()
1514 "Write follow message to current entity.
1515 It calls following-method selected from variable
1516 `mime-preview-following-method-alist'."
1518 (let ((entity (mime-preview-find-boundary-info t))
1521 (setq p-beg (aref entity 0)
1522 p-end (aref entity 1)
1523 entity (aref entity 2))
1524 (if (get-text-property p-beg 'mime-view-entity-body)
1527 (next-single-property-change
1528 p-beg 'mime-view-entity-body nil
1529 (or (next-single-property-change p-beg 'mime-view-entity)
1531 (let* ((mode (mime-preview-original-major-mode 'recursive))
1532 (entity-node-id (mime-entity-node-id entity))
1534 (format "%s-%s" (buffer-name) (reverse entity-node-id)))
1536 (the-buf (current-buffer))
1539 (set-buffer (setq new-buf (get-buffer-create new-name)))
1542 (insert-buffer-substring the-buf pb-beg p-end)
1543 (goto-char (point-min))
1544 (let ((current-entity
1545 (if (and (eq (mime-entity-media-type entity) 'message)
1546 (eq (mime-entity-media-subtype entity) 'rfc822))
1547 (car (mime-entity-children entity))
1549 (while (and current-entity
1550 (if (and (eq (mime-entity-media-type
1551 current-entity) 'message)
1552 (eq (mime-entity-media-subtype
1553 current-entity) 'rfc822))
1555 (mime-insert-header current-entity fields)
1557 (setq fields (std11-collect-field-names)
1558 current-entity (mime-entity-parent current-entity))
1560 (let ((rest mime-view-following-required-fields-list)
1563 (setq field-name (car rest))
1564 (or (std11-field-body field-name)
1567 (set-buffer the-buf)
1568 (let ((entity (when mime-mother-buffer
1569 (set-buffer mime-mother-buffer)
1570 (get-text-property (point)
1571 'mime-view-entity))))
1573 (null (setq ret (mime-entity-fetch-field
1574 entity field-name))))
1575 (setq entity (mime-entity-parent entity)))))
1577 (insert (concat field-name ": " ret "\n"))
1579 (setq rest (cdr rest))
1582 (let ((f (cdr (assq mode mime-preview-following-method-alist))))
1587 "Sorry, following method for %s is not implemented yet."
1596 (defun mime-preview-move-to-upper ()
1597 "Move to upper entity.
1598 If there is no upper entity, call function `mime-preview-quit'."
1601 (while (null (setq cinfo
1602 (get-text-property (point) 'mime-view-entity)))
1605 (let ((r (mime-entity-parent cinfo))
1608 (while (setq point (previous-single-property-change
1609 (point) 'mime-view-entity))
1611 (when (eq r (get-text-property (point) 'mime-view-entity))
1612 (if (or (eq mime-preview-move-scroll t)
1613 (and mime-preview-move-scroll
1616 (move-to-window-line -1)
1617 (forward-line (* -1 next-screen-context-lines))
1620 (recenter next-screen-context-lines))
1627 (defun mime-preview-move-to-previous ()
1628 "Move to previous entity.
1629 If there is no previous entity, it calls function registered in
1630 variable `mime-preview-over-to-previous-method-alist'."
1632 (while (and (not (bobp))
1633 (null (get-text-property (point) 'mime-view-entity)))
1636 (let ((point (previous-single-property-change (point) 'mime-view-entity)))
1638 (>= point (point-min)))
1639 (if (get-text-property (1- point) 'mime-view-entity)
1640 (progn (goto-char point)
1642 (or (eq mime-preview-move-scroll t)
1643 (and mime-preview-move-scroll
1646 (move-to-window-line 0)
1647 (forward-line next-screen-context-lines)
1650 (recenter (* -1 next-screen-context-lines))))
1651 (goto-char (1- point))
1652 (mime-preview-move-to-previous)
1654 (let ((f (assq (mime-preview-original-major-mode)
1655 mime-preview-over-to-previous-method-alist)))
1661 (defun mime-preview-move-to-next ()
1662 "Move to next entity.
1663 If there is no previous entity, it calls function registered in
1664 variable `mime-preview-over-to-next-method-alist'."
1666 (while (and (not (eobp))
1667 (null (get-text-property (point) 'mime-view-entity)))
1670 (let ((point (next-single-property-change (point) 'mime-view-entity)))
1672 (<= point (point-max)))
1675 (if (null (get-text-property point 'mime-view-entity))
1676 (mime-preview-move-to-next)
1678 (or (eq mime-preview-move-scroll t)
1679 (and mime-preview-move-scroll
1682 (move-to-window-line -1)
1684 (* -1 next-screen-context-lines))
1687 (recenter next-screen-context-lines))
1689 (let ((f (assq (mime-preview-original-major-mode)
1690 mime-preview-over-to-next-method-alist)))
1696 (defun mime-preview-scroll-up-entity (&optional h)
1697 "Scroll up current entity.
1698 If reached to (point-max), it calls function registered in variable
1699 `mime-preview-over-to-next-method-alist'."
1702 (let ((f (assq (mime-preview-original-major-mode)
1703 mime-preview-over-to-next-method-alist)))
1708 (or (next-single-property-change (point) 'mime-view-entity)
1710 (bottom (window-end (selected-window))))
1713 (progn (goto-char point)
1714 (recenter next-screen-context-lines))
1718 (goto-char (point-max)))))
1721 (defun mime-preview-scroll-down-entity (&optional h)
1722 "Scroll down current entity.
1723 If reached to (point-min), it calls function registered in variable
1724 `mime-preview-over-to-previous-method-alist'."
1727 (let ((f (assq (mime-preview-original-major-mode)
1728 mime-preview-over-to-previous-method-alist)))
1733 (or (previous-single-property-change (point) 'mime-view-entity)
1735 (top (window-start (selected-window))))
1738 (progn (goto-char point)
1739 (recenter (* -1 next-screen-context-lines)))
1742 (beginning-of-buffer
1743 (goto-char (point-min)))))
1746 (defun mime-preview-next-line-entity (&optional lines)
1747 "Scroll up one line (or prefix LINES lines).
1748 If LINES is negative, scroll down LINES lines."
1750 (mime-preview-scroll-up-entity (or lines 1))
1753 (defun mime-preview-previous-line-entity (&optional lines)
1754 "Scrroll down one line (or prefix LINES lines).
1755 If LINES is negative, scroll up LINES lines."
1757 (mime-preview-scroll-down-entity (or lines 1))
1764 (defun mime-preview-toggle-display (type &optional display)
1765 (let ((situation (mime-preview-find-boundary-info))
1766 (sym (intern (concat "*" (symbol-name type))))
1768 (setq p-beg (aref situation 0)
1769 p-end (aref situation 1)
1770 entity (aref situation 2)
1771 situation (get-text-property p-beg 'mime-view-situation))
1772 (cond ((eq display 'invisible)
1777 (eq (cdr (or (assq sym situation)
1778 (assq type situation)))
1780 (setq situation (put-alist sym (if display
1785 (let ((inhibit-read-only t))
1786 (delete-region p-beg p-end)
1787 (mime-display-entity entity situation)))
1788 (let ((ret (assoc situation mime-preview-situation-example-list)))
1790 (setcdr ret (1+ (cdr ret)))
1791 (add-to-list 'mime-preview-situation-example-list
1792 (cons situation 0))))))
1794 (defun mime-preview-toggle-header (&optional force-visible)
1796 (mime-preview-toggle-display 'header force-visible))
1798 (defun mime-preview-toggle-content (&optional force-visible)
1800 (mime-preview-toggle-display 'body force-visible))
1802 (defun mime-preview-show-header ()
1804 (mime-preview-toggle-display 'header 'visible))
1806 (defun mime-preview-show-content ()
1808 (mime-preview-toggle-display 'body 'visible))
1810 (defun mime-preview-hide-header ()
1812 (mime-preview-toggle-display 'header 'invisible))
1814 (defun mime-preview-hide-content ()
1816 (mime-preview-toggle-display 'body 'invisible))
1822 (defun mime-preview-quit ()
1823 "Quit from MIME-preview buffer.
1824 It calls function registered in variable
1825 `mime-preview-quitting-method-alist'."
1827 (let ((r (assq (mime-preview-original-major-mode)
1828 mime-preview-quitting-method-alist)))
1833 (defun mime-preview-kill-buffer ()
1835 (kill-buffer (current-buffer))
1842 (provide 'mime-view)
1844 (mime-view-read-situation-examples-file)
1846 ;;; mime-view.el ends here