1 ;;; tm-view.el --- interactive MIME viewer for GNU Emacs
3 ;; Copyright (C) 1995,1996,1997 Free Software Foundation, Inc.
5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; Created: 1994/7/13 (1994/8/31 obsolete tm-body.el)
7 ;; Version: $Revision: 7.82 $
8 ;; Keywords: mail, news, MIME, multimedia
10 ;; This file is part of tm (Tools for MIME).
12 ;; This program is free software; you can redistribute it and/or
13 ;; modify it under the terms of the GNU General Public License as
14 ;; published by the Free Software Foundation; either version 2, or (at
15 ;; your option) any later version.
17 ;; This program is distributed in the hope that it will be useful, but
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 ;; General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
44 (defconst mime-viewer/RCS-ID
45 "$Id: tm-view.el,v 7.82 1997/02/18 10:51:17 tmorioka Exp $")
47 (defconst mime-viewer/version (get-version-string mime-viewer/RCS-ID))
48 (defconst mime/viewer-version mime-viewer/version)
54 (defvar mime/content-decoding-condition
55 '(((type . "text/plain")
56 (method "tm-plain" nil 'file 'type 'encoding 'mode 'name)
60 (method "tm-html" nil 'file 'type 'encoding 'mode 'name)
63 ((type . "text/x-rot13-47")
64 (method . mime-article/decode-caesar)
67 ((type . "audio/basic")
68 (method "tm-au" nil 'file 'type 'encoding 'mode 'name)
72 ((type . "image/jpeg")
73 (method "tm-image" nil 'file 'type 'encoding 'mode 'name)
77 (method "tm-image" nil 'file 'type 'encoding 'mode 'name)
80 ((type . "image/tiff")
81 (method "tm-image" nil 'file 'type 'encoding 'mode 'name)
84 ((type . "image/x-tiff")
85 (method "tm-image" nil 'file 'type 'encoding 'mode 'name)
88 ((type . "image/x-xbm")
89 (method "tm-image" nil 'file 'type 'encoding 'mode 'name)
92 ((type . "image/x-pic")
93 (method "tm-image" nil 'file 'type 'encoding 'mode 'name)
96 ((type . "image/x-mag")
97 (method "tm-image" nil 'file 'type 'encoding 'mode 'name)
101 ((type . "video/mpeg")
102 (method "tm-mpeg" nil 'file 'type 'encoding 'mode 'name)
106 ((type . "application/postscript")
107 (method "tm-ps" nil 'file 'type 'encoding 'mode 'name)
108 (mode "play" "print")
110 ((type . "application/octet-stream")
111 (method "tm-file" nil 'file 'type 'encoding 'mode 'name)
112 (mode "play" "print")
115 ;;((type . "message/external-body")
116 ;; (method "xterm" nil
117 ;; "-e" "showexternal"
118 ;; 'file '"access-type" '"name" '"site" '"directory"))
119 ((type . "message/rfc822")
120 (method . mime-article/view-message/rfc822)
123 ((type . "message/partial")
124 (method . mime-article/decode-message/partial)
128 ((method "metamail" t "-m" "tm" "-x" "-d" "-z" "-e" 'file)
131 ((method "tm-file" nil 'file 'type 'encoding 'mode 'name)
136 (defvar mime-viewer/childrens-header-showing-Content-Type-list
137 '("message/rfc822" "message/news"))
139 (defvar mime-viewer/default-showing-Content-Type-list
140 '("text/plain" nil "text/richtext" "text/enriched"
141 "text/x-latex" "application/x-latex"
142 "message/delivery-status"
143 "application/pgp" "text/x-pgp"
144 "application/octet-stream"
145 "application/x-selection" "application/x-comment"))
147 (defvar mime-viewer/content-button-ignored-ctype-list
148 '("application/x-selection"))
150 (defvar mime-viewer/content-button-visible-ctype-list
151 '("application/pgp"))
153 (defvar mime-viewer/uuencode-encoding-name-list '("x-uue" "x-uuencode"))
155 (defvar mime-viewer/ignored-field-list
156 '(".*Received" ".*Path" ".*Id" "References"
157 "Replied" "Errors-To"
158 "Lines" "Sender" ".*Host" "Xref"
159 "Content-Type" "Precedence"
161 "All fields that match this list will be hidden in MIME preview buffer.
162 Each elements are regexp of field-name. [tm-view.el]")
164 (defvar mime-viewer/ignored-field-regexp
166 (apply (function regexp-or) mime-viewer/ignored-field-list)
169 (defvar mime-viewer/visible-field-list
170 '("Dnas.*" "Message-Id")
171 "All fields that match this list will be displayed in MIME preview buffer.
172 Each elements are regexp of field-name. [tm-view.el]")
174 (defvar mime-viewer/visible-field-regexp
176 (apply (function regexp-or) mime-viewer/visible-field-list)
179 (defvar mime-viewer/redisplay nil)
181 (defvar mime-viewer/announcement-for-message/partial
182 (if (and (>= emacs-major-version 19) window-system)
184 \[[ This is message/partial style split message. ]]
185 \[[ Please press `v' key in this buffer ]]
186 \[[ or click here by mouse button-2. ]]"
188 \[[ This is message/partial style split message. ]]
189 \[[ Please press `v' key in this buffer. ]]"
193 ;;; @@ predicate functions
196 (defun mime-viewer/header-visible-p (rcnum cinfo &optional ctype)
200 (mime::content-info/type
201 (mime-article/rcnum-to-cinfo (cdr rcnum) cinfo)
203 (member ctype mime-viewer/childrens-header-showing-Content-Type-list)
206 (defun mime-viewer/body-visible-p (rcnum cinfo &optional ctype)
210 (mime::content-info/type
211 (setq ccinfo (mime-article/rcnum-to-cinfo rcnum cinfo))
214 (and (member ctype mime-viewer/default-showing-Content-Type-list)
215 (if (string-equal ctype "application/octet-stream")
218 (setq ccinfo (mime-article/rcnum-to-cinfo rcnum cinfo))
220 (member (mime::content-info/encoding ccinfo)
221 '(nil "7bit" "8bit"))
227 ;;; @@ content button
230 (defun mime-preview/insert-content-button
231 (rcnum cinfo ctype params subj encoding)
233 (narrow-to-region (point)(point))
234 (let ((access-type (assoc "access-type" params))
235 (charset (assoc "charset" params))
236 (num (or (assoc-value "x-part-number" params)
240 (format "%s" (1+ num))
246 (let ((server (assoc "server" params)))
247 (setq access-type (cdr access-type))
249 (insert (format "[%s %s ([%s] %s)]\n" num subj
250 access-type (cdr server)))
251 (let ((site (assoc-value "site" params))
252 (dir (assoc-value "directory" params))
254 (insert (format "[%s %s ([%s] %s:%s)]\n" num subj
255 access-type site dir))
259 (insert (concat "[" num " " subj))
261 (if (setq charset (cdr charset))
263 (format " <%s; %s (%s)>]\n"
264 ctype charset encoding)
265 (format " <%s; %s>]\n" ctype charset)
267 (format " <%s>]\n" ctype)
269 (if (>= (+ (current-column)(length rest))(window-width))
270 (setq rest (concat "\n\t" rest))
274 (tm:add-button (point-min)(1- (point-max))
275 (function mime-viewer/play-content))
278 (defun mime-preview/default-content-button-function
279 (rcnum cinfo ctype params subj encoding)
280 (if (and (consp rcnum)
283 mime-viewer/content-button-ignored-ctype-list)))
284 (mime-preview/insert-content-button
285 rcnum cinfo ctype params subj encoding)
288 (defvar mime-preview/content-button-function
289 (function mime-preview/default-content-button-function))
292 ;;; @@ content header filter
295 (defun mime-preview/cut-header ()
296 (goto-char (point-min))
298 (re-search-forward mime-viewer/ignored-field-regexp nil t)
299 (let* ((beg (match-beginning 0))
301 (name (buffer-substring beg end))
303 (if (not (string-match mime-viewer/visible-field-regexp name))
308 (re-search-forward "^\\([^ \t]\\|$\\)" nil t)
315 (defun mime-viewer/default-content-header-filter ()
316 (mime-preview/cut-header)
317 (mime/decode-message-header)
320 (defvar mime-viewer/content-header-filter-alist nil)
323 ;;; @@ content filter
326 (defvar mime-viewer/content-filter-alist
327 '(("text/enriched" . mime-preview/filter-for-text/enriched)
328 ("text/richtext" . mime-preview/filter-for-text/richtext)
329 (t . mime-preview/filter-for-text/plain)
333 ;;; @@ content separator
336 (defun mime-preview/default-content-separator (rcnum cinfo ctype params subj)
337 (if (and (not (mime-viewer/header-visible-p rcnum cinfo ctype))
338 (not (mime-viewer/body-visible-p rcnum cinfo ctype))
341 (goto-char (point-max))
346 ;;; @@ buffer local variables
350 (defvar mime::article/preview-buffer nil)
351 (defvar mime::article/code-converter nil)
352 (defvar mime::preview/article-buffer nil)
354 (make-variable-buffer-local 'mime::article/content-info)
355 (make-variable-buffer-local 'mime::article/preview-buffer)
356 (make-variable-buffer-local 'mime::article/code-converter)
358 (make-variable-buffer-local 'mime::preview/mother-buffer)
359 (make-variable-buffer-local 'mime::preview/content-list)
360 (make-variable-buffer-local 'mime::preview/article-buffer)
361 (make-variable-buffer-local 'mime::preview/original-major-mode)
362 (make-variable-buffer-local 'mime::preview/original-window-configuration)
365 ;;; @@ quitting method
368 (defvar mime-viewer/quitting-method-alist
369 '((mime/show-message-mode
370 . mime-viewer/quitting-method-for-mime/show-message-mode)))
372 (defvar mime-viewer/over-to-previous-method-alist nil)
373 (defvar mime-viewer/over-to-next-method-alist nil)
375 (defvar mime-viewer/show-summary-method nil)
378 ;;; @@ following method
381 (defvar mime-viewer/following-method-alist nil)
383 (defvar mime-viewer/following-required-fields-list
390 ;; hack from Gnus 5.0.4.
392 (defvar mime-viewer/x-face-to-pbm-command
393 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm")
395 (defvar mime-viewer/x-face-command
396 (concat mime-viewer/x-face-to-pbm-command
398 "String to be executed to display an X-Face field.
399 The command will be executed in a sub-shell asynchronously.
400 The compressed face will be piped to this command.")
402 (defun mime-viewer/x-face-function ()
403 "Function to display X-Face field. You can redefine to customize."
404 ;; 1995/10/12 (c.f. tm-eng:130)
405 ;; fixed by Eric Ding <ericding@San-Jose.ate.slb.com>
407 (narrow-to-region (point-min) (re-search-forward "^$" nil t))
409 (goto-char (point-min))
410 (if (re-search-forward "^X-Face:[ \t]*" nil t)
411 (let ((beg (match-end 0))
412 (end (std11-field-end))
414 (call-process-region beg end "sh" nil 0 nil
415 "-c" mime-viewer/x-face-command)
422 (defun mime-preview/get-original-major-mode ()
423 (if mime::preview/mother-buffer
425 (set-buffer mime::preview/mother-buffer)
426 (mime-preview/get-original-major-mode)
428 mime::preview/original-major-mode))
431 ;;; @ data structures
434 ;;; @@ preview-content-info
437 (define-structure mime::preview-content-info
438 point-min point-max buffer content-info)
444 (defun mime-viewer/setup-buffer (&optional ctl encoding ibuf obuf)
450 (or mime-viewer/redisplay
451 (setq mime::article/content-info (mime/parse-message ctl encoding))
453 (let ((ret (mime-viewer/make-preview-buffer obuf)))
454 (setq mime::article/preview-buffer (car ret))
457 (defun mime-viewer/make-preview-buffer (&optional obuf)
458 (let* ((cinfo mime::article/content-info)
459 (pcl (mime/flatten-content-info cinfo))
460 (dest (make-list (length pcl) nil))
461 (the-buf (current-buffer))
465 (setq obuf (concat "*Preview-" (buffer-name the-buf) "*")))
466 (set-buffer (get-buffer-create obuf))
467 (setq buffer-read-only nil)
470 (setq mime::preview/article-buffer the-buf)
471 (setq mime::preview/original-major-mode mode)
472 (setq major-mode 'mime/viewer-mode)
473 (setq mode-name "MIME-View")
477 (mime-preview/display-content (car pcl) cinfo the-buf obuf))
481 (set-buffer-modified-p nil)
482 (setq buffer-read-only t)
487 (defun mime-preview/display-content (content cinfo ibuf obuf)
488 (let* ((beg (mime::content-info/point-min content))
489 (end (mime::content-info/point-max content))
490 (ctype (mime::content-info/type content))
491 (params (mime::content-info/parameters content))
492 (encoding (mime::content-info/encoding content))
493 (rcnum (mime::content-info/rcnum content))
497 (setq he (if (re-search-forward "^$" nil t)
504 (narrow-to-region beg end)
506 (mime-eword/decode-string
507 (mime-article/get-subject params encoding)))
511 (narrow-to-region nb nb)
512 (funcall mime-preview/content-button-function
513 rcnum cinfo ctype params subj encoding)
514 (if (mime-viewer/header-visible-p rcnum cinfo ctype)
515 (mime-preview/display-header beg he)
517 (if (and (null rcnum)
519 ctype mime-viewer/content-button-visible-ctype-list))
521 (goto-char (point-max))
522 (mime-preview/insert-content-button
523 rcnum cinfo ctype params subj encoding)
525 (cond ((mime-viewer/body-visible-p rcnum cinfo ctype)
526 (mime-preview/display-body he end
527 rcnum cinfo ctype params subj encoding)
529 ((equal ctype "message/partial")
530 (mime-preview/display-message/partial)
533 (null (mime::content-info/children cinfo))
535 (goto-char (point-max))
536 (mime-preview/insert-content-button
537 rcnum cinfo ctype params subj encoding)
539 (mime-preview/default-content-separator rcnum cinfo ctype params subj)
542 (setq ne (point-max))
544 (mime::preview-content-info/create nb (1- ne) ibuf content)
549 (defun mime-preview/display-header (beg end)
551 (narrow-to-region (point)(point))
552 (insert-buffer-substring mime::preview/article-buffer beg end)
553 (let ((f (cdr (assq mime::preview/original-major-mode
554 mime-viewer/content-header-filter-alist))))
557 (mime-viewer/default-content-header-filter)
559 (run-hooks 'mime-viewer/content-header-filter-hook)
562 (defun mime-preview/display-body (beg end
563 rcnum cinfo ctype params subj encoding)
565 (narrow-to-region (point-max)(point-max))
566 (insert-buffer-substring mime::preview/article-buffer beg end)
567 (let ((f (cdr (or (assoc ctype mime-viewer/content-filter-alist)
568 (assq t mime-viewer/content-filter-alist)))))
570 (funcall f ctype params encoding)
574 (defun mime-preview/display-message/partial ()
576 (goto-char (point-max))
577 (if (not (search-backward "\n\n" nil t))
580 (let ((be (point-max)))
581 (narrow-to-region be be)
582 (insert mime-viewer/announcement-for-message/partial)
583 (tm:add-button (point-min)(point-max)
584 (function mime-viewer/play-content))
587 (defun mime-article/get-uu-filename (param &optional encoding)
588 (if (member (or encoding
589 (cdr (assq 'encoding param))
591 mime-viewer/uuencode-encoding-name-list)
593 (or (if (re-search-forward "^begin [0-9]+ " nil t)
594 (if (looking-at ".+$")
595 (buffer-substring (match-beginning 0)(match-end 0))
600 (defun mime-article/get-subject (param &optional encoding)
601 (or (std11-find-field-body '("Content-Description" "Subject"))
603 (if (or (and (setq ret (mime/Content-Disposition))
604 (setq ret (assoc "filename" (cdr ret)))
606 (setq ret (assoc "name" param))
607 (setq ret (assoc "x-name" param))
609 (std11-strip-quoted-string (cdr ret))
611 (mime-article/get-uu-filename param encoding)
615 ;;; @ content information
618 (defun mime-article/point-content-number (p &optional cinfo)
620 (setq cinfo mime::article/content-info)
622 (let ((b (mime::content-info/point-min cinfo))
623 (e (mime::content-info/point-max cinfo))
624 (c (mime::content-info/children cinfo))
626 (if (and (<= b p)(<= p e))
627 (or (let (co ret (sn 0))
631 (setq ret (mime-article/point-content-number p co))
632 (cond ((eq ret t) (throw 'tag (list sn)))
633 (ret (throw 'tag (cons sn ret)))
640 (defun mime-article/rcnum-to-cinfo (rcnum &optional cinfo)
642 (setq cinfo mime::article/content-info)
646 (equal (mime::content-info/rcnum ci) rcnum)
648 (mime/flatten-content-info cinfo)
651 (defun mime-article/cnum-to-cinfo (cn &optional cinfo)
653 (setq cinfo mime::article/content-info)
660 (let ((rc (nth sn (mime::content-info/children cinfo))))
662 (mime-article/cnum-to-cinfo (cdr cn) rc)
666 (defun mime/flatten-content-info (&optional cinfo)
668 (setq cinfo mime::article/content-info)
670 (let ((dest (list cinfo))
671 (rcl (mime::content-info/children cinfo))
674 (setq dest (nconc dest (mime/flatten-content-info (car rcl))))
679 (defun mime-preview/point-pcinfo (p &optional pcl)
681 (setq pcl mime::preview/content-list)
687 (if (and (<= (mime::preview-content-info/point-min cell) p)
688 (<= p (mime::preview-content-info/point-max cell))
698 ;;; @ MIME viewer mode
701 (defconst mime-viewer/menu-title "MIME-View")
702 (defconst mime-viewer/menu-list
703 '((up "Move to upper content" mime-viewer/up-content)
704 (previous "Move to previous content" mime-viewer/previous-content)
705 (next "Move to next content" mime-viewer/next-content)
706 (scroll-down "Scroll to previous content" mime-viewer/scroll-down-content)
707 (scroll-up "Scroll to next content" mime-viewer/scroll-up-content)
708 (play "Play Content" mime-viewer/play-content)
709 (extract "Extract Content" mime-viewer/extract-content)
710 (print "Print" mime-viewer/print-content)
711 (x-face "Show X Face" mime-viewer/display-x-face)
713 "Menu for MIME Viewer")
717 (defvar mime-viewer/xemacs-popup-menu
718 (cons mime-viewer/menu-title
721 (vector (nth 1 item)(nth 2 item) t)
723 mime-viewer/menu-list)))
724 (defun mime-viewer/xemacs-popup-menu (event)
725 "Popup the menu in the MIME Viewer buffer"
727 (select-window (event-window event))
728 (set-buffer (event-buffer event))
729 (popup-menu 'mime-viewer/xemacs-popup-menu))
732 (defun mime-viewer/define-keymap (&optional mother)
733 (let ((mime/viewer-mode-map (if mother
738 (suppress-keymap mime/viewer-mode-map))
739 (define-key mime/viewer-mode-map
740 "u" (function mime-viewer/up-content))
741 (define-key mime/viewer-mode-map
742 "p" (function mime-viewer/previous-content))
743 (define-key mime/viewer-mode-map
744 "n" (function mime-viewer/next-content))
745 (define-key mime/viewer-mode-map
746 "\e\t" (function mime-viewer/previous-content))
747 (define-key mime/viewer-mode-map
748 "\t" (function mime-viewer/next-content))
749 (define-key mime/viewer-mode-map
750 " " (function mime-viewer/scroll-up-content))
751 (define-key mime/viewer-mode-map
752 "\M- " (function mime-viewer/scroll-down-content))
753 (define-key mime/viewer-mode-map
754 "\177" (function mime-viewer/scroll-down-content))
755 (define-key mime/viewer-mode-map
756 "\C-m" (function mime-viewer/next-line-content))
757 (define-key mime/viewer-mode-map
758 "\C-\M-m" (function mime-viewer/previous-line-content))
759 (define-key mime/viewer-mode-map
760 "v" (function mime-viewer/play-content))
761 (define-key mime/viewer-mode-map
762 "e" (function mime-viewer/extract-content))
763 (define-key mime/viewer-mode-map
764 "\C-c\C-p" (function mime-viewer/print-content))
765 (define-key mime/viewer-mode-map
766 "x" (function mime-viewer/display-x-face))
767 (define-key mime/viewer-mode-map
768 "a" (function mime-viewer/follow-content))
769 (define-key mime/viewer-mode-map
770 "q" (function mime-viewer/quit))
771 (define-key mime/viewer-mode-map
772 "h" (function mime-viewer/show-summary))
773 (define-key mime/viewer-mode-map
774 "\C-c\C-x" (function mime-viewer/kill-buffer))
775 (define-key mime/viewer-mode-map
776 "<" (function beginning-of-buffer))
777 (define-key mime/viewer-mode-map
778 ">" (function end-of-buffer))
779 (define-key mime/viewer-mode-map
780 "?" (function describe-mode))
782 (define-key mime/viewer-mode-map
783 mouse-button-2 (function tm:button-dispatcher))
785 (cond (running-xemacs
786 (define-key mime/viewer-mode-map
787 mouse-button-3 (function mime-viewer/xemacs-popup-menu))
789 ((>= emacs-major-version 19)
790 (define-key mime/viewer-mode-map [menu-bar mime-view]
791 (cons mime-viewer/menu-title
792 (make-sparse-keymap mime-viewer/menu-title)))
795 (define-key mime/viewer-mode-map
796 (vector 'menu-bar 'mime-view (car item))
797 (cons (nth 1 item)(nth 2 item))
800 (reverse mime-viewer/menu-list)
803 (use-local-map mime/viewer-mode-map)
804 (run-hooks 'mime-viewer/define-keymap-hook)
807 (defun mime/viewer-mode (&optional mother ctl encoding ibuf obuf
809 "Major mode for viewing MIME message.
811 Here is a list of the standard keys for mime/viewer-mode.
816 u Move to upper content
817 p or M-TAB Move to previous content
818 n or TAB Move to next content
819 SPC Scroll up or move to next content
820 M-SPC or DEL Scroll down or move to previous content
821 RET Move to next line
822 M-RET Move to previous line
823 v Decode current content as `play mode'
824 e Decode current content as `extract mode'
825 C-c C-p Decode current content as `print mode'
826 a Followup to current content.
829 button-2 Move to point under the mouse cursor
830 and decode current content as `play mode'
833 (let ((buf (get-buffer mime/output-buffer-name)))
839 (let ((ret (mime-viewer/setup-buffer ctl encoding ibuf obuf))
840 (win-conf (current-window-configuration))
843 (switch-to-buffer (car ret))
844 (setq mime::preview/original-window-configuration win-conf)
847 (setq mime::preview/mother-buffer mother)
849 (mime-viewer/define-keymap mother-keymap)
850 (setq mime::preview/content-list (nth 1 ret))
852 (let ((ce (mime::preview-content-info/point-max
853 (car mime::preview/content-list)
856 (goto-char (point-min))
857 (search-forward "\n\n" nil t)
858 (setq e (match-end 0))
862 (run-hooks 'mime/viewer-mode-hook)
865 (defun mime-preview/point-content-number (point)
866 (save-window-excursion
867 (let ((pc (mime-preview/point-pcinfo (point)))
869 (switch-to-buffer (mime::preview-content-info/buffer pc))
870 (setq cinfo (mime::preview-content-info/content-info pc))
871 (mime-article/point-content-number (mime::content-info/point-min cinfo))
874 (defun mime-preview/cinfo-to-pcinfo (cinfo)
875 (let ((rpcl mime::preview/content-list) cell)
878 (setq cell (car rpcl))
879 (if (eq cinfo (mime::preview-content-info/content-info cell))
882 (setq rpcl (cdr rpcl))
885 (autoload 'mime-preview/decode-content "tm-play")
887 (defvar mime-viewer/decoding-mode "play" "MIME body decoding mode")
889 (defun mime-viewer/play-content ()
891 (let ((mime-viewer/decoding-mode "play"))
892 (mime-preview/decode-content)
895 (defun mime-viewer/extract-content ()
897 (let ((mime-viewer/decoding-mode "extract"))
898 (mime-preview/decode-content)
901 (defun mime-viewer/print-content ()
903 (let ((mime-viewer/decoding-mode "print"))
904 (mime-preview/decode-content)
907 (defun mime-viewer/follow-content ()
910 (mime::preview-content-info/content-info
911 (car mime::preview/content-list)))
912 pc p-beg p-end cinfo rcnum)
913 (let ((rest mime::preview/content-list)
916 (while (setq cell (car rest))
917 (setq b (mime::preview-content-info/point-min cell)
918 e (mime::preview-content-info/point-max cell))
919 (setq rest (cdr rest))
920 (if (and (<= b (point))(<= (point) e))
926 cinfo (mime::preview-content-info/content-info pc)
927 rcnum (mime::content-info/rcnum cinfo))
928 (setq len (length rcnum))
929 (setq p-beg (mime::preview-content-info/point-min pc)
930 p-end (mime::preview-content-info/point-max pc))
931 (while (and (setq cell (car rest))
934 (mime::content-info/rcnum
935 (mime::preview-content-info/content-info
938 (nthcdr (- (length rc) len) rc))
940 (setq p-end (mime::preview-content-info/point-max cell))
941 (setq rest (cdr rest))
944 (let* ((mode (mime-preview/get-original-major-mode))
945 (new-name (format "%s-%s" (buffer-name) (reverse rcnum)))
947 (the-buf (current-buffer))
948 (a-buf mime::preview/article-buffer)
949 (hb (mime::content-info/point-min cinfo))
950 (he (mime::content-info/point-max cinfo))
951 fields from to cc reply-to subj mid f)
953 (set-buffer (setq new-buf (get-buffer-create new-name)))
955 (insert-buffer-substring the-buf p-beg p-end)
956 (goto-char (point-min))
957 (if (mime-viewer/header-visible-p rcnum root-cinfo)
958 (delete-region (goto-char (point-min))
959 (if (re-search-forward "^$" nil t)
963 (goto-char (point-min))
965 (goto-char (point-min))
966 (let ((rcnum (mime::content-info/rcnum cinfo)) ci str)
971 (setq ci (mime-article/rcnum-to-cinfo rcnum))
974 (mime::content-info/point-min ci)
975 (mime::content-info/point-max ci)
977 (std11-header-string-except
979 (apply (function regexp-or) fields)
981 (if (string-equal (mime::content-info/type ci)
988 (setq fields (std11-collect-field-names)
992 (let ((rest mime-viewer/following-required-fields-list))
994 (let ((field-name (car rest)))
995 (or (std11-field-body field-name)
1001 (set-buffer the-buf)
1002 (set-buffer mime::preview/mother-buffer)
1003 (set-buffer mime::preview/article-buffer)
1004 (std11-field-body field-name)
1008 (setq rest (cdr rest))
1010 (mime/decode-message-header)
1012 (let ((f (cdr (assq mode mime-viewer/following-method-alist))))
1017 "Sorry, following method for %s is not implemented yet."
1022 (defun mime-viewer/display-x-face ()
1024 (save-window-excursion
1025 (set-buffer mime::preview/article-buffer)
1026 (mime-viewer/x-face-function)
1029 (defun mime-viewer/up-content ()
1031 (let* ((pc (mime-preview/point-pcinfo (point)))
1032 (cinfo (mime::preview-content-info/content-info pc))
1033 (rcnum (mime::content-info/rcnum cinfo))
1036 (let ((r (save-excursion
1037 (set-buffer (mime::preview-content-info/buffer pc))
1038 (mime-article/rcnum-to-cinfo (cdr rcnum))
1040 (rpcl mime::preview/content-list)
1043 (setq cell (car rpcl))
1044 (not (eq r (mime::preview-content-info/content-info cell)))
1046 (setq rpcl (cdr rpcl))
1048 (goto-char (mime::preview-content-info/point-min cell))
1053 (defun mime-viewer/previous-content ()
1055 (let* ((pcl mime::preview/content-list)
1057 (i (- (length pcl) 1))
1061 (setq beg (mime::preview-content-info/point-min (nth i pcl)))
1063 (throw 'tag (goto-char beg))
1067 (let ((f (assq mime::preview/original-major-mode
1068 mime-viewer/over-to-previous-method-alist)))
1075 (defun mime-viewer/next-content ()
1077 (let ((pcl mime::preview/content-list)
1082 (setq beg (mime::preview-content-info/point-min (car pcl)))
1084 (throw 'tag (goto-char beg))
1086 (setq pcl (cdr pcl))
1088 (let ((f (assq mime::preview/original-major-mode
1089 mime-viewer/over-to-next-method-alist)))
1096 (defun mime-viewer/scroll-up-content (&optional h)
1099 (setq h (- (window-height) 1))
1101 (if (= (point) (point-max))
1102 (let ((f (assq mime::preview/original-major-mode
1103 mime-viewer/over-to-next-method-alist)))
1107 (let ((pcl mime::preview/content-list)
1113 (setq beg (mime::preview-content-info/point-min (car pcl)))
1117 (setq pcl (cdr pcl))
1128 (defun mime-viewer/scroll-down-content (&optional h)
1131 (setq h (- (window-height) 1))
1133 (if (= (point) (point-min))
1134 (let ((f (assq mime::preview/original-major-mode
1135 mime-viewer/over-to-previous-method-alist)))
1139 (let ((pcl mime::preview/content-list)
1143 (or (let ((i (- (length pcl) 1)))
1146 (setq beg (mime::preview-content-info/point-min
1154 (forward-line (- h))
1160 (defun mime-viewer/next-line-content ()
1162 (mime-viewer/scroll-up-content 1)
1165 (defun mime-viewer/previous-line-content ()
1167 (mime-viewer/scroll-down-content 1)
1170 (defun mime-viewer/quit ()
1172 (let ((r (save-excursion
1173 (set-buffer (mime::preview-content-info/buffer
1174 (mime-preview/point-pcinfo (point))))
1175 (assq major-mode mime-viewer/quitting-method-alist)
1181 (defun mime-viewer/show-summary ()
1183 (let ((r (save-excursion
1185 (mime::preview-content-info/buffer
1186 (mime-preview/point-pcinfo (point)))
1188 (assq major-mode mime-viewer/show-summary-method)
1194 (defun mime-viewer/kill-buffer ()
1196 (kill-buffer (current-buffer))
1205 (run-hooks 'tm-view-load-hook)
1207 ;;; tm-view.el ends here