1 ;;; mime-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>
7 ;; Renamed: 1994/8/31 from tm-body.el
8 ;; Renamed: 1997/02/19 from tm-view.el
9 ;; Version: $Revision: 0.15 $
10 ;; Keywords: MIME, multimedia, mail, news
12 ;; This file is part of SEMI (SEMI is Emacs MIME Interfaces).
14 ;; This program is free software; you can redistribute it and/or
15 ;; modify it under the terms of the GNU General Public License as
16 ;; published by the Free Software Foundation; either version 2, or (at
17 ;; your option) any later version.
19 ;; This program is distributed in the hope that it will be useful, but
20 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 ;; General Public License for more details.
24 ;; You should have received a copy of the GNU General Public License
25 ;; along with GNU Emacs; see the file COPYING. If not, write to the
26 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
27 ;; Boston, MA 02111-1307, USA.
36 (require 'eword-decode)
44 (defconst mime-view-RCS-ID
45 "$Id: mime-view.el,v 0.15 1997-02-24 09:09:55 tmorioka Exp $")
47 (defconst mime-view-version (get-version-string mime-view-RCS-ID))
53 (defvar mime/content-decoding-condition
54 '(((type . "text/plain")
55 (method "tm-plain" nil 'file 'type 'encoding 'mode 'name)
59 (method "tm-html" nil 'file 'type 'encoding 'mode 'name)
62 ((type . "text/x-rot13-47")
63 (method . mime-article/decode-caesar)
66 ((type . "audio/basic")
67 (method "tm-au" nil 'file 'type 'encoding 'mode 'name)
71 ((type . "image/jpeg")
72 (method "tm-image" nil 'file 'type 'encoding 'mode 'name)
76 (method "tm-image" nil 'file 'type 'encoding 'mode 'name)
79 ((type . "image/tiff")
80 (method "tm-image" nil 'file 'type 'encoding 'mode 'name)
83 ((type . "image/x-tiff")
84 (method "tm-image" nil 'file 'type 'encoding 'mode 'name)
87 ((type . "image/x-xbm")
88 (method "tm-image" nil 'file 'type 'encoding 'mode 'name)
91 ((type . "image/x-pic")
92 (method "tm-image" nil 'file 'type 'encoding 'mode 'name)
95 ((type . "image/x-mag")
96 (method "tm-image" nil 'file 'type 'encoding 'mode 'name)
100 ((type . "video/mpeg")
101 (method "tm-mpeg" nil 'file 'type 'encoding 'mode 'name)
105 ((type . "application/postscript")
106 (method "tm-ps" nil 'file 'type 'encoding 'mode 'name)
107 (mode "play" "print")
109 ((type . "application/octet-stream")
110 (method "tm-file" nil 'file 'type 'encoding 'mode 'name)
111 (mode "play" "print")
114 ;;((type . "message/external-body")
115 ;; (method "xterm" nil
116 ;; "-e" "showexternal"
117 ;; 'file '"access-type" '"name" '"site" '"directory"))
118 ((type . "message/rfc822")
119 (method . mime-article/view-message/rfc822)
122 ((type . "message/partial")
123 (method . mime-article/decode-message/partial)
127 ((method "metamail" t "-m" "tm" "-x" "-d" "-z" "-e" 'file)
130 ((method "tm-file" nil 'file 'type 'encoding 'mode 'name)
135 (defvar mime-view-childrens-header-showing-Content-Type-list
136 '("message/rfc822" "message/news"))
138 (defvar mime-view-default-showing-Content-Type-list
139 '("text/plain" nil "text/richtext" "text/enriched"
140 "text/x-latex" "application/x-latex"
141 "message/delivery-status"
142 "application/pgp" "text/x-pgp"
143 "application/octet-stream"
144 "application/x-selection" "application/x-comment"))
146 (defvar mime-view-content-button-ignored-ctype-list
147 '("application/x-selection"))
149 (defvar mime-view-content-button-visible-ctype-list
150 '("application/pgp"))
152 (defvar mime-view-uuencode-encoding-name-list '("x-uue" "x-uuencode"))
154 (defvar mime-view-ignored-field-list
155 '(".*Received" ".*Path" ".*Id" "References"
156 "Replied" "Errors-To"
157 "Lines" "Sender" ".*Host" "Xref"
158 "Content-Type" "Precedence"
160 "All fields that match this list will be hidden in MIME preview buffer.
161 Each elements are regexp of field-name. [mime-view.el]")
163 (defvar mime-view-ignored-field-regexp
165 (apply (function regexp-or) mime-view-ignored-field-list)
168 (defvar mime-view-visible-field-list
169 '("Dnas.*" "Message-Id")
170 "All fields that match this list will be displayed in MIME preview buffer.
171 Each elements are regexp of field-name. [mime-view.el]")
173 (defvar mime-view-visible-field-regexp
175 (apply (function regexp-or) mime-view-visible-field-list)
178 (defvar mime-view-redisplay nil)
180 (defvar mime-view-announcement-for-message/partial
181 (if (and (>= emacs-major-version 19) window-system)
183 \[[ This is message/partial style split message. ]]
184 \[[ Please press `v' key in this buffer ]]
185 \[[ or click here by mouse button-2. ]]"
187 \[[ This is message/partial style split message. ]]
188 \[[ Please press `v' key in this buffer. ]]"
192 ;;; @@ predicate functions
195 (defun mime-view-header-visible-p (rcnum cinfo &optional ctype)
199 (mime::content-info/type
200 (mime-article/rcnum-to-cinfo (cdr rcnum) cinfo)
202 (member ctype mime-view-childrens-header-showing-Content-Type-list)
205 (defun mime-view-body-visible-p (rcnum cinfo &optional ctype)
209 (mime::content-info/type
210 (setq ccinfo (mime-article/rcnum-to-cinfo rcnum cinfo))
213 (and (member ctype mime-view-default-showing-Content-Type-list)
214 (if (string-equal ctype "application/octet-stream")
217 (setq ccinfo (mime-article/rcnum-to-cinfo rcnum cinfo))
219 (member (mime::content-info/encoding ccinfo)
220 '(nil "7bit" "8bit"))
226 ;;; @@ content button
229 (defun mime-preview/insert-content-button
230 (rcnum cinfo ctype params subj encoding)
232 (narrow-to-region (point)(point))
233 (let ((access-type (assoc "access-type" params))
234 (charset (assoc "charset" params))
235 (num (or (cdr (assoc "x-part-number" params))
239 (format "%s" (1+ num))
245 (let ((server (assoc "server" params)))
246 (setq access-type (cdr access-type))
248 (insert (format "[%s %s ([%s] %s)]\n" num subj
249 access-type (cdr server)))
250 (let ((site (assoc-value "site" params))
251 (dir (assoc-value "directory" params))
253 (insert (format "[%s %s ([%s] %s:%s)]\n" num subj
254 access-type site dir))
258 (insert (concat "[" num " " subj))
260 (if (setq charset (cdr charset))
262 (format " <%s; %s (%s)>]\n"
263 ctype charset encoding)
264 (format " <%s; %s>]\n" ctype charset)
266 (format " <%s>]\n" ctype)
268 (if (>= (+ (current-column)(length rest))(window-width))
269 (setq rest (concat "\n\t" rest))
273 (tm:add-button (point-min)(1- (point-max))
274 (function mime-view-play-content))
277 (defun mime-preview/default-content-button-function
278 (rcnum cinfo ctype params subj encoding)
279 (if (and (consp rcnum)
282 mime-view-content-button-ignored-ctype-list)))
283 (mime-preview/insert-content-button
284 rcnum cinfo ctype params subj encoding)
287 (defvar mime-preview/content-button-function
288 (function mime-preview/default-content-button-function))
291 ;;; @@ content header filter
294 (defun mime-preview/cut-header ()
295 (goto-char (point-min))
297 (re-search-forward mime-view-ignored-field-regexp nil t)
298 (let* ((beg (match-beginning 0))
300 (name (buffer-substring beg end))
302 (if (not (string-match mime-view-visible-field-regexp name))
307 (re-search-forward "^\\([^ \t]\\|$\\)" nil t)
314 (defun mime-view-default-content-header-filter ()
315 (mime-preview/cut-header)
316 (eword-decode-header)
319 (defvar mime-view-content-header-filter-alist nil)
322 ;;; @@ content filter
325 (defvar mime-view-content-filter-alist
326 '(("text/enriched" . mime-preview/filter-for-text/enriched)
327 ("text/richtext" . mime-preview/filter-for-text/richtext)
328 (t . mime-preview/filter-for-text/plain)
332 ;;; @@ content separator
335 (defun mime-preview/default-content-separator (rcnum cinfo ctype params subj)
336 (if (and (not (mime-view-header-visible-p rcnum cinfo ctype))
337 (not (mime-view-body-visible-p rcnum cinfo ctype))
340 (goto-char (point-max))
345 ;;; @@ buffer local variables
349 (defvar mime::article/preview-buffer nil)
350 (defvar mime::article/code-converter nil)
351 (defvar mime::preview/article-buffer nil)
353 (make-variable-buffer-local 'mime::article/content-info)
354 (make-variable-buffer-local 'mime::article/preview-buffer)
355 (make-variable-buffer-local 'mime::article/code-converter)
357 (make-variable-buffer-local 'mime::preview/mother-buffer)
358 (make-variable-buffer-local 'mime::preview/content-list)
359 (make-variable-buffer-local 'mime::preview/article-buffer)
360 (make-variable-buffer-local 'mime::preview/original-major-mode)
361 (make-variable-buffer-local 'mime::preview/original-window-configuration)
364 ;;; @@ quitting method
367 (defvar mime-view-quitting-method-alist
368 '((mime/show-message-mode
369 . mime-view-quitting-method-for-mime/show-message-mode)))
371 (defvar mime-view-over-to-previous-method-alist nil)
372 (defvar mime-view-over-to-next-method-alist nil)
374 (defvar mime-view-show-summary-method nil)
377 ;;; @@ following method
380 (defvar mime-view-following-method-alist nil)
382 (defvar mime-view-following-required-fields-list
389 ;; hack from Gnus 5.0.4.
391 (defvar mime-view-x-face-to-pbm-command
392 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm")
394 (defvar mime-view-x-face-command
395 (concat mime-view-x-face-to-pbm-command
397 "String to be executed to display an X-Face field.
398 The command will be executed in a sub-shell asynchronously.
399 The compressed face will be piped to this command.")
401 (defun mime-view-x-face-function ()
402 "Function to display X-Face field. You can redefine to customize."
403 ;; 1995/10/12 (c.f. tm-eng:130)
404 ;; fixed by Eric Ding <ericding@San-Jose.ate.slb.com>
406 (narrow-to-region (point-min) (re-search-forward "^$" nil t))
408 (goto-char (point-min))
409 (if (re-search-forward "^X-Face:[ \t]*" nil t)
410 (let ((beg (match-end 0))
411 (end (std11-field-end))
413 (call-process-region beg end "sh" nil 0 nil
414 "-c" mime-view-x-face-command)
421 (defun mime-preview/get-original-major-mode ()
422 (if mime::preview/mother-buffer
424 (set-buffer mime::preview/mother-buffer)
425 (mime-preview/get-original-major-mode)
427 mime::preview/original-major-mode))
430 ;;; @ data structures
433 ;;; @@ preview-content-info
436 (define-structure mime::preview-content-info
437 point-min point-max buffer content-info)
443 (defun mime-view-setup-buffer (&optional ctl encoding ibuf obuf)
449 (or mime-view-redisplay
450 (setq mime::article/content-info (mime-parse-message ctl encoding))
452 (let ((ret (mime-view-make-preview-buffer obuf)))
453 (setq mime::article/preview-buffer (car ret))
456 (defun mime-view-make-preview-buffer (&optional obuf)
457 (let* ((cinfo mime::article/content-info)
458 (pcl (mime/flatten-content-info cinfo))
459 (dest (make-list (length pcl) nil))
460 (the-buf (current-buffer))
464 (setq obuf (concat "*Preview-" (buffer-name the-buf) "*")))
465 (set-buffer (get-buffer-create obuf))
466 (setq buffer-read-only nil)
469 (setq mime::preview/article-buffer the-buf)
470 (setq mime::preview/original-major-mode mode)
471 (setq major-mode 'mime-view-mode)
472 (setq mode-name "MIME-View")
476 (mime-preview/display-content (car pcl) cinfo the-buf obuf))
480 (set-buffer-modified-p nil)
481 (setq buffer-read-only t)
486 (defun mime-preview/display-content (content cinfo ibuf obuf)
487 (let* ((beg (mime::content-info/point-min content))
488 (end (mime::content-info/point-max content))
489 (ctype (mime::content-info/type content))
490 (params (mime::content-info/parameters content))
491 (encoding (mime::content-info/encoding content))
492 (rcnum (mime::content-info/rcnum content))
496 (setq he (if (re-search-forward "^$" nil t)
503 (narrow-to-region beg end)
506 (mime-article/get-subject params encoding)))
510 (narrow-to-region nb nb)
511 (funcall mime-preview/content-button-function
512 rcnum cinfo ctype params subj encoding)
513 (if (mime-view-header-visible-p rcnum cinfo ctype)
514 (mime-preview/display-header beg he)
516 (if (and (null rcnum)
518 ctype mime-view-content-button-visible-ctype-list))
520 (goto-char (point-max))
521 (mime-preview/insert-content-button
522 rcnum cinfo ctype params subj encoding)
524 (cond ((mime-view-body-visible-p rcnum cinfo ctype)
525 (mime-preview/display-body he end
526 rcnum cinfo ctype params subj encoding)
528 ((equal ctype "message/partial")
529 (mime-preview/display-message/partial)
532 (null (mime::content-info/children cinfo))
534 (goto-char (point-max))
535 (mime-preview/insert-content-button
536 rcnum cinfo ctype params subj encoding)
538 (mime-preview/default-content-separator rcnum cinfo ctype params subj)
541 (setq ne (point-max))
543 (mime::preview-content-info/create nb (1- ne) ibuf content)
548 (defun mime-preview/display-header (beg end)
550 (narrow-to-region (point)(point))
551 (insert-buffer-substring mime::preview/article-buffer beg end)
552 (let ((f (cdr (assq mime::preview/original-major-mode
553 mime-view-content-header-filter-alist))))
556 (mime-view-default-content-header-filter)
558 (run-hooks 'mime-view-content-header-filter-hook)
561 (defun mime-preview/display-body (beg end
562 rcnum cinfo ctype params subj encoding)
564 (narrow-to-region (point-max)(point-max))
565 (insert-buffer-substring mime::preview/article-buffer beg end)
566 (let ((f (cdr (or (assoc ctype mime-view-content-filter-alist)
567 (assq t mime-view-content-filter-alist)))))
569 (funcall f ctype params encoding)
573 (defun mime-preview/display-message/partial ()
575 (goto-char (point-max))
576 (if (not (search-backward "\n\n" nil t))
579 (let ((be (point-max)))
580 (narrow-to-region be be)
581 (insert mime-view-announcement-for-message/partial)
582 (tm:add-button (point-min)(point-max)
583 (function mime-view-play-content))
586 (defun mime-article/get-uu-filename (param &optional encoding)
587 (if (member (or encoding
588 (cdr (assq 'encoding param))
590 mime-view-uuencode-encoding-name-list)
592 (or (if (re-search-forward "^begin [0-9]+ " nil t)
593 (if (looking-at ".+$")
594 (buffer-substring (match-beginning 0)(match-end 0))
599 (defun mime-article/get-subject (param &optional encoding)
600 (or (std11-find-field-body '("Content-Description" "Subject"))
602 (if (or (and (setq ret (mime/Content-Disposition))
603 (setq ret (assoc "filename" (cdr ret)))
605 (setq ret (assoc "name" param))
606 (setq ret (assoc "x-name" param))
608 (std11-strip-quoted-string (cdr ret))
610 (mime-article/get-uu-filename param encoding)
614 ;;; @ content information
617 (defun mime-article/point-content-number (p &optional cinfo)
619 (setq cinfo mime::article/content-info)
621 (let ((b (mime::content-info/point-min cinfo))
622 (e (mime::content-info/point-max cinfo))
623 (c (mime::content-info/children cinfo))
625 (if (and (<= b p)(<= p e))
626 (or (let (co ret (sn 0))
630 (setq ret (mime-article/point-content-number p co))
631 (cond ((eq ret t) (throw 'tag (list sn)))
632 (ret (throw 'tag (cons sn ret)))
639 (defun mime-article/rcnum-to-cinfo (rcnum &optional cinfo)
641 (setq cinfo mime::article/content-info)
645 (equal (mime::content-info/rcnum ci) rcnum)
647 (mime/flatten-content-info cinfo)
650 (defun mime-article/cnum-to-cinfo (cn &optional cinfo)
652 (setq cinfo mime::article/content-info)
659 (let ((rc (nth sn (mime::content-info/children cinfo))))
661 (mime-article/cnum-to-cinfo (cdr cn) rc)
665 (defun mime/flatten-content-info (&optional cinfo)
667 (setq cinfo mime::article/content-info)
669 (let ((dest (list cinfo))
670 (rcl (mime::content-info/children cinfo))
673 (setq dest (nconc dest (mime/flatten-content-info (car rcl))))
678 (defun mime-preview/point-pcinfo (p &optional pcl)
680 (setq pcl mime::preview/content-list)
686 (if (and (<= (mime::preview-content-info/point-min cell) p)
687 (<= p (mime::preview-content-info/point-max cell))
697 ;;; @ MIME viewer mode
700 (defconst mime-view-menu-title "MIME-View")
701 (defconst mime-view-menu-list
702 '((up "Move to upper content" mime-view-up-content)
703 (previous "Move to previous content" mime-view-previous-content)
704 (next "Move to next content" mime-view-next-content)
705 (scroll-down "Scroll to previous content" mime-view-scroll-down-content)
706 (scroll-up "Scroll to next content" mime-view-scroll-up-content)
707 (play "Play Content" mime-view-play-content)
708 (extract "Extract Content" mime-view-extract-content)
709 (print "Print" mime-view-print-content)
710 (x-face "Show X Face" mime-view-display-x-face)
712 "Menu for MIME Viewer")
716 (defvar mime-view-xemacs-popup-menu
717 (cons mime-view-menu-title
720 (vector (nth 1 item)(nth 2 item) t)
722 mime-view-menu-list)))
723 (defun mime-view-xemacs-popup-menu (event)
724 "Popup the menu in the MIME Viewer buffer"
726 (select-window (event-window event))
727 (set-buffer (event-buffer event))
728 (popup-menu 'mime-view-xemacs-popup-menu))
731 (defun mime-view-define-keymap (&optional default)
732 (let ((mime-view-mode-map (if (keymapp default)
733 (copy-keymap default)
736 (define-key mime-view-mode-map
737 "u" (function mime-view-up-content))
738 (define-key mime-view-mode-map
739 "p" (function mime-view-previous-content))
740 (define-key mime-view-mode-map
741 "n" (function mime-view-next-content))
742 (define-key mime-view-mode-map
743 "\e\t" (function mime-view-previous-content))
744 (define-key mime-view-mode-map
745 "\t" (function mime-view-next-content))
746 (define-key mime-view-mode-map
747 " " (function mime-view-scroll-up-content))
748 (define-key mime-view-mode-map
749 "\M- " (function mime-view-scroll-down-content))
750 (define-key mime-view-mode-map
751 "\177" (function mime-view-scroll-down-content))
752 (define-key mime-view-mode-map
753 "\C-m" (function mime-view-next-line-content))
754 (define-key mime-view-mode-map
755 "\C-\M-m" (function mime-view-previous-line-content))
756 (define-key mime-view-mode-map
757 "v" (function mime-view-play-content))
758 (define-key mime-view-mode-map
759 "e" (function mime-view-extract-content))
760 (define-key mime-view-mode-map
761 "\C-c\C-p" (function mime-view-print-content))
762 (define-key mime-view-mode-map
763 "a" (function mime-view-follow-content))
764 (define-key mime-view-mode-map
765 "q" (function mime-view-quit))
766 (define-key mime-view-mode-map
767 "h" (function mime-view-show-summary))
768 (define-key mime-view-mode-map
769 "\C-c\C-x" (function mime-view-kill-buffer))
770 (define-key mime-view-mode-map
771 "<" (function beginning-of-buffer))
772 (define-key mime-view-mode-map
773 ">" (function end-of-buffer))
774 (define-key mime-view-mode-map
775 "?" (function describe-mode))
776 (if (functionp default)
777 (setq mime-view-mode-map
778 (append mime-view-mode-map (list (cons t default)))
781 (define-key mime-view-mode-map
782 mouse-button-2 (function tm:button-dispatcher))
784 (cond (running-xemacs
785 (define-key mime-view-mode-map
786 mouse-button-3 (function mime-view-xemacs-popup-menu))
788 ((>= emacs-major-version 19)
789 (define-key mime-view-mode-map [menu-bar mime-view]
790 (cons mime-view-menu-title
791 (make-sparse-keymap mime-view-menu-title)))
794 (define-key mime-view-mode-map
795 (vector 'menu-bar 'mime-view (car item))
796 (cons (nth 1 item)(nth 2 item))
799 (reverse mime-view-menu-list)
802 (use-local-map mime-view-mode-map)
803 (run-hooks 'mime-view-define-keymap-hook)
806 (defun mime-view-mode (&optional mother ctl encoding ibuf obuf
807 default-keymap-or-function)
808 "Major mode for viewing MIME message.
810 Here is a list of the standard keys for mime-view-mode.
815 u Move to upper content
816 p or M-TAB Move to previous content
817 n or TAB Move to next content
818 SPC Scroll up or move to next content
819 M-SPC or DEL Scroll down or move to previous content
820 RET Move to next line
821 M-RET Move to previous line
822 v Decode current content as `play mode'
823 e Decode current content as `extract mode'
824 C-c C-p Decode current content as `print mode'
825 a Followup to current content.
828 button-2 Move to point under the mouse cursor
829 and decode current content as `play mode'
832 (let ((buf (get-buffer mime/output-buffer-name)))
838 (let ((ret (mime-view-setup-buffer ctl encoding ibuf obuf))
839 (win-conf (current-window-configuration))
842 (switch-to-buffer (car ret))
843 (setq mime::preview/original-window-configuration win-conf)
846 (setq mime::preview/mother-buffer mother)
848 (mime-view-define-keymap default-keymap-or-function)
849 (setq mime::preview/content-list (nth 1 ret))
851 (let ((ce (mime::preview-content-info/point-max
852 (car mime::preview/content-list)
855 (goto-char (point-min))
856 (search-forward "\n\n" nil t)
857 (setq e (match-end 0))
861 (run-hooks 'mime-view-mode-hook)
864 (defun mime-preview/point-content-number (point)
865 (save-window-excursion
866 (let ((pc (mime-preview/point-pcinfo (point)))
868 (switch-to-buffer (mime::preview-content-info/buffer pc))
869 (setq cinfo (mime::preview-content-info/content-info pc))
870 (mime-article/point-content-number (mime::content-info/point-min cinfo))
873 (defun mime-preview/cinfo-to-pcinfo (cinfo)
874 (let ((rpcl mime::preview/content-list) cell)
877 (setq cell (car rpcl))
878 (if (eq cinfo (mime::preview-content-info/content-info cell))
881 (setq rpcl (cdr rpcl))
884 (autoload 'mime-preview/decode-content "mime-play")
886 (defvar mime-view-decoding-mode "play" "MIME body decoding mode")
888 (defun mime-view-play-content ()
890 (let ((mime-view-decoding-mode "play"))
891 (mime-preview/decode-content)
894 (defun mime-view-extract-content ()
896 (let ((mime-view-decoding-mode "extract"))
897 (mime-preview/decode-content)
900 (defun mime-view-print-content ()
902 (let ((mime-view-decoding-mode "print"))
903 (mime-preview/decode-content)
906 (defun mime-view-follow-content ()
909 (mime::preview-content-info/content-info
910 (car mime::preview/content-list)))
911 pc p-beg p-end cinfo rcnum)
912 (let ((rest mime::preview/content-list)
915 (while (setq cell (car rest))
916 (setq b (mime::preview-content-info/point-min cell)
917 e (mime::preview-content-info/point-max cell))
918 (setq rest (cdr rest))
919 (if (and (<= b (point))(<= (point) e))
925 cinfo (mime::preview-content-info/content-info pc)
926 rcnum (mime::content-info/rcnum cinfo))
927 (setq len (length rcnum))
928 (setq p-beg (mime::preview-content-info/point-min pc)
929 p-end (mime::preview-content-info/point-max pc))
930 (while (and (setq cell (car rest))
933 (mime::content-info/rcnum
934 (mime::preview-content-info/content-info
937 (nthcdr (- (length rc) len) rc))
939 (setq p-end (mime::preview-content-info/point-max cell))
940 (setq rest (cdr rest))
943 (let* ((mode (mime-preview/get-original-major-mode))
944 (new-name (format "%s-%s" (buffer-name) (reverse rcnum)))
946 (the-buf (current-buffer))
947 (a-buf mime::preview/article-buffer)
948 (hb (mime::content-info/point-min cinfo))
949 (he (mime::content-info/point-max cinfo))
950 fields from to cc reply-to subj mid f)
952 (set-buffer (setq new-buf (get-buffer-create new-name)))
954 (insert-buffer-substring the-buf p-beg p-end)
955 (goto-char (point-min))
956 (if (mime-view-header-visible-p rcnum root-cinfo)
957 (delete-region (goto-char (point-min))
958 (if (re-search-forward "^$" nil t)
962 (goto-char (point-min))
964 (goto-char (point-min))
965 (let ((rcnum (mime::content-info/rcnum cinfo)) ci str)
970 (setq ci (mime-article/rcnum-to-cinfo rcnum))
973 (mime::content-info/point-min ci)
974 (mime::content-info/point-max ci)
976 (std11-header-string-except
978 (apply (function regexp-or) fields)
980 (if (string-equal (mime::content-info/type ci)
987 (setq fields (std11-collect-field-names)
991 (let ((rest mime-view-following-required-fields-list))
993 (let ((field-name (car rest)))
994 (or (std11-field-body field-name)
1000 (set-buffer the-buf)
1001 (set-buffer mime::preview/mother-buffer)
1002 (set-buffer mime::preview/article-buffer)
1003 (std11-field-body field-name)
1007 (setq rest (cdr rest))
1009 (eword-decode-header)
1011 (let ((f (cdr (assq mode mime-view-following-method-alist))))
1016 "Sorry, following method for %s is not implemented yet."
1021 (defun mime-view-display-x-face ()
1023 (save-window-excursion
1024 (set-buffer mime::preview/article-buffer)
1025 (mime-view-x-face-function)
1028 (defun mime-view-up-content ()
1030 (let* ((pc (mime-preview/point-pcinfo (point)))
1031 (cinfo (mime::preview-content-info/content-info pc))
1032 (rcnum (mime::content-info/rcnum cinfo))
1035 (let ((r (save-excursion
1036 (set-buffer (mime::preview-content-info/buffer pc))
1037 (mime-article/rcnum-to-cinfo (cdr rcnum))
1039 (rpcl mime::preview/content-list)
1042 (setq cell (car rpcl))
1043 (not (eq r (mime::preview-content-info/content-info cell)))
1045 (setq rpcl (cdr rpcl))
1047 (goto-char (mime::preview-content-info/point-min cell))
1052 (defun mime-view-previous-content ()
1054 (let* ((pcl mime::preview/content-list)
1056 (i (- (length pcl) 1))
1060 (setq beg (mime::preview-content-info/point-min (nth i pcl)))
1062 (throw 'tag (goto-char beg))
1066 (let ((f (assq mime::preview/original-major-mode
1067 mime-view-over-to-previous-method-alist)))
1074 (defun mime-view-next-content ()
1076 (let ((pcl mime::preview/content-list)
1081 (setq beg (mime::preview-content-info/point-min (car pcl)))
1083 (throw 'tag (goto-char beg))
1085 (setq pcl (cdr pcl))
1087 (let ((f (assq mime::preview/original-major-mode
1088 mime-view-over-to-next-method-alist)))
1095 (defun mime-view-scroll-up-content (&optional h)
1098 (setq h (- (window-height) 1))
1100 (if (= (point) (point-max))
1101 (let ((f (assq mime::preview/original-major-mode
1102 mime-view-over-to-next-method-alist)))
1106 (let ((pcl mime::preview/content-list)
1112 (setq beg (mime::preview-content-info/point-min (car pcl)))
1116 (setq pcl (cdr pcl))
1127 (defun mime-view-scroll-down-content (&optional h)
1130 (setq h (- (window-height) 1))
1132 (if (= (point) (point-min))
1133 (let ((f (assq mime::preview/original-major-mode
1134 mime-view-over-to-previous-method-alist)))
1138 (let ((pcl mime::preview/content-list)
1142 (or (let ((i (- (length pcl) 1)))
1145 (setq beg (mime::preview-content-info/point-min
1153 (forward-line (- h))
1159 (defun mime-view-next-line-content ()
1161 (mime-view-scroll-up-content 1)
1164 (defun mime-view-previous-line-content ()
1166 (mime-view-scroll-down-content 1)
1169 (defun mime-view-quit ()
1171 (let ((r (save-excursion
1172 (set-buffer (mime::preview-content-info/buffer
1173 (mime-preview/point-pcinfo (point))))
1174 (assq major-mode mime-view-quitting-method-alist)
1180 (defun mime-view-show-summary ()
1182 (let ((r (save-excursion
1184 (mime::preview-content-info/buffer
1185 (mime-preview/point-pcinfo (point)))
1187 (assq major-mode mime-view-show-summary-method)
1193 (defun mime-view-kill-buffer ()
1195 (kill-buffer (current-buffer))
1202 (provide 'mime-view)
1204 (run-hooks 'mime-view-load-hook)
1206 ;;; mime-view.el ends here