2 ;;; tm-view.el --- interactive MIME viewer for GNU Emacs
4 ;;; Copyright (C) 1995 Free Software Foundation, Inc.
5 ;;; Copyright (C) 1994,1995 MORIOKA Tomohiko
7 ;;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
8 ;;; modified by Steven L. Baur <steve@miranova.com>
9 ;;; Maintainer: MORIOKA Tomohiko <morioka@jaist.ac.jp>
10 ;;; Created: 1994/7/13 (1994/8/31 obsolete tm-body.el)
11 ;;; Version: $Revision: 7.32.1.2 $
12 ;;; Keywords: mail, news, MIME, multimedia
14 ;;; This file is part of tm (Tools for MIME).
16 ;;; This program is free software; you can redistribute it and/or
17 ;;; modify it under the terms of the GNU General Public License as
18 ;;; published by the Free Software Foundation; either version 2, or
19 ;;; (at your option) any later version.
21 ;;; This program is distributed in the hope that it will be useful,
22 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
23 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 ;;; General Public License for more details.
26 ;;; You should have received a copy of the GNU General Public License
27 ;;; along with This program. If not, write to the Free Software
28 ;;; Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
46 (defconst mime-viewer/RCS-ID
47 "$Id: tm-view.el,v 7.32.1.2 1995/12/10 20:29:06 morioka Exp $")
49 (defconst mime-viewer/version (get-version-string mime-viewer/RCS-ID))
50 (defconst mime/viewer-version mime-viewer/version)
56 (defvar mime/content-decoding-condition
57 '(((type . "text/plain")
58 (method "tm-plain" nil 'file 'type 'encoding 'mode 'name))
60 (method "tm-html" nil 'file 'type 'encoding 'mode 'name)
62 ((type . "text/x-rot13-47")
63 (method . mime-article/decode-caesar))
65 ((type . "audio/basic")
66 (method "tm-au" nil 'file 'type 'encoding 'mode 'name))
69 (method "tm-image" nil 'file 'type 'encoding 'mode 'name))
70 ((type . "image/jpeg")
71 (method "tm-image" nil 'file 'type 'encoding 'mode 'name))
72 ((type . "image/tiff")
73 (method "tm-image" nil 'file 'type 'encoding 'mode 'name))
74 ((type . "image/x-tiff")
75 (method "tm-image" nil 'file 'type 'encoding 'mode 'name))
76 ((type . "image/x-xbm")
77 (method "tm-image" nil 'file 'type 'encoding 'mode 'name))
78 ((type . "image/x-pic")
79 (method "tm-image" nil 'file 'type 'encoding 'mode 'name))
81 ((type . "video/mpeg")
82 (method "tm-mpeg" nil 'file 'type 'encoding 'mode 'name))
84 ((type . "application/octet-stream")
85 (method "tm-file" nil 'file 'type 'encoding 'mode 'name))
87 ;;((type . "message/external-body")
88 ;; (method "xterm" nil
89 ;; "-e" "showexternal"
90 ;; 'file '"access-type" '"name" '"site" '"directory"))
91 ((type . "message/rfc822")
92 (method . mime-article/view-message/rfc822))
93 ((type . "message/partial")
94 (method . mime-article/decode-message/partial))
97 "-m" "tm" "-x" "-d" "-z" "-e" 'file)(mode . "play"))
98 ((method "tm-file" nil 'file 'type 'encoding 'mode 'name)
102 (defvar mime-viewer/childrens-header-showing-Content-Type-list
103 '("message/rfc822" "message/news"))
105 (defvar mime-viewer/default-showing-Content-Type-list
106 '("text/plain" "text/richtext" "text/enriched"
107 "text/x-latex" "application/x-latex"
108 "application/octet-stream" nil
110 "application/x-selection" "application/x-comment"))
112 (defvar mime-viewer/content-subject-omitting-Content-Type-list
113 '("application/x-selection"))
115 (defvar mime-viewer/content-subject-showing-Content-Type-list
116 '("application/pgp"))
118 (defvar mime-viewer/uuencode-encoding-name-list '("x-uue" "x-uuencode"))
120 (defvar mime-viewer/ignored-field-list
121 '(".*Received" "Return-Path" "Replied" "Errors-To"
122 "Lines" "Sender" "Path" "Nntp-Posting-Host"
123 "Content-Type" "Precedence" "X-Face"
125 "All fields that match this list will be hidden in MIME preview buffer.
126 Each elements are regexp of field-name. [tm-view.el]")
128 (defvar mime-viewer/ignored-field-regexp
130 (apply (function regexp-or) mime-viewer/ignored-field-list)
133 (defvar mime-viewer/announcement-for-message/partial
134 (if (and (>= emacs-major-version 19) window-system)
136 \[[ This is message/partial style split message. ]]
137 \[[ Please press `v' key in this buffer ]]
138 \[[ or click here by mouse button-2. ]]"
140 \[[ This is message/partial style split message. ]]
141 \[[ Please press `v' key in this buffer. ]]"
145 ;;; @@ predicate functions
148 (defun mime-viewer/header-visible-p (rcnum cinfo &optional ctype)
152 (mime::content-info/type
153 (mime-article/rcnum-to-cinfo (cdr rcnum) cinfo)
155 (member ctype mime-viewer/childrens-header-showing-Content-Type-list)
158 (defun mime-viewer/body-visible-p (rcnum cinfo &optional ctype)
162 (mime::content-info/type
163 (setq ccinfo (mime-article/rcnum-to-cinfo rcnum cinfo))
166 (and (member ctype mime-viewer/default-showing-Content-Type-list)
167 (if (string-equal ctype "application/octet-stream")
170 (setq ccinfo (mime-article/rcnum-to-cinfo rcnum cinfo))
172 (member (mime::content-info/encoding ccinfo)
173 '(nil "7bit" "8bit"))
179 ;;; @@ content subject
182 (defun mime-viewer/insert-content-subject
183 (rcnum cinfo ctype params subj)
185 (narrow-to-region (point)(point))
187 (let ((access-type (assoc "access-type" params))
188 (num (or (assoc-value "x-part-number" params)
192 (format "%s" (1+ num))
198 (let ((server (assoc "server" params)))
199 (setq access-type (cdr access-type))
201 (format "[%s %s ([%s] %s)]\n" num subj
202 access-type (cdr server))
203 (let ((site (assoc-value "site" params))
204 (dir (assoc-value "directory" params))
206 (format "[%s %s ([%s] %s:%s)]\n" num subj
207 access-type site dir)
209 (format "[%s %s (%s)]\n" num subj ctype)
211 (tm:add-button (point-min)(1- (point-max))
212 (function mime-viewer/play-content))
215 (defun mime-viewer/default-content-subject-function
216 (rcnum cinfo ctype params subj)
217 (if (and (consp rcnum)
220 mime-viewer/content-subject-omitting-Content-Type-list)))
221 (mime-viewer/insert-content-subject
222 rcnum cinfo ctype params subj)
225 (defvar mime-viewer/content-subject-function
226 (function mime-viewer/default-content-subject-function))
229 ;;; @@ content header filter
232 (defun mime-viewer/default-content-header-filter ()
233 (goto-char (point-min))
234 (while (and (re-search-forward mime-viewer/ignored-field-regexp nil t)
240 (re-search-forward "^\\([^ \t]\\|$\\)" nil t)
244 (mime/decode-message-header)
247 (defvar mime-viewer/content-header-filter-alist nil)
250 ;;; @@ content filter
253 (defvar mime-viewer/content-filter-alist
254 '(("text/plain" . mime-viewer/filter-text/plain)
255 ("application/pgp" . mime-viewer/filter-text/plain)
256 (nil . mime-viewer/filter-text/plain)))
258 (defun mime-viewer/default-content-filter (rcnum cinfo ctype params subj)
262 ;;; @@ content separator
265 (defun mime-viewer/default-content-separator (rcnum cinfo ctype params subj)
266 (if (and (not (mime-viewer/header-visible-p rcnum cinfo ctype))
267 (not (mime-viewer/body-visible-p rcnum cinfo ctype))
270 (goto-char (point-max))
275 ;;; @@ buffer local variables
279 (defvar mime::article/preview-buffer nil)
280 (defvar mime::article/code-converter nil)
282 (make-variable-buffer-local 'mime::article/content-info)
283 (make-variable-buffer-local 'mime::article/preview-buffer)
284 (make-variable-buffer-local 'mime::article/code-converter)
286 (make-variable-buffer-local 'mime::preview/mother-buffer)
287 (make-variable-buffer-local 'mime::preview/content-list)
288 (make-variable-buffer-local 'mime::preview/article-buffer)
289 (make-variable-buffer-local 'mime::preview/original-major-mode)
290 (make-variable-buffer-local 'mime::preview/original-window-configuration)
293 ;;; @@ quitting method
296 (defvar mime-viewer/quitting-method-alist
297 '((mime/show-message-mode
298 . mime-viewer/quitting-method-for-mime/show-message-mode)))
300 (defvar mime-viewer/over-to-previous-method-alist nil)
301 (defvar mime-viewer/over-to-next-method-alist nil)
307 ;; hack from Gnus 5.0.4.
309 (defvar mime-viewer/x-face-command
310 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -"
311 "String to be executed to display an X-Face field.
312 The command will be executed in a sub-shell asynchronously.
313 The compressed face will be piped to this command.")
315 (defun mime-viewer/x-face-function ()
316 "Function to display X-Face field. You can redefine to customize."
317 ;; 1995/10/12 (c.f. tm-eng:130)
318 ;; fixed by Eric Ding <ericding@San-Jose.ate.slb.com>
320 (narrow-to-region (point-min) (re-search-forward "^$" nil t))
322 (goto-char (point-min))
323 (if (re-search-forward "^X-Face:[ \t]*" nil t)
324 (let ((beg (match-end 0))
325 (end (rfc822/field-end))
327 (call-process-region beg end "sh" nil 0 nil
328 "-c" mime-viewer/x-face-command)
332 ;;; @ data structures
335 ;;; @@ preview-content-info
338 (define-structure mime::preview-content-info
339 point-min point-max buffer content-info)
345 (defun mime-viewer/setup-buffer (&optional ctl encoding ibuf obuf)
351 (setq mime::article/content-info (mime/parse-message ctl encoding))
352 (let ((ret (mime-viewer/make-preview-buffer obuf)))
353 (setq mime::article/preview-buffer (car ret))
356 (defun mime-viewer/make-preview-buffer (&optional obuf)
357 (let ((cinfo mime::article/content-info)
358 (the-buf (current-buffer))
362 (setq obuf (concat "*Preview-" (buffer-name the-buf) "*"))
364 (setq pcl (mime/flatten-content-info cinfo))
365 (let ((bf (get-buffer obuf)))
369 (setq buffer-read-only nil)
372 (setq bf (get-buffer-create obuf))
375 (setq mime::preview/article-buffer the-buf)
376 (setq mime::preview/original-major-mode mode)
377 (setq major-mode 'mime/viewer-mode)
378 (setq mode-name "MIME-View")
383 (mime-viewer/display-content content cinfo the-buf obuf)
386 (set-buffer-modified-p nil)
387 (setq buffer-read-only t)
392 (defun mime-viewer/display-content (content cinfo ibuf obuf)
393 (let* ((beg (mime::content-info/point-min content))
394 (end (mime::content-info/point-max content))
395 (ctype (mime::content-info/type content))
396 (params (mime::content-info/parameters content))
397 (encoding (mime::content-info/encoding content))
398 (rcnum (mime::content-info/rcnum content))
402 (setq he (if (re-search-forward "^$" nil t)
409 (narrow-to-region beg end)
411 (mime-eword/decode-string
412 (mime-viewer/get-subject params encoding)))
416 (narrow-to-region nb nb)
417 (funcall mime-viewer/content-subject-function
418 rcnum cinfo ctype params subj)
420 (if (mime-viewer/header-visible-p rcnum cinfo ctype)
421 (mime-viewer/display-header beg he obuf)
423 (if (and (null rcnum)
425 ctype mime-viewer/content-subject-showing-Content-Type-list))
428 (goto-char (point-max))
429 (mime-viewer/insert-content-subject rcnum cinfo ctype params subj)
431 (cond ((mime-viewer/body-visible-p rcnum cinfo ctype)
432 (mime-viewer/display-body he end obuf
433 rcnum cinfo ctype params subj encoding)
435 ((equal ctype "message/partial")
436 (mime-viewer/display-message/partial obuf)
439 (null (mime::content-info/children cinfo))
442 (goto-char (point-max))
443 (mime-viewer/insert-content-subject rcnum cinfo ctype params subj)
445 (t (set-buffer obuf))
447 (mime-viewer/default-content-separator rcnum cinfo ctype params subj)
450 (setq ne (point-max))
452 (mime::preview-content-info/create nb (1- ne) ibuf content)
457 (defun mime-viewer/display-header (beg end obuf)
458 (let ((str (buffer-substring beg end))
459 (f (assq major-mode mime-viewer/content-header-filter-alist))
464 (narrow-to-region (point)(point))
466 (if (and f (setq f (cdr f)))
468 (mime-viewer/default-content-header-filter)
470 (run-hooks 'mime-viewer/content-header-filter-hook)
473 (defun mime-viewer/display-body (beg end obuf
474 rcnum cinfo ctype params subj encoding)
475 (let ((str (buffer-substring beg end))
479 (setq be (point-max))
480 (narrow-to-region be be)
482 (let ((f (assoc-value ctype mime-viewer/content-filter-alist)))
483 (if (and f (fboundp f))
484 (funcall f ctype params encoding)
485 (mime-viewer/default-content-filter rcnum cinfo ctype params subj)
489 (defun mime-viewer/display-message/partial (obuf)
492 (goto-char (point-max))
493 (if (not (search-backward "\n\n" nil t))
496 (let ((be (point-max)))
497 (narrow-to-region be be)
498 (insert mime-viewer/announcement-for-message/partial)
499 (tm:add-button (point-min)(point-max)
500 (function mime-viewer/play-content))
503 (defun mime-viewer/get-subject (param &optional encoding)
504 (if (member (or encoding
505 (cdr (assq 'encoding param))
507 mime-viewer/uuencode-encoding-name-list)
509 (or (if (re-search-forward "^begin [0-9]+ " nil t)
510 (if (looking-at ".+$")
511 (buffer-substring (match-beginning 0)(match-end 0))
515 (or (and (setq ret (assoc "name" param))
516 (rfc822/strip-quoted-string (cdr ret))
518 (and (setq ret (assoc "x-name" param))
519 (rfc822/strip-quoted-string (cdr ret))
524 (goto-char (point-min))
525 (narrow-to-region (point-min)
526 (or (and (search-forward "\n\n" nil t)
531 (rfc822/get-field-body "Content-Description")
532 (rfc822/get-field-body "Subject")
538 ;;; @ content information
541 (defun mime-article/point-content-number (p &optional cinfo)
543 (setq cinfo mime::article/content-info)
545 (let ((b (mime::content-info/point-min cinfo))
546 (e (mime::content-info/point-max cinfo))
547 (c (mime::content-info/children cinfo))
549 (if (and (<= b p)(<= p e))
550 (or (let (co ret (sn 0))
554 (setq ret (mime-article/point-content-number p co))
555 (cond ((eq ret t) (throw 'tag (list sn)))
556 (ret (throw 'tag (cons sn ret)))
563 (defun mime-article/rcnum-to-cinfo (rcnum &optional cinfo)
565 (setq cinfo mime::article/content-info)
570 (equal (mime::content-info/rcnum ci) rcnum)
572 (mime/flatten-content-info cinfo)
575 (defun mime-article/cnum-to-cinfo (cn &optional cinfo)
577 (setq cinfo mime::article/content-info)
584 (let ((rc (nth sn (mime::content-info/children cinfo))))
586 (mime-article/cnum-to-cinfo (cdr cn) rc)
590 (defun mime/flatten-content-info (&optional cinfo)
592 (setq cinfo mime::article/content-info)
594 (let ((dest (list cinfo))
595 (rcl (mime::content-info/children cinfo))
598 (setq dest (nconc dest (mime/flatten-content-info (car rcl))))
603 (defun mime-preview/point-pcinfo (p &optional pcl)
605 (setq pcl mime::preview/content-list)
611 (if (and (<= (mime::preview-content-info/point-min cell) p)
612 (<= p (mime::preview-content-info/point-max cell))
625 (defvar mime-viewer/code-converter-alist
626 '((mime/show-message-mode . mime/code-convert-region-to-emacs))
629 (defun mime-viewer/default-code-convert-region
630 (beg end charset &optional encoding)
631 (if (member encoding '("quoted-printable" "base64"))
632 (mime/code-convert-region-to-emacs beg (point-max) charset)
635 (defun mime-preview/decode-text-region (beg end charset encoding)
636 (mime/decode-region encoding beg end)
637 (let* ((mode mime::preview/original-major-mode)
638 (m (or (save-excursion
639 (set-buffer mime::preview/article-buffer)
640 mime::article/code-converter)
641 (cdr (assq mode mime-viewer/code-converter-alist))
644 (if (and m (fboundp m))
645 (funcall m beg (point-max) charset encoding)
646 (mime-viewer/default-code-convert-region
647 beg (point-max) charset encoding)
650 (defun mime-viewer/filter-text/plain (ctype params encoding)
651 (let ((charset (cdr (assoc "charset" params)))
652 (beg (point-min)) (end (point-max))
654 (mime-preview/decode-text-region beg end charset encoding)
656 (goto-char (point-max))
657 (if (not (eq (char-after (1- (point))) ?\n))
660 (if browse-url-browser-function
662 (goto-char (point-min))
663 (while (re-search-forward tm:URL-regexp nil t)
664 (tm:add-button (match-beginning 0)(match-end 0)
665 (function tm:browse-url))
667 (run-hooks 'mime-viewer/plain-text-preview-hook)
671 ;;; @ MIME viewer mode
674 (defvar mime/viewer-mode-map nil)
675 (if (null mime/viewer-mode-map)
677 (setq mime/viewer-mode-map (make-keymap))
678 (suppress-keymap mime/viewer-mode-map)
679 (define-key mime/viewer-mode-map
680 "u" (function mime-viewer/up-content))
681 (define-key mime/viewer-mode-map
682 "p" (function mime-viewer/previous-content))
683 (define-key mime/viewer-mode-map
684 "n" (function mime-viewer/next-content))
685 (define-key mime/viewer-mode-map
686 " " (function mime-viewer/scroll-up-content))
687 (define-key mime/viewer-mode-map
688 "\M- " (function mime-viewer/scroll-down-content))
689 (define-key mime/viewer-mode-map
690 "\177" (function mime-viewer/scroll-down-content))
691 (define-key mime/viewer-mode-map
692 "\C-m" (function mime-viewer/next-line-content))
693 (define-key mime/viewer-mode-map
694 "\C-\M-m" (function mime-viewer/previous-line-content))
695 (define-key mime/viewer-mode-map
696 "v" (function mime-viewer/play-content))
697 (define-key mime/viewer-mode-map
698 "e" (function mime-viewer/extract-content))
699 (define-key mime/viewer-mode-map
700 "\C-c\C-p" (function mime-viewer/print-content))
701 (define-key mime/viewer-mode-map
702 "f" (function mime-viewer/display-x-face))
703 (define-key mime/viewer-mode-map
704 "q" (function mime-viewer/quit))
705 (define-key mime/viewer-mode-map
706 "\C-c\C-x" (function mime-viewer/kill-buffer))
707 (define-key mime/viewer-mode-map
708 "<" (function beginning-of-buffer))
709 (define-key mime/viewer-mode-map
710 ">" (function end-of-buffer))
712 (define-key mime/viewer-mode-map
713 mouse-button-2 (function tm:button-dispatcher))
716 (define-key mime/viewer-mode-map
717 mouse-button-3 (function mime-viewer/popup-menu))
721 (defvar mime-viewer/popup-menu-title "MIME Viewer Commands")
722 (defvar mime-viewer/popup-menu-items
723 '(("Move to upper content" . mime-viewer/up-content)
724 ("Move to previous content" . mime-viewer/previous-content)
725 ("Move to next content" . mime-viewer/next-content)
726 ("Scroll to previous content" . mime-viewer/scroll-down-content)
727 ("Scroll to next content" . mime-viewer/scroll-up-content)
728 ("Play Content" . mime-viewer/play-content)
729 ("Extract Content" . mime-viewer/extract-content)
730 ("Print" . mime-viewer/print-content)
731 ("Show X Face" . mime-viewer/display-x-face)
733 "Popup Menu for MIME Viewer")
735 (cond ((string-match "XEmacs\\|Lucid" emacs-version)
736 (defvar mime-viewer/popup-menu
737 (cons mime-viewer/popup-menu-title
740 (vector (car item)(cdr item) t)
742 mime-viewer/popup-menu-items)))
743 (defun mime-viewer/popup-menu (event)
744 "Popup the menu in the MIME Viewer buffer"
746 (select-window (event-window event))
747 (set-buffer (event-buffer event))
748 (popup-menu 'mime-viewer/popup-menu))
750 ((>= emacs-major-version 19)
751 (defun mime-viewer/popup-menu (event)
753 (mouse-set-point event)
755 (cons mime-viewer/popup-menu-title
756 (list (cons "Menu Items" mime-viewer/popup-menu-items))
758 (let ((func (x-popup-menu event menu)))
766 (defun mime/viewer-mode (&optional mother ctl encoding ibuf obuf)
767 "Major mode for viewing MIME message.
769 Here is a list of the standard keys for mime/viewer-mode.
774 u Move to upper content
775 p Move to previous content
776 n Move to next content
777 SPC Scroll up or move to next content
778 M-SPC Scroll down or move to previous content
779 DEL Scroll down or move to previous content
780 RET Move to next line
781 M-RET Move to previous line
782 v Decode current content as `play mode'
783 e Decode current content as `extract mode'
784 C-c C-p Decode current content as `print mode'
787 button-2 Move to point under the mouse cursor
788 and decode current content as `play mode'
791 Here are all the commands with their current binding,
794 \\{mime/viewer-mode-map}
797 (let ((buf (get-buffer mime/output-buffer-name)))
803 (let ((ret (mime-viewer/setup-buffer ctl encoding ibuf obuf))
804 (win-conf (current-window-configuration))
807 (switch-to-buffer (car ret))
808 (setq mime::preview/original-window-configuration win-conf)
811 (setq mime::preview/mother-buffer mother)
813 (use-local-map mime/viewer-mode-map)
814 (setq mime::preview/content-list (nth 1 ret))
816 (let ((ce (mime::preview-content-info/point-max
817 (car mime::preview/content-list)
820 (goto-char (point-min))
821 (search-forward "\n\n" nil t)
822 (setq e (match-end 0))
826 (run-hooks 'mime/viewer-mode-hook)
829 (defun mime-preview/point-content-number (point)
830 (save-window-excursion
831 (let ((pc (mime-preview/point-pcinfo (point)))
833 (switch-to-buffer (mime::preview-content-info/buffer pc))
834 (setq cinfo (mime::preview-content-info/content-info pc))
835 (mime-article/point-content-number (mime::content-info/point-min cinfo))
838 (defun mime-preview/cinfo-to-pcinfo (cinfo)
839 (let ((rpcl mime::preview/content-list) cell)
842 (setq cell (car rpcl))
843 (if (eq cinfo (mime::preview-content-info/content-info cell))
846 (setq rpcl (cdr rpcl))
849 (autoload 'mime-preview/decode-content "tm-play")
851 (defvar mime-viewer/decoding-mode "play" "MIME body decoding mode")
853 (defun mime-viewer/play-content ()
855 (let ((mime-viewer/decoding-mode "play"))
856 (mime-preview/decode-content)
859 (defun mime-viewer/extract-content ()
861 (let ((mime-viewer/decoding-mode "extract"))
862 (mime-preview/decode-content)
865 (defun mime-viewer/print-content ()
867 (let ((mime-viewer/decoding-mode "print"))
868 (mime-preview/decode-content)
871 (defun mime-viewer/display-x-face ()
873 (save-window-excursion
874 (set-buffer mime::preview/article-buffer)
875 (mime-viewer/x-face-function)
878 (defun mime-viewer/up-content ()
880 (let ((pc (mime-preview/point-pcinfo (point))) cinfo
881 (the-buf (current-buffer))
883 (switch-to-buffer (mime::preview-content-info/buffer pc))
884 (setq cinfo (mime::preview-content-info/content-info pc))
885 (setq rcnum (mime::content-info/rcnum cinfo))
887 (mime-viewer/quit the-buf
888 (mime::preview-content-info/buffer pc)
890 (setq r (mime-article/rcnum-to-cinfo (cdr rcnum)))
891 (switch-to-buffer the-buf)
893 (let ((rpcl mime::preview/content-list) cell)
895 (setq cell (car rpcl))
896 (if (eq r (mime::preview-content-info/content-info cell))
898 (goto-char (mime::preview-content-info/point-min cell))
901 (setq rpcl (cdr rpcl))
905 (defun mime-viewer/previous-content ()
907 (let* ((pcl mime::preview/content-list)
909 (i (- (length pcl) 1))
913 (setq beg (mime::preview-content-info/point-min (nth i pcl)))
915 (throw 'tag (goto-char beg))
919 (let ((f (assq mime::preview/original-major-mode
920 mime-viewer/over-to-previous-method-alist)))
927 (defun mime-viewer/next-content ()
929 (let ((pcl mime::preview/content-list)
934 (setq beg (mime::preview-content-info/point-min (car pcl)))
936 (throw 'tag (goto-char beg))
940 (let ((f (assq mime::preview/original-major-mode
941 mime-viewer/over-to-next-method-alist)))
948 (defun mime-viewer/scroll-up-content (&optional h)
951 (setq h (- (window-height) 1))
953 (if (= (point) (point-max))
954 (let ((f (assq mime::preview/original-major-mode
955 mime-viewer/over-to-next-method-alist)))
959 (let ((pcl mime::preview/content-list)
965 (setq beg (mime::preview-content-info/point-min (car pcl)))
980 (defun mime-viewer/scroll-down-content (&optional h)
983 (setq h (- (window-height) 1))
985 (if (= (point) (point-min))
986 (let ((f (assq mime::preview/original-major-mode
987 mime-viewer/over-to-previous-method-alist)))
991 (let ((pcl mime::preview/content-list)
995 (or (let ((i (- (length pcl) 1)))
998 (setq beg (mime::preview-content-info/point-min
1006 (forward-line (- h))
1012 (defun mime-viewer/next-line-content ()
1014 (mime-viewer/scroll-up-content 1)
1017 (defun mime-viewer/previous-line-content ()
1019 (mime-viewer/scroll-down-content 1)
1022 (defun mime-viewer/quit (&optional the-buf buf)
1025 (setq the-buf (current-buffer))
1028 (setq buf (mime::preview-content-info/buffer
1029 (mime-preview/point-pcinfo (point))))
1032 (switch-to-buffer buf)
1033 (assq major-mode mime-viewer/quitting-method-alist)
1037 (switch-to-buffer the-buf)
1042 (defun mime-viewer/kill-buffer ()
1044 (kill-buffer (current-buffer))
1053 (run-hooks 'tm-view-load-hook)