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.4 $
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.
46 (defconst mime-view-RCS-ID
47 "$Id: mime-view.el,v 0.4 1997-02-21 05:29:42 tmorioka Exp $")
49 (defconst mime-view-version (get-version-string mime-view-RCS-ID))
55 (defvar mime/content-decoding-condition
56 '(((type . "text/plain")
57 (method "tm-plain" nil 'file 'type 'encoding 'mode 'name)
61 (method "tm-html" nil 'file 'type 'encoding 'mode 'name)
64 ((type . "text/x-rot13-47")
65 (method . mime-article/decode-caesar)
68 ((type . "audio/basic")
69 (method "tm-au" nil 'file 'type 'encoding 'mode 'name)
73 ((type . "image/jpeg")
74 (method "tm-image" nil 'file 'type 'encoding 'mode 'name)
78 (method "tm-image" nil 'file 'type 'encoding 'mode 'name)
81 ((type . "image/tiff")
82 (method "tm-image" nil 'file 'type 'encoding 'mode 'name)
85 ((type . "image/x-tiff")
86 (method "tm-image" nil 'file 'type 'encoding 'mode 'name)
89 ((type . "image/x-xbm")
90 (method "tm-image" nil 'file 'type 'encoding 'mode 'name)
93 ((type . "image/x-pic")
94 (method "tm-image" nil 'file 'type 'encoding 'mode 'name)
97 ((type . "image/x-mag")
98 (method "tm-image" nil 'file 'type 'encoding 'mode 'name)
102 ((type . "video/mpeg")
103 (method "tm-mpeg" nil 'file 'type 'encoding 'mode 'name)
107 ((type . "application/postscript")
108 (method "tm-ps" nil 'file 'type 'encoding 'mode 'name)
109 (mode "play" "print")
111 ((type . "application/octet-stream")
112 (method "tm-file" nil 'file 'type 'encoding 'mode 'name)
113 (mode "play" "print")
116 ;;((type . "message/external-body")
117 ;; (method "xterm" nil
118 ;; "-e" "showexternal"
119 ;; 'file '"access-type" '"name" '"site" '"directory"))
120 ((type . "message/rfc822")
121 (method . mime-article/view-message/rfc822)
124 ((type . "message/partial")
125 (method . mime-article/decode-message/partial)
129 ((method "metamail" t "-m" "tm" "-x" "-d" "-z" "-e" 'file)
132 ((method "tm-file" nil 'file 'type 'encoding 'mode 'name)
137 (defvar mime-view-childrens-header-showing-Content-Type-list
138 '("message/rfc822" "message/news"))
140 (defvar mime-view-default-showing-Content-Type-list
141 '("text/plain" nil "text/richtext" "text/enriched"
142 "text/x-latex" "application/x-latex"
143 "message/delivery-status"
144 "application/pgp" "text/x-pgp"
145 "application/octet-stream"
146 "application/x-selection" "application/x-comment"))
148 (defvar mime-view-content-button-ignored-ctype-list
149 '("application/x-selection"))
151 (defvar mime-view-content-button-visible-ctype-list
152 '("application/pgp"))
154 (defvar mime-view-uuencode-encoding-name-list '("x-uue" "x-uuencode"))
156 (defvar mime-view-ignored-field-list
157 '(".*Received" ".*Path" ".*Id" "References"
158 "Replied" "Errors-To"
159 "Lines" "Sender" ".*Host" "Xref"
160 "Content-Type" "Precedence"
162 "All fields that match this list will be hidden in MIME preview buffer.
163 Each elements are regexp of field-name. [mime-view.el]")
165 (defvar mime-view-ignored-field-regexp
167 (apply (function regexp-or) mime-view-ignored-field-list)
170 (defvar mime-view-visible-field-list
171 '("Dnas.*" "Message-Id")
172 "All fields that match this list will be displayed in MIME preview buffer.
173 Each elements are regexp of field-name. [mime-view.el]")
175 (defvar mime-view-visible-field-regexp
177 (apply (function regexp-or) mime-view-visible-field-list)
180 (defvar mime-view-redisplay nil)
182 (defvar mime-view-announcement-for-message/partial
183 (if (and (>= emacs-major-version 19) window-system)
185 \[[ This is message/partial style split message. ]]
186 \[[ Please press `v' key in this buffer ]]
187 \[[ or click here by mouse button-2. ]]"
189 \[[ This is message/partial style split message. ]]
190 \[[ Please press `v' key in this buffer. ]]"
194 ;;; @@ predicate functions
197 (defun mime-view-header-visible-p (rcnum cinfo &optional ctype)
201 (mime::content-info/type
202 (mime-article/rcnum-to-cinfo (cdr rcnum) cinfo)
204 (member ctype mime-view-childrens-header-showing-Content-Type-list)
207 (defun mime-view-body-visible-p (rcnum cinfo &optional ctype)
211 (mime::content-info/type
212 (setq ccinfo (mime-article/rcnum-to-cinfo rcnum cinfo))
215 (and (member ctype mime-view-default-showing-Content-Type-list)
216 (if (string-equal ctype "application/octet-stream")
219 (setq ccinfo (mime-article/rcnum-to-cinfo rcnum cinfo))
221 (member (mime::content-info/encoding ccinfo)
222 '(nil "7bit" "8bit"))
228 ;;; @@ content button
231 (defun mime-preview/insert-content-button
232 (rcnum cinfo ctype params subj encoding)
234 (narrow-to-region (point)(point))
235 (let ((access-type (assoc "access-type" params))
236 (charset (assoc "charset" params))
237 (num (or (assoc-value "x-part-number" params)
241 (format "%s" (1+ num))
247 (let ((server (assoc "server" params)))
248 (setq access-type (cdr access-type))
250 (insert (format "[%s %s ([%s] %s)]\n" num subj
251 access-type (cdr server)))
252 (let ((site (assoc-value "site" params))
253 (dir (assoc-value "directory" params))
255 (insert (format "[%s %s ([%s] %s:%s)]\n" num subj
256 access-type site dir))
260 (insert (concat "[" num " " subj))
262 (if (setq charset (cdr charset))
264 (format " <%s; %s (%s)>]\n"
265 ctype charset encoding)
266 (format " <%s; %s>]\n" ctype charset)
268 (format " <%s>]\n" ctype)
270 (if (>= (+ (current-column)(length rest))(window-width))
271 (setq rest (concat "\n\t" rest))
275 (tm:add-button (point-min)(1- (point-max))
276 (function mime-view-play-content))
279 (defun mime-preview/default-content-button-function
280 (rcnum cinfo ctype params subj encoding)
281 (if (and (consp rcnum)
284 mime-view-content-button-ignored-ctype-list)))
285 (mime-preview/insert-content-button
286 rcnum cinfo ctype params subj encoding)
289 (defvar mime-preview/content-button-function
290 (function mime-preview/default-content-button-function))
293 ;;; @@ content header filter
296 (defun mime-preview/cut-header ()
297 (goto-char (point-min))
299 (re-search-forward mime-view-ignored-field-regexp nil t)
300 (let* ((beg (match-beginning 0))
302 (name (buffer-substring beg end))
304 (if (not (string-match mime-view-visible-field-regexp name))
309 (re-search-forward "^\\([^ \t]\\|$\\)" nil t)
316 (defun mime-view-default-content-header-filter ()
317 (mime-preview/cut-header)
318 (mime/decode-message-header)
321 (defvar mime-view-content-header-filter-alist nil)
324 ;;; @@ content filter
327 (defvar mime-view-content-filter-alist
328 '(("text/enriched" . mime-preview/filter-for-text/enriched)
329 ("text/richtext" . mime-preview/filter-for-text/richtext)
330 (t . mime-preview/filter-for-text/plain)
334 ;;; @@ content separator
337 (defun mime-preview/default-content-separator (rcnum cinfo ctype params subj)
338 (if (and (not (mime-view-header-visible-p rcnum cinfo ctype))
339 (not (mime-view-body-visible-p rcnum cinfo ctype))
342 (goto-char (point-max))
347 ;;; @@ buffer local variables
351 (defvar mime::article/preview-buffer nil)
352 (defvar mime::article/code-converter nil)
353 (defvar mime::preview/article-buffer nil)
355 (make-variable-buffer-local 'mime::article/content-info)
356 (make-variable-buffer-local 'mime::article/preview-buffer)
357 (make-variable-buffer-local 'mime::article/code-converter)
359 (make-variable-buffer-local 'mime::preview/mother-buffer)
360 (make-variable-buffer-local 'mime::preview/content-list)
361 (make-variable-buffer-local 'mime::preview/article-buffer)
362 (make-variable-buffer-local 'mime::preview/original-major-mode)
363 (make-variable-buffer-local 'mime::preview/original-window-configuration)
366 ;;; @@ quitting method
369 (defvar mime-view-quitting-method-alist
370 '((mime/show-message-mode
371 . mime-view-quitting-method-for-mime/show-message-mode)))
373 (defvar mime-view-over-to-previous-method-alist nil)
374 (defvar mime-view-over-to-next-method-alist nil)
376 (defvar mime-view-show-summary-method nil)
379 ;;; @@ following method
382 (defvar mime-view-following-method-alist nil)
384 (defvar mime-view-following-required-fields-list
391 ;; hack from Gnus 5.0.4.
393 (defvar mime-view-x-face-to-pbm-command
394 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm")
396 (defvar mime-view-x-face-command
397 (concat mime-view-x-face-to-pbm-command
399 "String to be executed to display an X-Face field.
400 The command will be executed in a sub-shell asynchronously.
401 The compressed face will be piped to this command.")
403 (defun mime-view-x-face-function ()
404 "Function to display X-Face field. You can redefine to customize."
405 ;; 1995/10/12 (c.f. tm-eng:130)
406 ;; fixed by Eric Ding <ericding@San-Jose.ate.slb.com>
408 (narrow-to-region (point-min) (re-search-forward "^$" nil t))
410 (goto-char (point-min))
411 (if (re-search-forward "^X-Face:[ \t]*" nil t)
412 (let ((beg (match-end 0))
413 (end (std11-field-end))
415 (call-process-region beg end "sh" nil 0 nil
416 "-c" mime-view-x-face-command)
423 (defun mime-preview/get-original-major-mode ()
424 (if mime::preview/mother-buffer
426 (set-buffer mime::preview/mother-buffer)
427 (mime-preview/get-original-major-mode)
429 mime::preview/original-major-mode))
432 ;;; @ data structures
435 ;;; @@ preview-content-info
438 (define-structure mime::preview-content-info
439 point-min point-max buffer content-info)
445 (defun mime-view-setup-buffer (&optional ctl encoding ibuf obuf)
451 (or mime-view-redisplay
452 (setq mime::article/content-info (mime/parse-message ctl encoding))
454 (let ((ret (mime-view-make-preview-buffer obuf)))
455 (setq mime::article/preview-buffer (car ret))
458 (defun mime-view-make-preview-buffer (&optional obuf)
459 (let* ((cinfo mime::article/content-info)
460 (pcl (mime/flatten-content-info cinfo))
461 (dest (make-list (length pcl) nil))
462 (the-buf (current-buffer))
466 (setq obuf (concat "*Preview-" (buffer-name the-buf) "*")))
467 (set-buffer (get-buffer-create obuf))
468 (setq buffer-read-only nil)
471 (setq mime::preview/article-buffer the-buf)
472 (setq mime::preview/original-major-mode mode)
473 (setq major-mode 'mime-view-mode)
474 (setq mode-name "MIME-View")
478 (mime-preview/display-content (car pcl) cinfo the-buf obuf))
482 (set-buffer-modified-p nil)
483 (setq buffer-read-only t)
488 (defun mime-preview/display-content (content cinfo ibuf obuf)
489 (let* ((beg (mime::content-info/point-min content))
490 (end (mime::content-info/point-max content))
491 (ctype (mime::content-info/type content))
492 (params (mime::content-info/parameters content))
493 (encoding (mime::content-info/encoding content))
494 (rcnum (mime::content-info/rcnum content))
498 (setq he (if (re-search-forward "^$" nil t)
505 (narrow-to-region beg end)
507 (mime-eword/decode-string
508 (mime-article/get-subject params encoding)))
512 (narrow-to-region nb nb)
513 (funcall mime-preview/content-button-function
514 rcnum cinfo ctype params subj encoding)
515 (if (mime-view-header-visible-p rcnum cinfo ctype)
516 (mime-preview/display-header beg he)
518 (if (and (null rcnum)
520 ctype mime-view-content-button-visible-ctype-list))
522 (goto-char (point-max))
523 (mime-preview/insert-content-button
524 rcnum cinfo ctype params subj encoding)
526 (cond ((mime-view-body-visible-p rcnum cinfo ctype)
527 (mime-preview/display-body he end
528 rcnum cinfo ctype params subj encoding)
530 ((equal ctype "message/partial")
531 (mime-preview/display-message/partial)
534 (null (mime::content-info/children cinfo))
536 (goto-char (point-max))
537 (mime-preview/insert-content-button
538 rcnum cinfo ctype params subj encoding)
540 (mime-preview/default-content-separator rcnum cinfo ctype params subj)
543 (setq ne (point-max))
545 (mime::preview-content-info/create nb (1- ne) ibuf content)
550 (defun mime-preview/display-header (beg end)
552 (narrow-to-region (point)(point))
553 (insert-buffer-substring mime::preview/article-buffer beg end)
554 (let ((f (cdr (assq mime::preview/original-major-mode
555 mime-view-content-header-filter-alist))))
558 (mime-view-default-content-header-filter)
560 (run-hooks 'mime-view-content-header-filter-hook)
563 (defun mime-preview/display-body (beg end
564 rcnum cinfo ctype params subj encoding)
566 (narrow-to-region (point-max)(point-max))
567 (insert-buffer-substring mime::preview/article-buffer beg end)
568 (let ((f (cdr (or (assoc ctype mime-view-content-filter-alist)
569 (assq t mime-view-content-filter-alist)))))
571 (funcall f ctype params encoding)
575 (defun mime-preview/display-message/partial ()
577 (goto-char (point-max))
578 (if (not (search-backward "\n\n" nil t))
581 (let ((be (point-max)))
582 (narrow-to-region be be)
583 (insert mime-view-announcement-for-message/partial)
584 (tm:add-button (point-min)(point-max)
585 (function mime-view-play-content))
588 (defun mime-article/get-uu-filename (param &optional encoding)
589 (if (member (or encoding
590 (cdr (assq 'encoding param))
592 mime-view-uuencode-encoding-name-list)
594 (or (if (re-search-forward "^begin [0-9]+ " nil t)
595 (if (looking-at ".+$")
596 (buffer-substring (match-beginning 0)(match-end 0))
601 (defun mime-article/get-subject (param &optional encoding)
602 (or (std11-find-field-body '("Content-Description" "Subject"))
604 (if (or (and (setq ret (mime/Content-Disposition))
605 (setq ret (assoc "filename" (cdr ret)))
607 (setq ret (assoc "name" param))
608 (setq ret (assoc "x-name" param))
610 (std11-strip-quoted-string (cdr ret))
612 (mime-article/get-uu-filename param encoding)
616 ;;; @ content information
619 (defun mime-article/point-content-number (p &optional cinfo)
621 (setq cinfo mime::article/content-info)
623 (let ((b (mime::content-info/point-min cinfo))
624 (e (mime::content-info/point-max cinfo))
625 (c (mime::content-info/children cinfo))
627 (if (and (<= b p)(<= p e))
628 (or (let (co ret (sn 0))
632 (setq ret (mime-article/point-content-number p co))
633 (cond ((eq ret t) (throw 'tag (list sn)))
634 (ret (throw 'tag (cons sn ret)))
641 (defun mime-article/rcnum-to-cinfo (rcnum &optional cinfo)
643 (setq cinfo mime::article/content-info)
647 (equal (mime::content-info/rcnum ci) rcnum)
649 (mime/flatten-content-info cinfo)
652 (defun mime-article/cnum-to-cinfo (cn &optional cinfo)
654 (setq cinfo mime::article/content-info)
661 (let ((rc (nth sn (mime::content-info/children cinfo))))
663 (mime-article/cnum-to-cinfo (cdr cn) rc)
667 (defun mime/flatten-content-info (&optional cinfo)
669 (setq cinfo mime::article/content-info)
671 (let ((dest (list cinfo))
672 (rcl (mime::content-info/children cinfo))
675 (setq dest (nconc dest (mime/flatten-content-info (car rcl))))
680 (defun mime-preview/point-pcinfo (p &optional pcl)
682 (setq pcl mime::preview/content-list)
688 (if (and (<= (mime::preview-content-info/point-min cell) p)
689 (<= p (mime::preview-content-info/point-max cell))
699 ;;; @ MIME viewer mode
702 (defconst mime-view-menu-title "MIME-View")
703 (defconst mime-view-menu-list
704 '((up "Move to upper content" mime-view-up-content)
705 (previous "Move to previous content" mime-view-previous-content)
706 (next "Move to next content" mime-view-next-content)
707 (scroll-down "Scroll to previous content" mime-view-scroll-down-content)
708 (scroll-up "Scroll to next content" mime-view-scroll-up-content)
709 (play "Play Content" mime-view-play-content)
710 (extract "Extract Content" mime-view-extract-content)
711 (print "Print" mime-view-print-content)
712 (x-face "Show X Face" mime-view-display-x-face)
714 "Menu for MIME Viewer")
718 (defvar mime-view-xemacs-popup-menu
719 (cons mime-view-menu-title
722 (vector (nth 1 item)(nth 2 item) t)
724 mime-view-menu-list)))
725 (defun mime-view-xemacs-popup-menu (event)
726 "Popup the menu in the MIME Viewer buffer"
728 (select-window (event-window event))
729 (set-buffer (event-buffer event))
730 (popup-menu 'mime-view-xemacs-popup-menu))
733 (defun mime-view-define-keymap (&optional default)
734 (let ((mime-view-mode-map (if (keymapp default)
735 (copy-keymap default)
738 (or (keymapp default)
739 (suppress-keymap mime-view-mode-map)
741 (define-key mime-view-mode-map
742 "u" (function mime-view-up-content))
743 (define-key mime-view-mode-map
744 "p" (function mime-view-previous-content))
745 (define-key mime-view-mode-map
746 "n" (function mime-view-next-content))
747 (define-key mime-view-mode-map
748 "\e\t" (function mime-view-previous-content))
749 (define-key mime-view-mode-map
750 "\t" (function mime-view-next-content))
751 (define-key mime-view-mode-map
752 " " (function mime-view-scroll-up-content))
753 (define-key mime-view-mode-map
754 "\M- " (function mime-view-scroll-down-content))
755 (define-key mime-view-mode-map
756 "\177" (function mime-view-scroll-down-content))
757 (define-key mime-view-mode-map
758 "\C-m" (function mime-view-next-line-content))
759 (define-key mime-view-mode-map
760 "\C-\M-m" (function mime-view-previous-line-content))
761 (define-key mime-view-mode-map
762 "v" (function mime-view-play-content))
763 (define-key mime-view-mode-map
764 "e" (function mime-view-extract-content))
765 (define-key mime-view-mode-map
766 "\C-c\C-p" (function mime-view-print-content))
767 (define-key mime-view-mode-map
768 "x" (function mime-view-display-x-face))
769 (define-key mime-view-mode-map
770 "a" (function mime-view-follow-content))
771 (define-key mime-view-mode-map
772 "q" (function mime-view-quit))
773 (define-key mime-view-mode-map
774 "h" (function mime-view-show-summary))
775 (define-key mime-view-mode-map
776 "\C-c\C-x" (function mime-view-kill-buffer))
777 (define-key mime-view-mode-map
778 "<" (function beginning-of-buffer))
779 (define-key mime-view-mode-map
780 ">" (function end-of-buffer))
781 (define-key mime-view-mode-map
782 "?" (function describe-mode))
783 (if (functionp default)
784 (setq mime-view-mode-map
785 (append mime-view-mode-map (list (cons t default)))
788 (define-key mime-view-mode-map
789 mouse-button-2 (function tm:button-dispatcher))
791 (cond (running-xemacs
792 (define-key mime-view-mode-map
793 mouse-button-3 (function mime-view-xemacs-popup-menu))
795 ((>= emacs-major-version 19)
796 (define-key mime-view-mode-map [menu-bar mime-view]
797 (cons mime-view-menu-title
798 (make-sparse-keymap mime-view-menu-title)))
801 (define-key mime-view-mode-map
802 (vector 'menu-bar 'mime-view (car item))
803 (cons (nth 1 item)(nth 2 item))
806 (reverse mime-view-menu-list)
809 (use-local-map mime-view-mode-map)
810 (run-hooks 'mime-view-define-keymap-hook)
813 (defun mime-view-mode (&optional mother ctl encoding ibuf obuf
814 default-keymap-or-function)
815 "Major mode for viewing MIME message.
817 Here is a list of the standard keys for mime-view-mode.
822 u Move to upper content
823 p or M-TAB Move to previous content
824 n or TAB Move to next content
825 SPC Scroll up or move to next content
826 M-SPC or DEL Scroll down or move to previous content
827 RET Move to next line
828 M-RET Move to previous line
829 v Decode current content as `play mode'
830 e Decode current content as `extract mode'
831 C-c C-p Decode current content as `print mode'
832 a Followup to current content.
835 button-2 Move to point under the mouse cursor
836 and decode current content as `play mode'
839 (let ((buf (get-buffer mime/output-buffer-name)))
845 (let ((ret (mime-view-setup-buffer ctl encoding ibuf obuf))
846 (win-conf (current-window-configuration))
849 (switch-to-buffer (car ret))
850 (setq mime::preview/original-window-configuration win-conf)
853 (setq mime::preview/mother-buffer mother)
855 (mime-view-define-keymap default-keymap-or-function)
856 (setq mime::preview/content-list (nth 1 ret))
858 (let ((ce (mime::preview-content-info/point-max
859 (car mime::preview/content-list)
862 (goto-char (point-min))
863 (search-forward "\n\n" nil t)
864 (setq e (match-end 0))
868 (run-hooks 'mime-view-mode-hook)
871 (defun mime-preview/point-content-number (point)
872 (save-window-excursion
873 (let ((pc (mime-preview/point-pcinfo (point)))
875 (switch-to-buffer (mime::preview-content-info/buffer pc))
876 (setq cinfo (mime::preview-content-info/content-info pc))
877 (mime-article/point-content-number (mime::content-info/point-min cinfo))
880 (defun mime-preview/cinfo-to-pcinfo (cinfo)
881 (let ((rpcl mime::preview/content-list) cell)
884 (setq cell (car rpcl))
885 (if (eq cinfo (mime::preview-content-info/content-info cell))
888 (setq rpcl (cdr rpcl))
891 (autoload 'mime-preview/decode-content "mime-play")
893 (defvar mime-view-decoding-mode "play" "MIME body decoding mode")
895 (defun mime-view-play-content ()
897 (let ((mime-view-decoding-mode "play"))
898 (mime-preview/decode-content)
901 (defun mime-view-extract-content ()
903 (let ((mime-view-decoding-mode "extract"))
904 (mime-preview/decode-content)
907 (defun mime-view-print-content ()
909 (let ((mime-view-decoding-mode "print"))
910 (mime-preview/decode-content)
913 (defun mime-view-follow-content ()
916 (mime::preview-content-info/content-info
917 (car mime::preview/content-list)))
918 pc p-beg p-end cinfo rcnum)
919 (let ((rest mime::preview/content-list)
922 (while (setq cell (car rest))
923 (setq b (mime::preview-content-info/point-min cell)
924 e (mime::preview-content-info/point-max cell))
925 (setq rest (cdr rest))
926 (if (and (<= b (point))(<= (point) e))
932 cinfo (mime::preview-content-info/content-info pc)
933 rcnum (mime::content-info/rcnum cinfo))
934 (setq len (length rcnum))
935 (setq p-beg (mime::preview-content-info/point-min pc)
936 p-end (mime::preview-content-info/point-max pc))
937 (while (and (setq cell (car rest))
940 (mime::content-info/rcnum
941 (mime::preview-content-info/content-info
944 (nthcdr (- (length rc) len) rc))
946 (setq p-end (mime::preview-content-info/point-max cell))
947 (setq rest (cdr rest))
950 (let* ((mode (mime-preview/get-original-major-mode))
951 (new-name (format "%s-%s" (buffer-name) (reverse rcnum)))
953 (the-buf (current-buffer))
954 (a-buf mime::preview/article-buffer)
955 (hb (mime::content-info/point-min cinfo))
956 (he (mime::content-info/point-max cinfo))
957 fields from to cc reply-to subj mid f)
959 (set-buffer (setq new-buf (get-buffer-create new-name)))
961 (insert-buffer-substring the-buf p-beg p-end)
962 (goto-char (point-min))
963 (if (mime-view-header-visible-p rcnum root-cinfo)
964 (delete-region (goto-char (point-min))
965 (if (re-search-forward "^$" nil t)
969 (goto-char (point-min))
971 (goto-char (point-min))
972 (let ((rcnum (mime::content-info/rcnum cinfo)) ci str)
977 (setq ci (mime-article/rcnum-to-cinfo rcnum))
980 (mime::content-info/point-min ci)
981 (mime::content-info/point-max ci)
983 (std11-header-string-except
985 (apply (function regexp-or) fields)
987 (if (string-equal (mime::content-info/type ci)
994 (setq fields (std11-collect-field-names)
998 (let ((rest mime-view-following-required-fields-list))
1000 (let ((field-name (car rest)))
1001 (or (std11-field-body field-name)
1007 (set-buffer the-buf)
1008 (set-buffer mime::preview/mother-buffer)
1009 (set-buffer mime::preview/article-buffer)
1010 (std11-field-body field-name)
1014 (setq rest (cdr rest))
1016 (mime/decode-message-header)
1018 (let ((f (cdr (assq mode mime-view-following-method-alist))))
1023 "Sorry, following method for %s is not implemented yet."
1028 (defun mime-view-display-x-face ()
1030 (save-window-excursion
1031 (set-buffer mime::preview/article-buffer)
1032 (mime-view-x-face-function)
1035 (defun mime-view-up-content ()
1037 (let* ((pc (mime-preview/point-pcinfo (point)))
1038 (cinfo (mime::preview-content-info/content-info pc))
1039 (rcnum (mime::content-info/rcnum cinfo))
1042 (let ((r (save-excursion
1043 (set-buffer (mime::preview-content-info/buffer pc))
1044 (mime-article/rcnum-to-cinfo (cdr rcnum))
1046 (rpcl mime::preview/content-list)
1049 (setq cell (car rpcl))
1050 (not (eq r (mime::preview-content-info/content-info cell)))
1052 (setq rpcl (cdr rpcl))
1054 (goto-char (mime::preview-content-info/point-min cell))
1059 (defun mime-view-previous-content ()
1061 (let* ((pcl mime::preview/content-list)
1063 (i (- (length pcl) 1))
1067 (setq beg (mime::preview-content-info/point-min (nth i pcl)))
1069 (throw 'tag (goto-char beg))
1073 (let ((f (assq mime::preview/original-major-mode
1074 mime-view-over-to-previous-method-alist)))
1081 (defun mime-view-next-content ()
1083 (let ((pcl mime::preview/content-list)
1088 (setq beg (mime::preview-content-info/point-min (car pcl)))
1090 (throw 'tag (goto-char beg))
1092 (setq pcl (cdr pcl))
1094 (let ((f (assq mime::preview/original-major-mode
1095 mime-view-over-to-next-method-alist)))
1102 (defun mime-view-scroll-up-content (&optional h)
1105 (setq h (- (window-height) 1))
1107 (if (= (point) (point-max))
1108 (let ((f (assq mime::preview/original-major-mode
1109 mime-view-over-to-next-method-alist)))
1113 (let ((pcl mime::preview/content-list)
1119 (setq beg (mime::preview-content-info/point-min (car pcl)))
1123 (setq pcl (cdr pcl))
1134 (defun mime-view-scroll-down-content (&optional h)
1137 (setq h (- (window-height) 1))
1139 (if (= (point) (point-min))
1140 (let ((f (assq mime::preview/original-major-mode
1141 mime-view-over-to-previous-method-alist)))
1145 (let ((pcl mime::preview/content-list)
1149 (or (let ((i (- (length pcl) 1)))
1152 (setq beg (mime::preview-content-info/point-min
1160 (forward-line (- h))
1166 (defun mime-view-next-line-content ()
1168 (mime-view-scroll-up-content 1)
1171 (defun mime-view-previous-line-content ()
1173 (mime-view-scroll-down-content 1)
1176 (defun mime-view-quit ()
1178 (let ((r (save-excursion
1179 (set-buffer (mime::preview-content-info/buffer
1180 (mime-preview/point-pcinfo (point))))
1181 (assq major-mode mime-view-quitting-method-alist)
1187 (defun mime-view-show-summary ()
1189 (let ((r (save-excursion
1191 (mime::preview-content-info/buffer
1192 (mime-preview/point-pcinfo (point)))
1194 (assq major-mode mime-view-show-summary-method)
1200 (defun mime-view-kill-buffer ()
1202 (kill-buffer (current-buffer))
1209 (provide 'mime-view)
1211 (run-hooks 'mime-view-load-hook)
1213 ;;; mime-view.el ends here