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-save-situation-examples ()
364 (if (or mime-preview-situation-example-list
365 mime-acting-situation-example-list)
366 (let ((file mime-situation-examples-file))
368 (insert ";;; " (file-name-nondirectory file) "\n")
369 (insert "\n;; This file is generated automatically by "
370 mime-view-version "\n\n")
371 (insert ";;; Code:\n\n")
372 (if mime-preview-situation-example-list
373 (pp `(setq mime-preview-situation-example-list
374 ',mime-preview-situation-example-list)
376 (if mime-acting-situation-example-list
377 (pp `(setq mime-acting-situation-example-list
378 ',mime-acting-situation-example-list)
381 (file-name-nondirectory file)
383 (setq buffer-file-coding-system
384 mime-situation-examples-file-coding-system)
386 ;; ((boundp 'buffer-file-coding-system)
387 ;; (setq buffer-file-coding-system
388 ;; mime-situation-examples-file-coding-system))
389 ;; ((boundp 'file-coding-system)
390 ;; (setq file-coding-system
391 ;; mime-situation-examples-file-coding-system)))
392 (setq buffer-file-name file)
395 (add-hook 'kill-emacs-hook 'mime-save-situation-examples)
397 (defun mime-reduce-situation-examples (situation-examples)
398 (let ((len (length situation-examples))
406 ir situation-examples)
410 jr situation-examples)
414 (setq ret (mime-compare-situation-with-example (car ic)(car jc))
416 det-ret (+ (length (car ic))(length (car jc)))
417 det-org (length (cdr ret))
418 freq (+ (cdr ic)(cdr jc)))
419 (cond ((< max-sim sim)
426 dest (cons (cdr ret) freq))
429 (cond ((> min-det-ret det-ret)
430 (setq min-det-ret det-ret
435 dest (cons (cdr ret) freq))
437 ((= min-det-ret det-ret)
438 (cond ((> min-det-org det-org)
439 (setq min-det-org det-org
443 dest (cons (cdr ret) freq))
445 ((= min-det-org det-org)
446 (cond ((> min-freq freq)
450 dest (cons (cdr ret) freq))
464 (setq jr (nthcdr (1- d-j) situation-examples))
465 (setcdr jr (cddr jr))
467 (setq situation-examples
468 (cdr situation-examples))
469 (setq ir (nthcdr (1- d-i) situation-examples))
470 (setcdr ir (cddr ir))
472 (if (setq ir (assoc (car dest) situation-examples))
474 (setcdr ir (+ (cdr ir)(cdr dest)))
476 (cons dest situation-examples)
477 ;; situation-examples may be modified.
481 ;;; @ presentation of preview
487 ;;; @@@ predicate function
490 ;; (defun mime-view-entity-button-visible-p (entity)
491 ;; "Return non-nil if header of ENTITY is visible.
492 ;; Please redefine this function if you want to change default setting."
493 ;; (let ((media-type (mime-entity-media-type entity))
494 ;; (media-subtype (mime-entity-media-subtype entity)))
495 ;; (or (not (eq media-type 'application))
496 ;; (and (not (eq media-subtype 'x-selection))
497 ;; (or (not (eq media-subtype 'octet-stream))
498 ;; (let ((mother-entity (mime-entity-parent entity)))
499 ;; (or (not (eq (mime-entity-media-type mother-entity)
501 ;; (not (eq (mime-entity-media-subtype mother-entity)
506 ;;; @@@ entity button generator
509 (defun mime-view-insert-entity-button (entity)
510 "Insert entity-button of ENTITY."
511 (let ((entity-node-id (mime-entity-node-id entity))
512 (params (mime-entity-parameters entity))
513 (subject (mime-view-entity-title entity)))
515 (let ((access-type (assoc "access-type" params))
516 (num (or (cdr (assoc "x-part-number" params))
517 (if (consp entity-node-id)
520 (format "%s" (1+ num))
522 (reverse entity-node-id) ".")
526 (let ((server (assoc "server" params)))
527 (setq access-type (cdr access-type))
529 (format "%s %s ([%s] %s)"
530 num subject access-type (cdr server))
531 (let ((site (cdr (assoc "site" params)))
532 (dir (cdr (assoc "directory" params)))
533 (url (cdr (assoc "url" params)))
536 (format "%s %s ([%s] %s)"
537 num subject access-type url)
538 (format "%s %s ([%s] %s:%s)"
539 num subject access-type site dir))
543 (let ((media-type (mime-entity-media-type entity))
544 (media-subtype (mime-entity-media-subtype entity))
545 (charset (cdr (assoc "charset" params)))
546 (encoding (mime-entity-encoding entity)))
550 (format " <%s/%s%s%s>"
551 media-type media-subtype
553 (concat "; " charset)
556 (concat " (" encoding ")")
558 (if (>= (+ (current-column)(length rest))(window-width))
562 (function mime-preview-play-current-entity))
569 (defvar mime-header-presentation-method-alist nil
570 "Alist of major mode vs. corresponding header-presentation-method functions.
571 Each element looks like (SYMBOL . FUNCTION).
572 SYMBOL must be major mode in raw-buffer or t. t means default.
573 Interface of FUNCTION must be (ENTITY SITUATION).")
575 (defvar mime-view-ignored-field-list
576 '(".*Received:" ".*Path:" ".*Id:" "^References:"
577 "^Replied:" "^Errors-To:"
578 "^Lines:" "^Sender:" ".*Host:" "^Xref:"
579 "^Content-Type:" "^Precedence:"
580 "^Status:" "^X-VM-.*:")
581 "All fields that match this list will be hidden in MIME preview buffer.
582 Each elements are regexp of field-name.")
584 (defvar mime-view-visible-field-list '("^Dnas.*:" "^Message-Id:")
585 "All fields that match this list will be displayed in MIME preview buffer.
586 Each elements are regexp of field-name.")
592 ;;; @@@ predicate function
595 (in-calist-package 'mime-view)
597 (defun mime-calist::field-match-method-as-default-rule (calist
598 field-type field-value)
599 (let ((s-field (assq field-type calist)))
600 (cond ((null s-field)
601 (cons (cons field-type field-value) calist)
605 (define-calist-field-match-method
606 'header #'mime-calist::field-match-method-as-default-rule)
608 (define-calist-field-match-method
609 'body #'mime-calist::field-match-method-as-default-rule)
612 (defvar mime-preview-condition nil
613 "Condition-tree about how to display entity.")
615 (ctree-set-calist-strictly
616 'mime-preview-condition '((type . application)(subtype . octet-stream)
619 (ctree-set-calist-strictly
620 'mime-preview-condition '((type . application)(subtype . octet-stream)
623 (ctree-set-calist-strictly
624 'mime-preview-condition '((type . application)(subtype . octet-stream)
628 (ctree-set-calist-strictly
629 'mime-preview-condition '((type . application)(subtype . pgp)
632 (ctree-set-calist-strictly
633 'mime-preview-condition '((type . application)(subtype . x-latex)
636 (ctree-set-calist-strictly
637 'mime-preview-condition '((type . application)(subtype . x-selection)
640 (ctree-set-calist-strictly
641 'mime-preview-condition '((type . application)(subtype . x-comment)
644 (ctree-set-calist-strictly
645 'mime-preview-condition '((type . message)(subtype . delivery-status)
648 (ctree-set-calist-strictly
649 'mime-preview-condition
651 (body-presentation-method . mime-display-text/plain)))
653 (ctree-set-calist-strictly
654 'mime-preview-condition
657 (body-presentation-method . mime-display-text/plain)))
659 (ctree-set-calist-strictly
660 'mime-preview-condition
661 '((type . text)(subtype . enriched)
663 (body-presentation-method . mime-display-text/enriched)))
665 (ctree-set-calist-strictly
666 'mime-preview-condition
667 '((type . text)(subtype . richtext)
669 (body-presentation-method . mime-display-text/richtext)))
671 (autoload 'mime-display-application/x-postpet "postpet")
673 (ctree-set-calist-strictly
674 'mime-preview-condition
675 '((type . application)(subtype . x-postpet)
677 (body-presentation-method . mime-display-application/x-postpet)))
679 (ctree-set-calist-strictly
680 'mime-preview-condition
681 '((type . text)(subtype . t)
683 (body-presentation-method . mime-display-text/plain)))
685 (ctree-set-calist-strictly
686 'mime-preview-condition
687 '((type . multipart)(subtype . alternative)
689 (body-presentation-method . mime-display-multipart/alternative)))
691 (ctree-set-calist-strictly
692 'mime-preview-condition
693 '((type . multipart)(subtype . t)
695 (body-presentation-method . mime-display-multipart/mixed)))
697 (ctree-set-calist-strictly
698 'mime-preview-condition
699 '((type . message)(subtype . partial)
701 (body-presentation-method . mime-display-message/partial-button)))
703 (ctree-set-calist-strictly
704 'mime-preview-condition
705 '((type . message)(subtype . rfc822)
707 (body-presentation-method . mime-display-multipart/mixed)
708 (childrens-situation (header . visible)
709 (entity-button . invisible))))
711 (ctree-set-calist-strictly
712 'mime-preview-condition
713 '((type . message)(subtype . news)
715 (body-presentation-method . mime-display-multipart/mixed)
716 (childrens-situation (header . visible)
717 (entity-button . invisible))))
720 ;;; @@@ entity presentation
723 (defun mime-display-text/plain (entity situation)
725 (narrow-to-region (point-max)(point-max))
727 (mime-insert-text-content entity)
729 (message "Can't decode current entity.")
731 (run-hooks 'mime-text-decode-hook)
732 (goto-char (point-max))
733 (if (not (eq (char-after (1- (point))) ?\n))
736 (mime-add-url-buttons)
737 (run-hooks 'mime-display-text/plain-hook)
740 (defun mime-display-text/richtext (entity situation)
742 (narrow-to-region (point-max)(point-max))
743 (mime-insert-text-content entity)
744 (run-hooks 'mime-text-decode-hook)
745 (let ((beg (point-min)))
746 (remove-text-properties beg (point-max) '(face nil))
747 (richtext-decode beg (point-max))
750 (defun mime-display-text/enriched (entity situation)
752 (narrow-to-region (point-max)(point-max))
753 (mime-insert-text-content entity)
754 (run-hooks 'mime-text-decode-hook)
755 (let ((beg (point-min)))
756 (remove-text-properties beg (point-max) '(face nil))
757 (enriched-decode beg (point-max))
761 (defvar mime-view-announcement-for-message/partial
762 (if (and (>= emacs-major-version 19) window-system)
764 \[[ This is message/partial style split message. ]]
765 \[[ Please press `v' key in this buffer ]]
766 \[[ or click here by mouse button-2. ]]"
768 \[[ This is message/partial style split message. ]]
769 \[[ Please press `v' key in this buffer. ]]"
772 (defun mime-display-message/partial-button (&optional entity situation)
774 (goto-char (point-max))
775 (if (not (search-backward "\n\n" nil t))
778 (goto-char (point-max))
779 (narrow-to-region (point-max)(point-max))
780 (insert mime-view-announcement-for-message/partial)
781 (mime-add-button (point-min)(point-max)
782 #'mime-preview-play-current-entity)
785 (defun mime-display-multipart/mixed (entity situation)
786 (let ((children (mime-entity-children entity))
787 (original-major-mode-cell (assq 'major-mode situation))
789 (cdr (assq 'childrens-situation situation))))
790 (if original-major-mode-cell
791 (setq default-situation
792 (cons original-major-mode-cell default-situation)))
794 (mime-display-entity (car children) nil default-situation)
795 (setq children (cdr children))
798 (defcustom mime-view-type-subtype-score-alist
799 '(((text . enriched) . 3)
800 ((text . richtext) . 2)
803 "Alist MEDIA-TYPE vs corresponding score.
804 MEDIA-TYPE must be (TYPE . SUBTYPE), TYPE or t. t means default."
806 :type '(repeat (cons (choice :tag "Media-Type"
807 (cons :tag "Type/Subtype"
808 (symbol :tag "Primary-type")
809 (symbol :tag "Subtype"))
811 (const :tag "Default" t))
814 (defun mime-display-multipart/alternative (entity situation)
815 (let* ((children (mime-entity-children entity))
816 (original-major-mode-cell (assq 'major-mode situation))
818 (cdr (assq 'childrens-situation situation)))
823 (if original-major-mode-cell
824 (setq default-situation
825 (cons original-major-mode-cell default-situation)))
830 (mime-find-entity-preview-situation
831 child default-situation)))
832 (if (cdr (assq 'body-presentation-method situation))
837 (cdr (assq 'type situation))
838 (cdr (assq 'subtype situation)))
839 mime-view-type-subtype-score-alist)
841 (cdr (assq 'type situation))
842 mime-view-type-subtype-score-alist)
845 mime-view-type-subtype-score-alist)
847 (if (> score max-score)
857 (let ((child (car children))
858 (situation (car situations)))
859 (mime-display-entity child (if (= i p)
861 (put-alist 'body 'invisible
862 (copy-alist situation)))))
863 (setq children (cdr children)
864 situations (cdr situations)
868 ;;; @ acting-condition
871 (defvar mime-acting-condition nil
872 "Condition-tree about how to process entity.")
874 (if (file-readable-p mime-mailcap-file)
875 (let ((entries (mime-parse-mailcap-file)))
877 (let ((entry (car entries))
880 (let* ((field (car entry))
881 (field-type (car field)))
882 (cond ((eq field-type 'view) (setq view field))
883 ((eq field-type 'print) (setq print field))
884 ((memq field-type '(compose composetyped edit)))
885 (t (setq shared (cons field shared))))
887 (setq entry (cdr entry))
889 (setq shared (nreverse shared))
890 (ctree-set-calist-with-default
891 'mime-acting-condition
892 (append shared (list '(mode . "play")(cons 'method (cdr view)))))
894 (ctree-set-calist-with-default
895 'mime-acting-condition
897 (list '(mode . "print")(cons 'method (cdr view))))
900 (setq entries (cdr entries))
903 (ctree-set-calist-strictly
904 'mime-acting-condition
905 '((type . application)(subtype . octet-stream)
907 (method . mime-detect-content)
910 (ctree-set-calist-with-default
911 'mime-acting-condition
913 (method . mime-save-content)))
915 (ctree-set-calist-strictly
916 'mime-acting-condition
917 '((type . text)(subtype . x-rot13-47)(mode . "play")
918 (method . mime-view-caesar)
920 (ctree-set-calist-strictly
921 'mime-acting-condition
922 '((type . text)(subtype . x-rot13-47-48)(mode . "play")
923 (method . mime-view-caesar)
926 (ctree-set-calist-strictly
927 'mime-acting-condition
928 '((type . message)(subtype . rfc822)(mode . "play")
929 (method . mime-view-message/rfc822)
931 (ctree-set-calist-strictly
932 'mime-acting-condition
933 '((type . message)(subtype . partial)(mode . "play")
934 (method . mime-store-message/partial-piece)
937 (ctree-set-calist-strictly
938 'mime-acting-condition
939 '((type . message)(subtype . external-body)
940 ("access-type" . "anon-ftp")
941 (method . mime-view-message/external-anon-ftp)
944 (ctree-set-calist-strictly
945 'mime-acting-condition
946 '((type . message)(subtype . external-body)
947 ("access-type" . "url")
948 (method . mime-view-message/external-url)
951 (ctree-set-calist-strictly
952 'mime-acting-condition
953 '((type . application)(subtype . octet-stream)
954 (method . mime-save-content)
958 ;;; @ quitting method
961 (defvar mime-preview-quitting-method-alist
962 '((mime-show-message-mode
963 . mime-preview-quitting-method-for-mime-show-message-mode))
964 "Alist of major-mode vs. quitting-method of mime-view.")
966 (defvar mime-preview-over-to-previous-method-alist nil
967 "Alist of major-mode vs. over-to-previous-method of mime-view.")
969 (defvar mime-preview-over-to-next-method-alist nil
970 "Alist of major-mode vs. over-to-next-method of mime-view.")
973 ;;; @ following method
976 (defvar mime-preview-following-method-alist nil
977 "Alist of major-mode vs. following-method of mime-view.")
979 (defvar mime-view-following-required-fields-list
986 (defun mime-display-entity (entity &optional situation
987 default-situation preview-buffer)
989 (setq preview-buffer (current-buffer)))
990 (let* (e nb ne nhb nbb)
991 (in-calist-package 'mime-view)
994 (mime-find-entity-preview-situation entity default-situation)))
995 (let ((button-is-invisible
996 (eq (cdr (or (assq '*entity-button situation)
997 (assq 'entity-button situation)))
1000 (eq (cdr (or (assq '*header situation)
1001 (assq 'header situation)))
1004 (eq (cdr (or (assq '*body situation)
1005 (assq 'body situation)))
1007 (children (mime-entity-children entity)))
1008 (set-buffer preview-buffer)
1010 (narrow-to-region nb nb)
1011 (or button-is-invisible
1012 ;; (if (mime-view-entity-button-visible-p entity)
1013 (mime-view-insert-entity-button entity)
1016 (if header-is-visible
1017 (let ((header-presentation-method
1018 (or (cdr (assq 'header-presentation-method situation))
1019 (cdr (assq (cdr (assq 'major-mode situation))
1020 mime-header-presentation-method-alist)))))
1022 (if header-presentation-method
1023 (funcall header-presentation-method entity situation)
1024 (mime-insert-header entity
1025 mime-view-ignored-field-list
1026 mime-view-visible-field-list))
1027 (run-hooks 'mime-display-header-hook)
1028 (put-text-property nhb (point-max) 'mime-view-entity-header entity)
1029 (goto-char (point-max))
1034 (let ((body-presentation-method
1035 (cdr (assq 'body-presentation-method situation))))
1036 (if (functionp body-presentation-method)
1037 (funcall body-presentation-method entity situation)
1038 (mime-display-text/plain entity situation)))
1039 (when button-is-invisible
1040 (goto-char (point-max))
1041 (mime-view-insert-entity-button entity)
1043 (unless header-is-visible
1044 (goto-char (point-max))
1047 (setq ne (point-max))
1049 (put-text-property nb ne 'mime-view-entity entity)
1050 (put-text-property nb ne 'mime-view-situation situation)
1051 (put-text-property nbb ne 'mime-view-entity-body entity)
1053 (if (and children body-is-visible)
1054 (let ((body-presentation-method
1055 (cdr (assq 'body-presentation-method situation))))
1056 (if (functionp body-presentation-method)
1057 (funcall body-presentation-method entity situation)
1058 (mime-display-multipart/mixed entity situation))))
1062 ;;; @ MIME viewer mode
1065 (defconst mime-view-menu-title "MIME-View")
1066 (defconst mime-view-menu-list
1067 '((up "Move to upper entity" mime-preview-move-to-upper)
1068 (previous "Move to previous entity" mime-preview-move-to-previous)
1069 (next "Move to next entity" mime-preview-move-to-next)
1070 (scroll-down "Scroll-down" mime-preview-scroll-down-entity)
1071 (scroll-up "Scroll-up" mime-preview-scroll-up-entity)
1072 (play "Play current entity" mime-preview-play-current-entity)
1073 (extract "Extract current entity" mime-preview-extract-current-entity)
1074 (print "Print current entity" mime-preview-print-current-entity)
1076 "Menu for MIME Viewer")
1078 (cond ((featurep 'xemacs)
1079 (defvar mime-view-xemacs-popup-menu
1080 (cons mime-view-menu-title
1083 (vector (nth 1 item)(nth 2 item) t)
1085 mime-view-menu-list)))
1086 (defun mime-view-xemacs-popup-menu (event)
1087 "Popup the menu in the MIME Viewer buffer"
1089 (select-window (event-window event))
1090 (set-buffer (event-buffer event))
1091 (popup-menu 'mime-view-xemacs-popup-menu))
1092 (defvar mouse-button-2 'button2)
1093 (defvar mouse-button-3 'button3)
1096 (defvar mime-view-popup-menu
1097 (let ((menu (make-sparse-keymap mime-view-menu-title)))
1101 (list (intern (nth 1 item)) 'menu-item
1102 (nth 1 item)(nth 2 item))
1104 mime-view-menu-list))))
1105 (defun mime-view-popup-menu (event)
1106 "Popup the menu in the MIME Viewer buffer"
1108 (let ((menu mime-view-popup-menu) events func)
1109 (setq events (x-popup-menu t menu))
1111 (setq func (lookup-key menu (apply #'vector events)))
1114 (defvar mouse-button-2 [mouse-2])
1115 (defvar mouse-button-3 [mouse-3])
1118 (defun mime-view-define-keymap (&optional default)
1119 (let ((mime-view-mode-map (if (keymapp default)
1120 (copy-keymap default)
1121 (make-sparse-keymap)
1123 (define-key mime-view-mode-map
1124 "u" (function mime-preview-move-to-upper))
1125 (define-key mime-view-mode-map
1126 "p" (function mime-preview-move-to-previous))
1127 (define-key mime-view-mode-map
1128 "n" (function mime-preview-move-to-next))
1129 (define-key mime-view-mode-map
1130 "\e\t" (function mime-preview-move-to-previous))
1131 (define-key mime-view-mode-map
1132 "\t" (function mime-preview-move-to-next))
1133 (define-key mime-view-mode-map
1134 " " (function mime-preview-scroll-up-entity))
1135 (define-key mime-view-mode-map
1136 "\M- " (function mime-preview-scroll-down-entity))
1137 (define-key mime-view-mode-map
1138 "\177" (function mime-preview-scroll-down-entity))
1139 (define-key mime-view-mode-map
1140 "\C-m" (function mime-preview-next-line-entity))
1141 (define-key mime-view-mode-map
1142 "\C-\M-m" (function mime-preview-previous-line-entity))
1143 (define-key mime-view-mode-map
1144 "v" (function mime-preview-play-current-entity))
1145 (define-key mime-view-mode-map
1146 "e" (function mime-preview-extract-current-entity))
1147 (define-key mime-view-mode-map
1148 "\C-c\C-p" (function mime-preview-print-current-entity))
1150 (define-key mime-view-mode-map
1151 "\C-c\C-t\C-f" (function mime-preview-toggle-header))
1152 (define-key mime-view-mode-map
1153 "\C-c\C-th" (function mime-preview-toggle-header))
1154 (define-key mime-view-mode-map
1155 "\C-c\C-t\C-c" (function mime-preview-toggle-content))
1157 (define-key mime-view-mode-map
1158 "\C-c\C-v\C-f" (function mime-preview-show-header))
1159 (define-key mime-view-mode-map
1160 "\C-c\C-vh" (function mime-preview-show-header))
1161 (define-key mime-view-mode-map
1162 "\C-c\C-v\C-c" (function mime-preview-show-content))
1164 (define-key mime-view-mode-map
1165 "\C-c\C-d\C-f" (function mime-preview-hide-header))
1166 (define-key mime-view-mode-map
1167 "\C-c\C-dh" (function mime-preview-hide-header))
1168 (define-key mime-view-mode-map
1169 "\C-c\C-d\C-c" (function mime-preview-hide-content))
1171 (define-key mime-view-mode-map
1172 "a" (function mime-preview-follow-current-entity))
1173 (define-key mime-view-mode-map
1174 "q" (function mime-preview-quit))
1175 (define-key mime-view-mode-map
1176 "\C-c\C-x" (function mime-preview-kill-buffer))
1177 ;; (define-key mime-view-mode-map
1178 ;; "<" (function beginning-of-buffer))
1179 ;; (define-key mime-view-mode-map
1180 ;; ">" (function end-of-buffer))
1181 (define-key mime-view-mode-map
1182 "?" (function describe-mode))
1183 (define-key mime-view-mode-map
1184 [tab] (function mime-preview-move-to-next))
1185 (define-key mime-view-mode-map
1186 [delete] (function mime-preview-scroll-down-entity))
1187 (define-key mime-view-mode-map
1188 [backspace] (function mime-preview-scroll-down-entity))
1189 (if (functionp default)
1190 (cond ((featurep 'xemacs)
1191 (set-keymap-default-binding mime-view-mode-map default)
1194 (setq mime-view-mode-map
1195 (append mime-view-mode-map (list (cons t default))))
1198 (define-key mime-view-mode-map
1199 mouse-button-2 (function mime-button-dispatcher))
1201 (cond ((featurep 'xemacs)
1202 (define-key mime-view-mode-map
1203 mouse-button-3 (function mime-view-xemacs-popup-menu))
1205 ((>= emacs-major-version 19)
1206 (define-key mime-view-mode-map
1207 mouse-button-3 (function mime-view-popup-menu))
1208 (define-key mime-view-mode-map [menu-bar mime-view]
1209 (cons mime-view-menu-title
1210 (make-sparse-keymap mime-view-menu-title)))
1213 (define-key mime-view-mode-map
1214 (vector 'menu-bar 'mime-view (car item))
1215 (cons (nth 1 item)(nth 2 item))
1218 (reverse mime-view-menu-list)
1221 (use-local-map mime-view-mode-map)
1222 (run-hooks 'mime-view-define-keymap-hook)
1225 (defsubst mime-maybe-hide-echo-buffer ()
1226 "Clear mime-echo buffer and delete window for it."
1227 (let ((buf (get-buffer mime-echo-buffer-name)))
1232 (let ((win (get-buffer-window buf)))
1239 (defvar mime-view-redisplay nil)
1242 (defun mime-display-message (message &optional preview-buffer
1243 mother default-keymap-or-function
1244 original-major-mode)
1245 "View MESSAGE in MIME-View mode.
1247 Optional argument PREVIEW-BUFFER specifies the buffer of the
1248 presentation. It must be either nil or a name of preview buffer.
1250 Optional argument MOTHER specifies mother-buffer of the preview-buffer.
1252 Optional argument DEFAULT-KEYMAP-OR-FUNCTION is nil, keymap or
1253 function. If it is a keymap, keymap of MIME-View mode will be added
1254 to it. If it is a function, it will be bound as default binding of
1255 keymap of MIME-View mode."
1256 (mime-maybe-hide-echo-buffer)
1257 (let ((win-conf (current-window-configuration)))
1259 (setq preview-buffer
1260 (concat "*Preview-" (mime-entity-name message) "*")))
1261 (or original-major-mode
1262 (setq original-major-mode major-mode))
1263 (let ((inhibit-read-only t))
1264 (set-buffer (get-buffer-create preview-buffer))
1268 (setq mime-mother-buffer mother)
1270 (setq mime-preview-original-window-configuration win-conf)
1271 (setq major-mode 'mime-view-mode)
1272 (setq mode-name "MIME-View")
1273 (mime-display-entity message nil
1274 `((entity-button . invisible)
1276 (major-mode . ,original-major-mode))
1278 (mime-view-define-keymap default-keymap-or-function)
1280 (next-single-property-change (point-min) 'mime-view-entity)))
1283 (goto-char (point-min))
1284 (search-forward "\n\n" nil t)
1286 (run-hooks 'mime-view-mode-hook)
1287 (set-buffer-modified-p nil)
1288 (setq buffer-read-only t)
1292 (defun mime-view-buffer (&optional raw-buffer preview-buffer mother
1293 default-keymap-or-function
1294 representation-type)
1295 "View RAW-BUFFER in MIME-View mode.
1296 Optional argument PREVIEW-BUFFER is either nil or a name of preview
1298 Optional argument DEFAULT-KEYMAP-OR-FUNCTION is nil, keymap or
1299 function. If it is a keymap, keymap of MIME-View mode will be added
1300 to it. If it is a function, it will be bound as default binding of
1301 keymap of MIME-View mode.
1302 Optional argument REPRESENTATION-TYPE is representation-type of
1303 message. It must be nil, `binary' or `cooked'. If it is nil,
1304 `cooked' is used as default."
1307 (setq raw-buffer (current-buffer)))
1308 (or representation-type
1309 (setq representation-type
1311 (set-buffer raw-buffer)
1312 (cdr (or (assq major-mode mime-raw-representation-type-alist)
1313 (assq t mime-raw-representation-type-alist)))
1315 (if (eq representation-type 'binary)
1316 (setq representation-type 'buffer)
1318 (setq preview-buffer (mime-display-message
1319 (mime-open-entity representation-type raw-buffer)
1320 preview-buffer mother default-keymap-or-function))
1321 (or (get-buffer-window preview-buffer)
1322 (let ((r-win (get-buffer-window raw-buffer)))
1324 (set-window-buffer r-win preview-buffer)
1325 (let ((m-win (and mother (get-buffer-window mother))))
1327 (set-window-buffer m-win preview-buffer)
1328 (switch-to-buffer preview-buffer)
1331 (defun mime-view-mode (&optional mother ctl encoding
1332 raw-buffer preview-buffer
1333 default-keymap-or-function)
1334 "Major mode for viewing MIME message.
1336 Here is a list of the standard keys for mime-view-mode.
1341 u Move to upper content
1342 p or M-TAB Move to previous content
1343 n or TAB Move to next content
1344 SPC Scroll up or move to next content
1345 M-SPC or DEL Scroll down or move to previous content
1346 RET Move to next line
1347 M-RET Move to previous line
1348 v Decode current content as `play mode'
1349 e Decode current content as `extract mode'
1350 C-c C-p Decode current content as `print mode'
1351 a Followup to current content.
1353 button-2 Move to point under the mouse cursor
1354 and decode current content as `play mode'
1357 (unless mime-view-redisplay
1359 (if raw-buffer (set-buffer raw-buffer))
1362 (or (assq major-mode mime-raw-representation-type-alist)
1363 (assq t mime-raw-representation-type-alist)))))
1364 (if (eq type 'binary)
1367 (setq mime-message-structure (mime-open-entity type raw-buffer))
1368 (or (mime-entity-content-type mime-message-structure)
1369 (mime-entity-set-content-type mime-message-structure ctl))
1371 (or (mime-entity-encoding mime-message-structure)
1372 (mime-entity-set-encoding mime-message-structure encoding))
1374 (mime-display-message mime-message-structure preview-buffer
1375 mother default-keymap-or-function)
1382 (defun mime-preview-find-boundary-info (&optional get-mother)
1386 (while (null (setq entity
1387 (get-text-property (point) 'mime-view-entity)))
1389 (setq p-beg (previous-single-property-change (point) 'mime-view-entity))
1390 (setq entity-node-id (mime-entity-node-id entity))
1391 (setq len (length entity-node-id))
1394 (if (eq (next-single-property-change (point-min)
1400 ((eq (next-single-property-change p-beg 'mime-view-entity)
1402 (setq p-beg (point))
1404 (setq p-end (next-single-property-change p-beg 'mime-view-entity))
1406 (setq p-end (point-max))
1408 ((null entity-node-id)
1409 (setq p-end (point-max))
1417 (next-single-property-change
1418 (point) 'mime-view-entity))
1420 (let ((rc (mime-entity-node-id
1421 (get-text-property (1- (point))
1422 'mime-view-entity))))
1423 (or (and (>= (setq i (- (length rc) len)) 0)
1424 (equal entity-node-id (nthcdr i rc)))
1427 (setq p-end (point-max))))
1429 (vector p-beg p-end entity)))
1435 (autoload 'mime-preview-play-current-entity "mime-play"
1436 "Play current entity." t)
1438 (defun mime-preview-extract-current-entity (&optional ignore-examples)
1439 "Extract current entity into file (maybe).
1440 It decodes current entity to call internal or external method as
1441 \"extract\" mode. The method is selected from variable
1442 `mime-acting-condition'."
1444 (mime-preview-play-current-entity ignore-examples "extract")
1447 (defun mime-preview-print-current-entity (&optional ignore-examples)
1448 "Print current entity (maybe).
1449 It decodes current entity to call internal or external method as
1450 \"print\" mode. The method is selected from variable
1451 `mime-acting-condition'."
1453 (mime-preview-play-current-entity ignore-examples "print")
1460 (defun mime-preview-follow-current-entity ()
1461 "Write follow message to current entity.
1462 It calls following-method selected from variable
1463 `mime-preview-following-method-alist'."
1465 (let ((entity (mime-preview-find-boundary-info t))
1468 (setq p-beg (aref entity 0)
1469 p-end (aref entity 1)
1470 entity (aref entity 2))
1471 (if (get-text-property p-beg 'mime-view-entity-body)
1474 (next-single-property-change
1475 p-beg 'mime-view-entity-body nil
1476 (or (next-single-property-change p-beg 'mime-view-entity)
1478 (let* ((mode (mime-preview-original-major-mode 'recursive))
1479 (entity-node-id (mime-entity-node-id entity))
1481 (format "%s-%s" (buffer-name) (reverse entity-node-id)))
1483 (the-buf (current-buffer))
1486 (set-buffer (setq new-buf (get-buffer-create new-name)))
1489 (insert-buffer-substring the-buf pb-beg p-end)
1490 (goto-char (point-min))
1491 (let ((current-entity
1492 (if (and (eq (mime-entity-media-type entity) 'message)
1493 (eq (mime-entity-media-subtype entity) 'rfc822))
1494 (car (mime-entity-children entity))
1496 (while (and current-entity
1497 (if (and (eq (mime-entity-media-type
1498 current-entity) 'message)
1499 (eq (mime-entity-media-subtype
1500 current-entity) 'rfc822))
1502 (mime-insert-header current-entity fields)
1504 (setq fields (std11-collect-field-names)
1505 current-entity (mime-entity-parent current-entity))
1507 (let ((rest mime-view-following-required-fields-list)
1510 (setq field-name (car rest))
1511 (or (std11-field-body field-name)
1514 (set-buffer the-buf)
1515 (let ((entity (when mime-mother-buffer
1516 (set-buffer mime-mother-buffer)
1517 (get-text-property (point)
1518 'mime-view-entity))))
1520 (null (setq ret (mime-entity-fetch-field
1521 entity field-name))))
1522 (setq entity (mime-entity-parent entity)))))
1524 (insert (concat field-name ": " ret "\n"))
1526 (setq rest (cdr rest))
1529 (let ((f (cdr (assq mode mime-preview-following-method-alist))))
1534 "Sorry, following method for %s is not implemented yet."
1543 (defun mime-preview-move-to-upper ()
1544 "Move to upper entity.
1545 If there is no upper entity, call function `mime-preview-quit'."
1548 (while (null (setq cinfo
1549 (get-text-property (point) 'mime-view-entity)))
1552 (let ((r (mime-entity-parent cinfo))
1555 (while (setq point (previous-single-property-change
1556 (point) 'mime-view-entity))
1558 (when (eq r (get-text-property (point) 'mime-view-entity))
1559 (if (or (eq mime-preview-move-scroll t)
1560 (and mime-preview-move-scroll
1563 (move-to-window-line -1)
1564 (forward-line (* -1 next-screen-context-lines))
1567 (recenter next-screen-context-lines))
1574 (defun mime-preview-move-to-previous ()
1575 "Move to previous entity.
1576 If there is no previous entity, it calls function registered in
1577 variable `mime-preview-over-to-previous-method-alist'."
1579 (while (and (not (bobp))
1580 (null (get-text-property (point) 'mime-view-entity)))
1583 (let ((point (previous-single-property-change (point) 'mime-view-entity)))
1585 (>= point (point-min)))
1586 (if (get-text-property (1- point) 'mime-view-entity)
1587 (progn (goto-char point)
1589 (or (eq mime-preview-move-scroll t)
1590 (and mime-preview-move-scroll
1593 (move-to-window-line 0)
1594 (forward-line next-screen-context-lines)
1597 (recenter (* -1 next-screen-context-lines))))
1598 (goto-char (1- point))
1599 (mime-preview-move-to-previous)
1601 (let ((f (assq (mime-preview-original-major-mode)
1602 mime-preview-over-to-previous-method-alist)))
1608 (defun mime-preview-move-to-next ()
1609 "Move to next entity.
1610 If there is no previous entity, it calls function registered in
1611 variable `mime-preview-over-to-next-method-alist'."
1613 (while (and (not (eobp))
1614 (null (get-text-property (point) 'mime-view-entity)))
1617 (let ((point (next-single-property-change (point) 'mime-view-entity)))
1619 (<= point (point-max)))
1622 (if (null (get-text-property point 'mime-view-entity))
1623 (mime-preview-move-to-next)
1625 (or (eq mime-preview-move-scroll t)
1626 (and mime-preview-move-scroll
1629 (move-to-window-line -1)
1631 (* -1 next-screen-context-lines))
1634 (recenter next-screen-context-lines))
1636 (let ((f (assq (mime-preview-original-major-mode)
1637 mime-preview-over-to-next-method-alist)))
1643 (defun mime-preview-scroll-up-entity (&optional h)
1644 "Scroll up current entity.
1645 If reached to (point-max), it calls function registered in variable
1646 `mime-preview-over-to-next-method-alist'."
1649 (let ((f (assq (mime-preview-original-major-mode)
1650 mime-preview-over-to-next-method-alist)))
1655 (or (next-single-property-change (point) 'mime-view-entity)
1657 (bottom (window-end (selected-window))))
1660 (progn (goto-char point)
1661 (recenter next-screen-context-lines))
1665 (goto-char (point-max)))))
1668 (defun mime-preview-scroll-down-entity (&optional h)
1669 "Scroll down current entity.
1670 If reached to (point-min), it calls function registered in variable
1671 `mime-preview-over-to-previous-method-alist'."
1674 (let ((f (assq (mime-preview-original-major-mode)
1675 mime-preview-over-to-previous-method-alist)))
1680 (or (previous-single-property-change (point) 'mime-view-entity)
1682 (top (window-start (selected-window))))
1685 (progn (goto-char point)
1686 (recenter (* -1 next-screen-context-lines)))
1689 (beginning-of-buffer
1690 (goto-char (point-min)))))
1693 (defun mime-preview-next-line-entity (&optional lines)
1694 "Scroll up one line (or prefix LINES lines).
1695 If LINES is negative, scroll down LINES lines."
1697 (mime-preview-scroll-up-entity (or lines 1))
1700 (defun mime-preview-previous-line-entity (&optional lines)
1701 "Scrroll down one line (or prefix LINES lines).
1702 If LINES is negative, scroll up LINES lines."
1704 (mime-preview-scroll-down-entity (or lines 1))
1711 (defun mime-preview-toggle-display (type &optional display)
1712 (let ((situation (mime-preview-find-boundary-info))
1713 (sym (intern (concat "*" (symbol-name type))))
1715 (setq p-beg (aref situation 0)
1716 p-end (aref situation 1)
1717 entity (aref situation 2)
1718 situation (get-text-property p-beg 'mime-view-situation))
1719 (cond ((eq display 'invisible)
1724 (eq (cdr (or (assq sym situation)
1725 (assq type situation)))
1727 (setq situation (put-alist sym (if display
1732 (let ((inhibit-read-only t))
1733 (delete-region p-beg p-end)
1734 (mime-display-entity entity situation)))
1735 (let ((ret (assoc situation mime-preview-situation-example-list)))
1737 (setcdr ret (1+ (cdr ret)))
1738 (add-to-list 'mime-preview-situation-example-list
1739 (cons situation 0))))))
1741 (defun mime-preview-toggle-header (&optional force-visible)
1743 (mime-preview-toggle-display 'header force-visible))
1745 (defun mime-preview-toggle-content (&optional force-visible)
1747 (mime-preview-toggle-display 'body force-visible))
1749 (defun mime-preview-show-header ()
1751 (mime-preview-toggle-display 'header 'visible))
1753 (defun mime-preview-show-content ()
1755 (mime-preview-toggle-display 'body 'visible))
1757 (defun mime-preview-hide-header ()
1759 (mime-preview-toggle-display 'header 'invisible))
1761 (defun mime-preview-hide-content ()
1763 (mime-preview-toggle-display 'body 'invisible))
1769 (defun mime-preview-quit ()
1770 "Quit from MIME-preview buffer.
1771 It calls function registered in variable
1772 `mime-preview-quitting-method-alist'."
1774 (let ((r (assq (mime-preview-original-major-mode)
1775 mime-preview-quitting-method-alist)))
1780 (defun mime-preview-kill-buffer ()
1782 (kill-buffer (current-buffer))
1789 (provide 'mime-view)
1791 (let ((file mime-situation-examples-file))
1792 (if (file-readable-p file)
1794 (insert-file-contents file)
1795 (setq mime-situation-examples-file-coding-system
1796 (and (boundp 'buffer-file-coding-system)
1797 buffer-file-coding-system)
1799 ;; ((boundp 'buffer-file-coding-system)
1800 ;; (symbol-value 'buffer-file-coding-system))
1801 ;; ((boundp 'file-coding-system)
1802 ;; (symbol-value 'file-coding-system))
1809 (while (and (> (length mime-preview-situation-example-list)
1810 mime-preview-situation-example-list-max-size)
1812 (setq mime-preview-situation-example-list
1813 (mime-reduce-situation-examples
1814 mime-preview-situation-example-list))
1816 (error (setq mime-preview-situation-example-list nil)))
1817 ;; (let ((rest mime-preview-situation-example-list))
1819 ;; (ctree-set-calist-strictly 'mime-preview-condition
1821 ;; (setq rest (cdr rest))))
1824 (while (and (> (length mime-acting-situation-example-list)
1825 mime-acting-situation-example-list-max-size)
1827 (setq mime-acting-situation-example-list
1828 (mime-reduce-situation-examples
1829 mime-acting-situation-example-list))
1831 (error (setq mime-acting-situation-example-list nil))))))
1833 ;;; mime-view.el ends here