From 17b21ac06f99fb910439173553454246348c5011 Mon Sep 17 00:00:00 2001 From: morioka Date: Mon, 9 Mar 1998 08:28:46 +0000 Subject: [PATCH] tm 7.6. --- Changes-6.92-7.06.en | 128 +++++++++ Changes-6.92-7.06.ja | 128 +++++++++ Makefile | 5 +- gnus/Makefile | 2 +- gnus/tm-sgnus.el | 8 +- mk-tm | 4 +- tm-def.el | 16 +- tm-parse.el | 163 ++++++++++++ tm-play.el | 243 +++++++++++++++++ tm-view.el | 707 +++++++++++--------------------------------------- tm-vm.el | 8 +- 11 files changed, 844 insertions(+), 568 deletions(-) create mode 100644 Changes-6.92-7.06.en create mode 100644 Changes-6.92-7.06.ja create mode 100644 tm-parse.el create mode 100644 tm-play.el diff --git a/Changes-6.92-7.06.en b/Changes-6.92-7.06.en new file mode 100644 index 0000000..11d95a0 --- /dev/null +++ b/Changes-6.92-7.06.en @@ -0,0 +1,128 @@ +* tl + + Attached version 6.6.7. + +tl/tl-header.el +---------------------------- +revision 5.10 +date: 1995/09/26 00:23:15; author: morioka; state: Exp; lines: +1 -18 +Parsed data structure was deleted. +---------------------------- + + +* tm + +tm/tm-def.el +---------------------------- +revision 6.7 +date: 1995/09/25 22:21:48; author: morioka; state: Exp; lines: +15 -1 +Definitions of constants were moved from tm-view.el. +---------------------------- + +tm/tm-parse.el +---------------------------- +revision 2.4 +date: 1995/09/26 13:19:32; author: morioka; state: Exp; lines: +3 -2 +Quoted-string is strip in function `mime/parse-parameter'. +---------------------------- +revision 2.3 +date: 1995/09/26 04:25:13; author: morioka; state: Exp; lines: +4 -4 +Parser of tm-view.el was separated into tm-parse.el. +Parser was rewrote to speedup. +---------------------------- + +tm/tm-play.el +---------------------------- +revision 1.2 +date: 1995/09/26 11:54:38; author: morioka; state: Exp; lines: +25 -11 +Decoder of tm-view.el was separated into tm-play.el. +---------------------------- + +tm/tm-view.el +---------------------------- +revision 7.6 +date: 1995/09/26 11:53:46; author: morioka; state: Exp; lines: +41 -242 +Codes of decoder were moved to tm-play.el. +---------------------------- +revision 7.5 +date: 1995/09/26 10:22:34; author: morioka; state: Exp; lines: +107 -116 +Content displayer in function `mime-viewer/make-preview-buffer' was +separated into function `mime-viewer/display-content'. +---------------------------- +revision 7.4 +date: 1995/09/26 07:34:14; author: morioka; state: Exp; lines: +5 -8 +Argument `cinfo' of function `mime-viewer/make-preview-buffer' was deleted. +---------------------------- +revision 7.3 +date: 1995/09/26 07:15:29; author: morioka; state: Exp; lines: +16 -18 +Function `mime-viewer/make-preview-buffer' was modified. +---------------------------- +revision 7.2 +date: 1995/09/26 05:54:35; author: morioka; state: Exp; lines: +46 -51 +Function `mime-viewer/parse-message' was renamed to +`mime-viewer/setup-buffer'. +---------------------------- +revision 7.1 +date: 1995/09/26 05:28:56; author: morioka; state: Exp; lines: +4 -4 +Function `mime::make-flat-content-list' was renamed to +`mime/flatten-content-info'. +---------------------------- +revision 7.0 +date: 1995/09/26 03:21:54; author: morioka; state: Exp; lines: +2 -6 +Definition of structure `mime::content-info' was moved to tm-parse.el. +---------------------------- +revision 6.99 +date: 1995/09/26 02:59:41; author: morioka; state: Exp; lines: +2 -2 +tm-1521.el was renamed to tm-parse.el. +---------------------------- +revision 6.98 +date: 1995/09/26 02:32:27; author: morioka; state: Exp; lines: +2 -2 +Function `mime-viewer/parse' was renamed to `mime/parse-message'. +---------------------------- +revision 6.97 +date: 1995/09/26 02:22:17; author: morioka; state: Exp; lines: +1 -37 +Function `mime-viewer/parse' was moved to tm-1521.el. +---------------------------- +revision 6.96 +date: 1995/09/26 02:20:45; author: morioka; state: Exp; lines: +35 -39 +Unnecessary (save-excursion (save-restriction ...)) was deleted. +---------------------------- +revision 6.95 +date: 1995/09/26 01:15:00; author: morioka; state: Exp; lines: +4 -17 +Function `mime-viewer/parse' and function `mime/parse-multipart' were +modified. +---------------------------- +revision 6.94 +date: 1995/09/26 00:55:34; author: morioka; state: Exp; lines: +3 -111 +Parser for multipart was moved to tm-1521.el and renamed to +`mime/parse-multipart'. +---------------------------- +revision 6.93 +date: 1995/09/25 22:21:05; author: morioka; state: Exp; lines: +4 -16 +Definitions of constants were moved to tm-def.el. +---------------------------- + +tm/tm-vm.el +---------------------------- +revision 6.3 +date: 1995/09/26 00:15:07; author: morioka; state: Exp; lines: +4 -4 +Does not unfold because function `mime/parse-Content-Type' unfolds. +---------------------------- +revision 6.2 +date: 1995/09/25 23:41:10; author: morioka; state: Exp; lines: +2 -2 +Function `mime::parse-field-body/Content-Type' was renamed to +`mime/parse-Content-Type'. +---------------------------- + + +tm/gnus + + Attached version 6.24. + +tm/tm-sgnus.el +---------------------------- +revision 6.24 +date: 1995/09/26 12:08:35; author: morioka; state: Exp; lines: +2 -6 +Quitting-method was set for gnus-original-article-mode. +(Notice that it needs September Gnus v0.3 or later.) +---------------------------- diff --git a/Changes-6.92-7.06.ja b/Changes-6.92-7.06.ja new file mode 100644 index 0000000..80bc660 --- /dev/null +++ b/Changes-6.92-7.06.ja @@ -0,0 +1,128 @@ +* tl + + Version 6.6.7 を添付した。 + +tl/tl-header.el +---------------------------- +revision 5.10 +date: 1995/09/26 00:23:15; author: morioka; state: Exp; lines: +1 -18 +parsed data structure を削除した。 +---------------------------- + + +* tm + +tm/tm-def.el +---------------------------- +revision 6.7 +date: 1995/09/25 22:21:48; author: morioka; state: Exp; lines: +15 -1 +tm-view.el にあった定数の定義を移した。 +---------------------------- + +tm/tm-parse.el +---------------------------- +revision 2.4 +date: 1995/09/26 13:19:32; author: morioka; state: Exp; lines: +3 -2 +関数 mime/parse-parameter で value を strip するようにした。 +---------------------------- +revision 2.3 +date: 1995/09/26 04:25:13; author: morioka; state: Exp; lines: +4 -4 +tm-view.el の parser 関係の code を tm-parse.el として独立させた。 +parser を大幅に書き直し、無駄な code を削減させた。 +---------------------------- + +tm/tm-play.el +---------------------------- +revision 1.2 +date: 1995/09/26 11:54:38; author: morioka; state: Exp; lines: +25 -11 +tm-view.el の decoder 関係の code を tm-play.el として独立させた。 +---------------------------- + +tm/tm-view.el +---------------------------- +revision 7.6 +date: 1995/09/26 11:53:46; author: morioka; state: Exp; lines: +41 -242 +decoder 関係の code を tm-play.el に移した。 +---------------------------- +revision 7.5 +date: 1995/09/26 10:22:34; author: morioka; state: Exp; lines: +107 -116 +関数 mime-viewer/make-preview-buffer 中の各 content を表示する部分を関 +数 mime-viewer/display-content に分けた。 +---------------------------- +revision 7.4 +date: 1995/09/26 07:34:14; author: morioka; state: Exp; lines: +5 -8 +関数 mime-viewer/make-preview-buffer の引数 cinfo を廃止した。 +---------------------------- +revision 7.3 +date: 1995/09/26 07:15:29; author: morioka; state: Exp; lines: +16 -18 +関数 mime-viewer/make-preview-buffer をいじった。 +---------------------------- +revision 7.2 +date: 1995/09/26 05:54:35; author: morioka; state: Exp; lines: +46 -51 +関数 mime-viewer/parse-message を `mime-viewer/setup-buffer' に改名し +た。 +---------------------------- +revision 7.1 +date: 1995/09/26 05:28:56; author: morioka; state: Exp; lines: +4 -4 +関数 mime::make-flat-content-list を `mime/flatten-content-info' に改 +名した。 +---------------------------- +revision 7.0 +date: 1995/09/26 03:21:54; author: morioka; state: Exp; lines: +2 -6 +構造体 mime::content-info の定義を tm-parse.el に移した。 +---------------------------- +revision 6.99 +date: 1995/09/26 02:59:41; author: morioka; state: Exp; lines: +2 -2 +tm-1521.el を tm-parse.el に改名した。 +---------------------------- +revision 6.98 +date: 1995/09/26 02:32:27; author: morioka; state: Exp; lines: +2 -2 +関数 mime-viewer/parse を `mime/parse-message' に改名した。 +---------------------------- +revision 6.97 +date: 1995/09/26 02:22:17; author: morioka; state: Exp; lines: +1 -37 +関数 mime-viewer/parse を tm-1521.el に移した。 +---------------------------- +revision 6.96 +date: 1995/09/26 02:20:45; author: morioka; state: Exp; lines: +35 -39 +不要な (save-excursion (save-restriction ...)) を削除した。 +---------------------------- +revision 6.95 +date: 1995/09/26 01:15:00; author: morioka; state: Exp; lines: +4 -17 +関数 mime-viewer/parse と関数 mime/parse-multipart を修正した。 +---------------------------- +revision 6.94 +date: 1995/09/26 00:55:34; author: morioka; state: Exp; lines: +3 -111 +multipart を parse する関数を `mime/parse-multipart' として、 +tm-1521.el に移した。 +---------------------------- +revision 6.93 +date: 1995/09/25 22:21:05; author: morioka; state: Exp; lines: +4 -16 +定数の定義を tm-def.el に移した。 +---------------------------- + +tm/tm-vm.el +---------------------------- +revision 6.3 +date: 1995/09/26 00:15:07; author: morioka; state: Exp; lines: +4 -4 +関数 mime/parse-Content-Type が unfolding を行なうようになったので、引 +数を unfolding するのはやめた。 +---------------------------- +revision 6.2 +date: 1995/09/25 23:41:10; author: morioka; state: Exp; lines: +2 -2 +tm-view 6.94 に合わせて、関数 mime::parse-field-body/Content-Type を +`mime/parse-Content-Type' に書き直した。 +---------------------------- + + +tm/gnus + + Version 6.24 を添付した。 + +tm/tm-sgnus.el +---------------------------- +revision 6.24 +date: 1995/09/26 12:08:35; author: morioka; state: Exp; lines: +2 -6 +gnus-original-article-mode に対して quitting-method を設定するようにし +た。(September Gnus v0.3 以降が必要) +---------------------------- diff --git a/Makefile b/Makefile index d2136b3..9841c63 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ # -# $Id: Makefile,v 6.28 1995/09/08 18:04:24 morioka Exp morioka $ +# $Id: Makefile,v 7.0 1995/09/26 12:36:27 morioka Exp morioka $ # include config.tm @@ -10,6 +10,7 @@ GOMI = $(UTILS) *.elc loadpath TM_FILES = tm/README.eng tm/rel-*.ol tm/Changes* \ tm/config.tm tm/Makefile tm/mk-tm \ tm/tm-view.el tm/tiny-mime.el \ + tm/tm-parse.el tm/tm-play.el \ tm/tm-mule.el tm/tm-nemacs.el tm/tm-orig.el tm/tm-def.el \ tm/tm-ftp.el tm/tm-latex.el tm/tm-w3.el tm/tm-partial.el \ tm/tm-tar.el \ @@ -33,7 +34,7 @@ TL_FILES = tl/README.eng tl/Makefile tl/mk-tl tl/*.el tl/doc/*.texi FILES = $(TM_FILES) $(TM_MUA_FILES) $(MEL_FILES) $(TL_FILES) -TARFILE = tm6.92.tar +TARFILE = tm7.06.tar nemacs: diff --git a/gnus/Makefile b/gnus/Makefile index 8936255..50ec763 100644 --- a/gnus/Makefile +++ b/gnus/Makefile @@ -17,7 +17,7 @@ TMDIR19 = $(HOME)/lib/emacs19/lisp FILES = tm/gnus/*.el tm/doc/tm-gnus*.texi -TARFILE = tm-gnus6.23.tar +TARFILE = tm-gnus6.24.tar gnus3: diff --git a/gnus/tm-sgnus.el b/gnus/tm-sgnus.el index abc4cf4..47a0c96 100644 --- a/gnus/tm-sgnus.el +++ b/gnus/tm-sgnus.el @@ -12,7 +12,7 @@ ;;; (defconst tm-gnus/RCS-ID - "$Id: tm-sgnus.el,v 6.23 1995/09/24 20:20:32 morioka Exp $") + "$Id: tm-sgnus.el,v 6.24 1995/09/26 12:08:35 morioka Exp $") (defconst tm-gnus/version (concat (get-version-string tm-gnus/RCS-ID) " for September")) @@ -80,12 +80,8 @@ article is automatic MIME decoded.") (function (lambda () (set-alist 'mime-viewer/quitting-method-alist - 'fundamental-mode + 'gnus-original-article-mode (function mime-viewer/quitting-method-for-sgnus)) - (set-alist 'tm:callback-property-alist - 'fundamental-mode 'gnus-callback) - (set-alist 'tm:data-property-alist - 'fundamental-mode 'gnus-data) ))) diff --git a/mk-tm b/mk-tm index 3c371cd..56805c1 100644 --- a/mk-tm +++ b/mk-tm @@ -1,6 +1,6 @@ ;;; -*-Emacs-Lisp-*- ;;; -;;; $Id: mk-tm,v 3.0 1995/09/24 20:41:39 morioka Exp morioka $ +;;; $Id: mk-tm,v 4.0 1995/09/26 12:35:39 morioka Exp morioka $ ;;; (setq load-path (append @@ -29,7 +29,7 @@ "tm-orig" )) '("signature" - "tiny-mime" "tm-def" "tm-view" + "tiny-mime" "tm-def" "tm-parse" "tm-view" "tm-play" "tm-latex" "tm-w3" "tm-tar" "tm-rmail" "tm-comp" "tm-setup" "mime-setup" diff --git a/tm-def.el b/tm-def.el index 5b6d5fb..f27f59d 100644 --- a/tm-def.el +++ b/tm-def.el @@ -6,7 +6,7 @@ ;;; ;;; Author: MORIOKA Tomohiko ;;; Version: -;;; $Id: tm-def.el,v 6.6 1995/09/24 22:24:17 morioka Exp $ +;;; $Id: tm-def.el,v 6.7 1995/09/25 22:21:48 morioka Exp $ ;;; Keywords: mail, news, MIME, multimedia, definition ;;; ;;; This file is part of tm (Tools for MIME). @@ -30,6 +30,13 @@ )) +;;; @ constants +;;; + +(defconst mime/output-buffer-name "*MIME-out*") +(defconst mime/decoding-buffer-name "*MIME-decoding*") + + ;;; @ for various Emacs variants ;;; @@ -103,6 +110,13 @@ (defconst mime/token-regexp (concat "[^" mime/tspecials "]+")) (defconst mime/charset-regexp mime/token-regexp) +(defconst mime/content-type-subtype-regexp + (concat mime/token-regexp "/" mime/token-regexp)) +(defconst mime/content-parameter-value-regexp + (concat "\\(" + message/quoted-string-regexp + "\\|[^; \t\n]*\\)")) + ;;; @@ Base64 ;;; diff --git a/tm-parse.el b/tm-parse.el new file mode 100644 index 0000000..3a4d810 --- /dev/null +++ b/tm-parse.el @@ -0,0 +1,163 @@ +;;; +;;; tm-parse.el --- MIME message parser +;;; +;;; Copyright (C) 1995 Free Software Foundation, Inc. +;;; Copyright (C) 1994,1995 MORIOKA Tomohiko +;;; +;;; Author: MORIOKA Tomohiko +;;; Version: +;;; $Id: tm-parse.el,v 2.4 1995/09/26 13:19:32 morioka Exp $ +;;; Keywords: mail, news, MIME, multimedia +;;; +;;; This file is part of tm (Tools for MIME). +;;; + +(require 'tl-header) +(require 'tl-misc) +(require 'tm-def) + + +;;; @ field parser +;;; + +(defconst mime::parameter-regexp + (concat "^[ \t]*\;[ \t]*\\(" mime/token-regexp "\\)" + "[ \t]*=[ \t]*\\(" mime/content-parameter-value-regexp "\\)")) + +(defun mime/parse-parameter (str) + (if (string-match mime::parameter-regexp str) + (let ((e (match-end 2))) + (cons + (cons (downcase (substring str (match-beginning 1) (match-end 1))) + (message/strip-quoted-string + (substring str (match-beginning 2) e)) + ) + (substring str e) + )))) + +(defconst mime::ctype-regexp + (concat "^" mime/content-type-subtype-regexp)) + +(defun mime/parse-Content-Type (str) + "Parse STR as field-body of Content-Type field. [tm-parse.el]" + (setq str (message/unfolding-string str)) + (if (string-match mime::ctype-regexp str) + (let* ((e (match-end 0)) + (ctype (downcase (substring str 0 e))) + ret dest) + (setq str (substring str e)) + (while (setq ret (mime/parse-parameter str)) + (setq dest (cons (car ret) dest)) + (setq str (cdr ret)) + ) + (cons ctype (reverse dest)) + ))) + + +;;; @ field reader +;;; + +(defun mime/Content-Type () + "Read field-body of Content-Type field from current-buffer, +and return parsed it. [tm-parse.el]" + (let ((str (message/get-field-body "Content-Type"))) + (if str + (mime/parse-Content-Type str) + ))) + +(defun mime/Content-Transfer-Encoding (&optional default-encoding) + "Read field-body of Content-Transfer-Encoding field from +current-buffer, and return it. +If is is not found, return DEFAULT-ENCODING. [tm-parse.el]" + (let ((str (message/get-field-body "Content-Transfer-Encoding"))) + (if str + (downcase str) + default-encoding) + )) + + +;;; @ message parser +;;; + +(define-structure mime::content-info + point-min point-max type parameters encoding children) + + +(defun mime/parse-multipart (boundary ctype params encoding) + (goto-char (point-min)) + (let ((beg (point-min)) + (end (if (re-search-forward + (concat "^--" (regexp-quote boundary) "--$") nil t) + (match-beginning 0) + (point-max) + )) + (rsep (concat "^--" (regexp-quote boundary) "\n")) + (dc-ctl + (cond ((string= ctype "multipart/digest") '("message/rfc822")) + (t '("text/plain")))) + cb ce ct ret ncb children) + (save-restriction + (narrow-to-region beg end) + (goto-char beg) + (re-search-forward rsep nil t) + (setq cb (match-end 0)) + (while (re-search-forward rsep nil t) + (setq ce (match-beginning 0)) + (setq ncb (match-end 0)) + (save-restriction + (narrow-to-region cb ce) + (setq ret (mime/parse-message dc-ctl "7bit")) + ) + (setq children (cons ret children)) + (goto-char (mime::content-info/point-max ret)) + (goto-char (setq cb ncb)) + ) + (setq ce (point-max)) + (save-restriction + (narrow-to-region cb ce) + (setq ret (mime/parse-message dc-ctl "7bit")) + ) + (setq children (cons ret children)) + ) + (mime::content-info/create beg end ctype params encoding + (reverse children)) + )) + +(defun mime/parse-message (&optional ctl encoding) + "Parse current-buffer as a MIME message. [tm-parse.el]" + (setq ctl (or (mime/Content-Type) ctl)) + (setq encoding (or (mime/Content-Transfer-Encoding) encoding)) + (let ((ctype (car ctl)) + (params (cdr ctl)) + ) + (let ((boundary (assoc "boundary" params))) + (cond (boundary + (setq boundary (message/strip-quoted-string (cdr boundary))) + (mime/parse-multipart boundary ctype params encoding) + ) + ((string= ctype "message/rfc822") + (goto-char (point-min)) + (mime::content-info/create (point-min) (point-max) + ctype params encoding + (save-restriction + (narrow-to-region + (if (re-search-forward "^$" nil t) + (+ (match-end 0) 1) + (point-min) + ) + (point-max)) + (list (mime/parse-message)) + ) + ) + ) + (t + (mime::content-info/create (point-min) (point-max) + ctype params encoding nil) + )) + ))) + + +;;; @ end +;;; + +(provide 'tm-parse) diff --git a/tm-play.el b/tm-play.el new file mode 100644 index 0000000..d077b9d --- /dev/null +++ b/tm-play.el @@ -0,0 +1,243 @@ +;;; +;;; tm-play.el --- decoder for tm-view.el +;;; +;;; Copyright (C) 1995 Free Software Foundation, Inc. +;;; Copyright (C) 1994,1995 MORIOKA Tomohiko +;;; +;;; Author: MORIOKA Tomohiko +;;; Version: +;;; $Id: tm-play.el,v 1.2 1995/09/26 11:54:38 morioka Exp $ +;;; Keywords: mail, news, MIME, multimedia +;;; +;;; This file is part of tm (Tools for MIME). +;;; + +(require 'tm-view) + + +;;; @ content decoder +;;; + +(defvar mime-preview/after-decoded-position nil) + +(defun mime-preview/decode-content () + (interactive) + (let ((pc (mime::point-preview-content (point)))) + (if pc + (let ((the-buf (current-buffer))) + (setq mime-preview/after-decoded-position (point)) + (set-buffer (mime::preview-content-info/buffer pc)) + (mime-article/decode-content + (mime::preview-content-info/content-info pc)) + (if (eq (current-buffer) + (mime::preview-content-info/buffer pc)) + (progn + (set-buffer the-buf) + (goto-char mime-preview/after-decoded-position) + )) + )))) + + +(defun mime-article/decode-content (cinfo) + (let ((beg (mime::content-info/point-min cinfo)) + (end (mime::content-info/point-max cinfo)) + (ctype (mime::content-info/type cinfo)) + (params (mime::content-info/parameters cinfo)) + (encoding (mime::content-info/encoding cinfo)) + ) + (if ctype + (let (method cal ret) + (setq cal (append (list (cons 'type ctype) + (cons 'encoding encoding) + (cons 'major-mode major-mode) + ) + params)) + (if mime-viewer/decoding-mode + (setq cal (cons + (cons 'mode mime-viewer/decoding-mode) + cal)) + ) + (setq ret (mime/get-content-decoding-alist cal)) + (setq method (cdr (assoc 'method ret))) + (cond ((and (symbolp method) + (fboundp method)) + (funcall method beg end ret) + ) + ((and (listp method)(stringp (car method))) + (mime-article/start-external-method-region beg end ret) + ) + (t + (mime-article/show-output-buffer + "No method are specified for %s\n" ctype) + )) + )) + )) + +(defun mime/get-content-decoding-alist (al) + (get-unified-alist mime/content-decoding-condition al) + ) + + +;;; @ external decoder +;;; + +(defun mime-article/start-external-method-region (beg end cal) + (save-excursion + (save-restriction + (narrow-to-region beg end) + (goto-char beg) + (let ((method (cdr (assoc 'method cal))) + (name (mime-article/get-name cal)) + ) + (if method + (let ((file (make-temp-name + (expand-file-name "TM" mime/tmp-dir))) + b args) + (if (nth 1 method) + (setq b beg) + (setq b + (if (re-search-forward "^$" nil t) + (1+ (match-end 0)) + (point-min) + )) + ) + (goto-char b) + (write-region b end file) + (setq cal (put-alist + 'name (replace-as-filename name) cal)) + (setq cal (put-alist 'file file cal)) + (setq args (nconc + (list (car method) + mime/output-buffer-name (car method) + ) + (mime-article/make-method-args cal + (cdr (cdr method))) + )) + (apply (function start-process) args) + (mime-article/show-output-buffer) + )) + )))) + +(defun mime-article/make-method-args (cal format) + (mapcar (function + (lambda (arg) + (if (stringp arg) + arg + (let ((ret (cdr (assoc (eval arg) cal)))) + (if ret + ret + "") + )) + )) + format)) + +(defun mime-article/show-output-buffer (&rest forms) + (let ((the-win (selected-window)) + (win (get-buffer-window mime/output-buffer-name)) + ) + (if (null win) + (progn + (setq win (split-window-vertically (/ (* (window-height) 3) 4))) + (set-window-buffer win mime/output-buffer-name) + )) + (select-window win) + (goto-char (point-max)) + (if forms + (insert (apply (function format) forms)) + ) + (select-window the-win) + )) + + +;;; @ file name +;;; + +(defvar mime-viewer/file-name-char-regexp "[A-Za-z0-9+_-]") + +(defvar mime-viewer/file-name-regexp-1 + (concat mime-viewer/file-name-char-regexp "+\\." + mime-viewer/file-name-char-regexp "+")) + +(defvar mime-viewer/file-name-regexp-2 + (concat (regexp-* mime-viewer/file-name-char-regexp) + "\\(\\." mime-viewer/file-name-char-regexp "+\\)*")) + +(defun mime-article/get-name (param) + (let ((str (mime-viewer/get-subject param))) + (if (string-match " " str) + (if (or (string-match mime-viewer/file-name-regexp-1 str) + (string-match mime-viewer/file-name-regexp-2 str)) + (substring str (match-beginning 0)(match-end 0)) + ) + (replace-as-filename str) + ))) + + +;;; @ message/partial +;;; + +(defun mime/decode-message/partial-region (beg end cal) + (goto-char beg) + (let* ((root-dir (expand-file-name + (concat "m-prts-" (user-login-name)) mime/tmp-dir)) + (id (cdr (assoc "id" cal))) + (number (cdr (assoc "number" cal))) + (total (cdr (assoc "total" cal))) + (the-buf (current-buffer)) + file + (mother mime::article/preview-buffer)) + (if (not (file-exists-p root-dir)) + (make-directory root-dir) + ) + (setq id (replace-as-filename id)) + (setq root-dir (concat root-dir "/" id)) + (if (not (file-exists-p root-dir)) + (make-directory root-dir) + ) + (setq file (concat root-dir "/FULL")) + (if (not (file-exists-p file)) + (progn + (re-search-forward "^$") + (goto-char (1+ (match-end 0))) + (setq file (concat root-dir "/" number)) + (write-region (point) (point-max) file) + (if (get-buffer "*MIME-temp*") + (kill-buffer "*MIME-temp*") + ) + (switch-to-buffer "*MIME-temp*") + (let ((i 1) + (max (string-to-int total)) + ) + (catch 'tag + (while (<= i max) + (setq file (concat root-dir "/" (int-to-string i))) + (if (not (file-exists-p file)) + (progn + (switch-to-buffer the-buf) + (throw 'tag nil) + )) + (insert-file-contents file) + (goto-char (point-max)) + (setq i (1+ i)) + ) + (delete-other-windows) + (write-file (concat root-dir "/FULL")) + (setq major-mode 'mime/show-message-mode) + (mime/viewer-mode mother) + (pop-to-buffer (current-buffer)) + )) + ) + (progn + (delete-other-windows) + (find-file file) + (setq major-mode 'mime/show-message-mode) + (mime/viewer-mode mother) + (pop-to-buffer (current-buffer)) + )) + )) + + +;;; @ end +;;; + +(provide 'tm-play) diff --git a/tm-view.el b/tm-view.el index 6c86489..e7d224c 100644 --- a/tm-view.el +++ b/tm-view.el @@ -21,32 +21,19 @@ (require 'mel) (require 'tiny-mime) (require 'tm-def) +(require 'tm-parse) ;;; @ version ;;; (defconst mime-viewer/RCS-ID - "$Id: tm-view.el,v 6.92 1995/09/24 22:25:24 morioka Exp $") + "$Id: tm-view.el,v 7.6 1995/09/26 11:53:46 morioka Exp $") (defconst mime-viewer/version (get-version-string mime-viewer/RCS-ID)) (defconst mime/viewer-version mime-viewer/version) -;;; @ constants -;;; - -(defconst mime/content-type-subtype-regexp - (concat mime/token-regexp "/" mime/token-regexp)) -(defconst mime/content-parameter-value-regexp - (concat "\\(" - message/quoted-string-regexp - "\\|[^; \t\n]*\\)")) - -(defconst mime/output-buffer-name "*MIME-out*") -(defconst mime/decoding-buffer-name "*MIME-decoding*") - - ;;; @ variables ;;; @@ -92,6 +79,7 @@ '("text/plain" "text/richtext" "text/enriched" "text/x-latex" "application/x-latex" "application/octet-stream" nil + "application/pgp" "application/x-selection" "application/x-comment")) (defvar mime-viewer/content-subject-omitting-Content-Type-list @@ -106,18 +94,6 @@ (defvar mime-viewer/ignored-field-regexp) -(defvar mime-viewer/decoding-mode "play" "MIME body decoding mode") - -(defvar mime-viewer/file-name-char-regexp "[A-Za-z0-9+_-]") - -(defvar mime-viewer/file-name-regexp-1 - (concat mime-viewer/file-name-char-regexp "+\\." - mime-viewer/file-name-char-regexp "+")) - -(defvar mime-viewer/file-name-regexp-2 - (concat (regexp-* mime-viewer/file-name-char-regexp) - "\\(\\." mime-viewer/file-name-char-regexp "+\\)*")) - (defvar mime-viewer/announcement-for-message/partial (if (and (>= emacs-major-version 19) window-system) "\ @@ -177,7 +153,7 @@ (if (listp cnum) (mapconcat (function (lambda (num) - (format "%s" (+ num 1)) + (format "%s" (1+ num)) )) cnum ".") "0")) @@ -240,7 +216,8 @@ ;;; (defvar mime-viewer/content-filter-alist - '(("text/plain" . mime-viewer/filter-text/plain) + '(("text/plain" . mime-viewer/filter-text/plain) + ("application/pgp" . mime-viewer/filter-text/plain) (nil . mime-viewer/filter-text/plain))) (defun mime-viewer/default-content-filter (cnum cinfo ctype params subj) @@ -317,198 +294,168 @@ The compressed face will be piped to this command.") ;;; @ data structures ;;; -;;; @@ content-info -;;; -(define-structure mime::content-info - point-min point-max type parameters encoding children) - ;;; @@ preview-content-info ;;; + (define-structure mime::preview-content-info point-min point-max buffer content-info) -;;; @ parser +;;; @ buffer setup ;;; -(defun mime-viewer/parse-message (&optional ctl encoding ibuf obuf) +(defun mime-viewer/setup-buffer (&optional ctl encoding ibuf obuf) (if ibuf - (set-buffer ibuf) - (setq ibuf (current-buffer)) - ) + (progn + (get-buffer ibuf) + (set-buffer ibuf) + )) (make-variable-buffer-local 'mime::article/content-info) - (setq mime::article/content-info (mime-viewer/parse ctl encoding)) - (let ((ret (mime-viewer/make-preview-buffer - ibuf mime::article/content-info obuf))) + (setq mime::article/content-info (mime/parse-message ctl encoding)) + (let ((ret (mime-viewer/make-preview-buffer obuf))) (make-variable-buffer-local 'mime::article/preview-buffer) (setq mime::article/preview-buffer (car ret)) ret)) -(defun mime-viewer/parse (&optional ctl encoding) - (save-excursion - (save-restriction - (setq ctl (or (mime/Content-Type) - ctl)) - (setq encoding (or (mime/Content-Transfer-Encoding) - encoding)) - (let ((ctype (car ctl)) - (params (cdr ctl)) +(defun mime-viewer/make-preview-buffer (&optional obuf) + (let ((cinfo mime::article/content-info) + (the-buf (current-buffer)) + (mode major-mode) + pcl dest) + (or obuf + (setq obuf (concat "*Preview-" (buffer-name the-buf) "*")) + ) + (setq pcl (mime/flatten-content-info cinfo)) + (let ((bf (get-buffer obuf))) + (if bf + (progn + (set-buffer obuf) + (setq buffer-read-only nil) + (erase-buffer) ) - (let ((boundary (assoc "boundary" params))) - (goto-char (point-min)) - (search-forward "\n\n" nil t) - (cond (boundary - (save-excursion - (save-restriction - (setq boundary - (message/strip-quoted-string (cdr boundary))) - (narrow-to-region - (point-min) - (if (re-search-forward - (concat "^--" (regexp-quote boundary) "--$") nil t) - (match-beginning 0) - (point-max) - )) - (mime-viewer/parse-multipart - (point-min) - (point-max) - boundary ctype params encoding) - ))) - ((string= ctype "message/rfc822") - (mime::content-info/create - (point-min) (point-max) - ctype params encoding - (save-excursion - (save-restriction - (narrow-to-region (progn - (goto-char (point-min)) - (if (re-search-forward "^$" nil t) - (+ (match-end 0) 1) - (point-min) - )) - (point-max)) - (list (mime-viewer/parse)) - )) - ) - ) - (t - (mime::content-info/create (point-min) (point-max) - ctype params encoding nil) - )) - ))))) - -(defun mime-viewer/parse-multipart (beg end boundary ctype params encoding) - (let ((sep (concat "^--" (regexp-quote boundary) "$")) - cb ce ct ret ncb children) - (save-excursion - (save-restriction - (narrow-to-region beg end) - (goto-char (point-min)) - (search-forward (concat "--" boundary "\n") nil t) - (setq cb (match-end 0)) - (while (re-search-forward sep nil t) - (setq ce (match-beginning 0)) - (setq ncb (match-end 0)) - (save-excursion - (save-restriction - (narrow-to-region cb ce) - (setq ret (apply (function mime-viewer/parse) - (cond ((string= ctype "multipart/digest") - '(("message/rfc822") "7bit") - ) - (t '(("text/plain") "7bit")) - ) - )) - )) - (setq children (nconc children (list ret))) - (goto-char (mime::content-info/point-max ret)) - (search-forward (concat "--" boundary "\n") nil t) - (goto-char (setq cb (match-end 0))) - ) - (setq ce (point-max)) - (save-excursion - (save-restriction - (narrow-to-region cb ce) - (setq ret (apply (function mime-viewer/parse) - (cond ((string= ctype "multipart/mixed") - '(("text/plain") "7bit") - ) - ((string= ctype "multipart/digest") - '(("message/rfc822") "7bit") - )) - )) - )) - (setq children (nconc children (list ret))) + (setq bf (get-buffer-create obuf)) + (set-buffer obuf) )) - (setq beg (point-min)) - (goto-char beg) - (mime::content-info/create beg end ctype params encoding children) + (make-variable-buffer-local 'mime::preview/article-buffer) + (setq mime::preview/article-buffer the-buf) + (make-variable-buffer-local 'mime::preview/original-major-mode) + (setq mime::preview/original-major-mode mode) + (setq major-mode 'mime/viewer-mode) + (setq mode-name "MIME-View") + (setq dest + (mapcar + (function + (lambda (content) + (mime-viewer/display-content content cinfo the-buf obuf) + )) + pcl)) + (set-buffer-modified-p nil) + (setq buffer-read-only t) + (set-buffer the-buf) + (list obuf dest) )) -(defun mime::parse-parameter (str) - (let ((ret (message::parse "\;" str))) - (if ret - (if (setq ret - (message::parse mime/token-regexp - (message::parsed/rest ret))) - (let ((parameter (downcase (message::parsed/matched ret)))) - (if (setq ret (message::parse "=" (message::parsed/rest ret))) - (if (setq ret - (message::parse - mime/content-parameter-value-regexp - (message::parsed/rest ret))) - (message::make-parsed - (cons parameter - (message/strip-quoted-string - (message::parsed/matched ret)) - ) - (message::parsed/rest ret) - ) - ))))))) - -(defun mime::parse-field-body/Content-Type (str) - (let ((ret (message::parse mime/content-type-subtype-regexp str))) - (if ret - (let ((ctype (downcase (message::parsed/matched ret))) - dest) - (while (progn - (setq str (message::parsed/rest ret)) - (setq ret (mime::parse-parameter str)) - ) - (setq dest (cons (message::parsed/matched ret) dest)) - ) - (if (string-match "^[ \t]*$" str) - (cons ctype (reverse dest)) - ))))) - -(defun mime/Content-Type (&optional port) - "Read field-body of Content-Type field from PORT and parse it. -PORT must be buffer or string. If PORT is omitted, -it is regarded as current-buffer. [tm-view]" - (or port - (setq port (current-buffer)) +(defun mime-viewer/display-content (content cinfo ibuf obuf) + (let* ((beg (mime::content-info/point-min content)) + (end (mime::content-info/point-max content)) + (ctype (mime::content-info/type content)) + (params (mime::content-info/parameters content)) + (encoding (mime::content-info/encoding content)) + (cnum (mime::get-point-content-number beg cinfo)) + he e nb ne subj) + (set-buffer ibuf) + (goto-char beg) + (setq he (if (re-search-forward "^$" nil t) + (1+ (match-end 0)) + end)) + (if (> he end) + (setq he end) ) - (let ((str (if (get-buffer port) - (save-window-excursion - (switch-to-buffer port) - (message/get-field-body "Content-Type") - ) - port) - )) - (if str - (mime::parse-field-body/Content-Type - (message/unfolding-string str)) + (setq subj (mime-viewer/get-subject params encoding)) + (set-buffer obuf) + (setq nb (point)) + (narrow-to-region nb nb) + (funcall mime-viewer/content-subject-function + cnum cinfo ctype params subj) + (set-buffer ibuf) + (if (mime-viewer/header-visible-p cnum cinfo ctype) + (mime-viewer/display-header beg he obuf) + ) + (cond ((mime-viewer/body-visible-p cnum cinfo ctype) + (mime-viewer/display-body he end obuf + cnum cinfo ctype params subj encoding) + ) + ((equal ctype "message/partial") + (mime-viewer/display-message/partial obuf) + ) + ((and (eq cnum t) + (null (mime::content-info/children cinfo)) + ) + (set-buffer obuf) + (mime-viewer/insert-content-subject cnum cinfo ctype params subj) + ) + (t (set-buffer obuf)) + ) + (mime-viewer/default-content-separator cnum cinfo ctype params subj) + (prog1 + (progn + (setq ne (point-max)) + (widen) + (mime::preview-content-info/create nb (1- ne) ibuf content) + ) + (goto-char ne) ))) -(defun mime/Content-Transfer-Encoding (&optional default-encoding) - (let ((str (message/get-field-body "Content-Transfer-Encoding"))) - (if str - (downcase str) - default-encoding) - )) +(defun mime-viewer/display-header (beg end obuf) + (let ((str (buffer-substring beg end)) + (f (assq major-mode mime-viewer/content-header-filter-alist)) + ) + (save-excursion + (set-buffer obuf) + (save-restriction + (narrow-to-region (point)(point)) + (insert str) + (if (and f (setq f (cdr f))) + (funcall f) + (mime-viewer/default-content-header-filter) + ) + (run-hooks 'mime-viewer/content-header-filter-hook) + )))) -(defun mime-viewer/get-subject (param) - (if (member (cdr (assq 'encoding param)) +(defun mime-viewer/display-body (beg end obuf + cnum cinfo ctype params subj encoding) + (let ((str (buffer-substring beg end)) + be) + (set-buffer obuf) + (save-restriction + (setq be (point-max)) + (narrow-to-region be be) + (insert str) + (let ((f (assoc-value ctype mime-viewer/content-filter-alist))) + (if (and f (fboundp f)) + (funcall f ctype params encoding) + (mime-viewer/default-content-filter cnum cinfo ctype params subj) + )) + ))) + +(defun mime-viewer/display-message/partial (obuf) + (set-buffer obuf) + (save-restriction + (goto-char (point-max)) + (if (not (search-backward "\n\n" nil t)) + (insert "\n") + ) + (let ((be (point-max))) + (narrow-to-region be be) + (insert mime-viewer/announcement-for-message/partial) + (tm:add-button (point-min)(point-max) + (function mime-viewer/play-content)) + ))) + +(defun mime-viewer/get-subject (param &optional encoding) + (if (member (or encoding + (cdr (assq 'encoding param)) + ) mime-viewer/uuencode-encoding-name-list) (save-excursion (or (if (re-search-forward "^begin [0-9]+ " nil t) @@ -526,6 +473,7 @@ it is regarded as current-buffer. [tm-view]" (save-excursion (save-restriction + (goto-char (point-min)) (narrow-to-region (point-min) (or (and (search-forward "\n\n" nil t) (match-beginning 0) @@ -538,169 +486,7 @@ it is regarded as current-buffer. [tm-view]" "")) )) -(defun mime-viewer/get-name (param) - (let ((str (mime-viewer/get-subject param))) - (if (string-match " " str) - (if (or (string-match mime-viewer/file-name-regexp-1 str) - (string-match mime-viewer/file-name-regexp-2 str)) - (substring str (match-beginning 0)(match-end 0)) - ) - (replace-as-filename str) - ))) - -(defun mime-viewer/make-preview-buffer (&optional buf cinfo obuf) - (let ((the-buf (current-buffer)) - (mode major-mode) - pcl dest) - (setq buf - (if (null buf) - (current-buffer) - (prog1 - (get-buffer buf) - (switch-to-buffer buf) - ))) - (or cinfo - (setq cinfo mime::article/content-info) - ) - (or obuf - (setq obuf (concat "*Preview-" (buffer-name buf) "*")) - ) - (setq pcl (mime::make-flat-content-list cinfo)) - (let ((bf (get-buffer obuf))) - (switch-to-buffer obuf) - (setq buffer-read-only nil) - (if bf - (erase-buffer) - )) - (make-variable-buffer-local 'mime::preview/article-buffer) - (setq mime::preview/article-buffer the-buf) - (make-variable-buffer-local 'mime::preview/original-major-mode) - (setq mime::preview/original-major-mode mode) - (setq major-mode 'mime/viewer-mode) - (setq mode-name "MIME-View") - (setq dest - (mapcar - (function - (lambda (cell) - (let ((beg (mime::content-info/point-min cell)) - (end (mime::content-info/point-max cell)) - (ctype (mime::content-info/type cell)) - (params (mime::content-info/parameters cell)) - (encoding (mime::content-info/encoding cell)) - he cnum e nb ne subj str) - (setq cnum (mime::get-point-content-number beg cinfo)) - (switch-to-buffer the-buf) - (setq he (save-excursion - (goto-char beg) - (re-search-forward "^$" nil t) - (+ (match-end 0) 1) - )) - (if (> he (point-max)) - (setq he (point-max)) - ) - (save-excursion - (save-restriction - (narrow-to-region beg he) - (setq subj (mime-viewer/get-subject params)) - )) - (switch-to-buffer obuf) - (setq nb (point)) - (narrow-to-region nb nb) - (switch-to-buffer the-buf) - (if (mime-viewer/header-visible-p cnum cinfo ctype) - (progn - (setq str (buffer-substring beg he)) - (switch-to-buffer obuf) - (insert str) - (let ((f (assq - mode - mime-viewer/content-header-filter-alist)) - ) - (if (and f (setq f (cdr f))) - (funcall f) - (mime-viewer/default-content-header-filter) - )) - (run-hooks 'mime-viewer/content-header-filter-hook) - (switch-to-buffer the-buf) - )) - (cond ((mime-viewer/body-visible-p cnum cinfo ctype) - (let (be) - (setq str (buffer-substring he end)) - (switch-to-buffer obuf) - (save-restriction - (setq be (point-max)) - (narrow-to-region be be) - (insert str) - (setq ne (point-max)) - (let ((f (or (assoc-value - ctype - mime-viewer/content-filter-alist) - ))) - (if (and f (fboundp f)) - (funcall f ctype params encoding) - (mime-viewer/default-content-filter - cnum cinfo ctype params subj) - )) - (setq ne (point-max)) - ) - (switch-to-buffer the-buf) - )) - ((equal ctype "message/partial") - (let (be) - (switch-to-buffer obuf) - (save-restriction - (goto-char (point-max)) - (if (not (search-backward "\n\n" nil t)) - (insert "\n") - ) - (setq be (point-max)) - (narrow-to-region be be) - (insert - mime-viewer/announcement-for-message/partial) - (tm:add-button (point-min)(point-max) - (function mime-viewer/play-content)) - (setq ne (point-max)) - ) - (switch-to-buffer the-buf) - )) - ((and (eq cnum t) - (null (mime::content-info/children cinfo)) - ) - (let (be) - (switch-to-buffer obuf) - (save-restriction - (setq be (point-max)) - (narrow-to-region be be) - (mime-viewer/insert-content-subject - cnum cinfo ctype params subj) - (setq ne (point-max)) - ) - (switch-to-buffer the-buf) - )) - ) - (switch-to-buffer obuf) - (mime-viewer/default-content-separator - cnum cinfo ctype params subj) - (prog1 - (progn - (goto-char nb) - (funcall mime-viewer/content-subject-function - cnum cinfo ctype params subj) - (setq ne (point-max)) - (widen) - (mime::preview-content-info/create nb (- ne 1) - buf cell) - ) - (goto-char ne) - )))) - pcl)) - (set-buffer-modified-p nil) - (setq buffer-read-only t) - (switch-to-buffer the-buf) - (list obuf dest) - )) - - + ;;; @ content information ;;; @@ -722,7 +508,7 @@ it is regarded as current-buffer. [tm-view]" (ret (throw 'tag (cons sn ret))) ) (setq c (cdr c)) - (setq sn (+ sn 1)) + (setq sn (1+ sn)) ))) t)))) @@ -741,7 +527,7 @@ it is regarded as current-buffer. [tm-view]" )) )))) -(defun mime::make-flat-content-list (&optional cinfo) +(defun mime/flatten-content-info (&optional cinfo) (or cinfo (setq cinfo mime::article/content-info) ) @@ -749,7 +535,7 @@ it is regarded as current-buffer. [tm-view]" (rcl (mime::content-info/children cinfo)) ) (while rcl - (setq dest (nconc dest (mime::make-flat-content-list (car rcl)))) + (setq dest (nconc dest (mime/flatten-content-info (car rcl)))) (setq rcl (cdr rcl)) ) dest)) @@ -773,170 +559,6 @@ it is regarded as current-buffer. [tm-view]" )) -;;; @ decoder -;;; - -(defun mime/make-method-args (cal format) - (mapcar (function - (lambda (arg) - (if (stringp arg) - arg - (let ((ret (cdr (assoc (eval arg) cal)))) - (if ret - ret - "") - )) - )) - format)) - -(defun mime/start-external-method-region (beg end cal) - (save-excursion - (save-restriction - (narrow-to-region beg end) - (goto-char beg) - (let ((method (cdr (assoc 'method cal))) - (name (mime-viewer/get-name cal)) - ) - (if method - (let ((file (make-temp-name - (expand-file-name "TM" mime/tmp-dir))) - b args) - (if (nth 1 method) - (setq b beg) - (setq b - (if (re-search-forward "^$" nil t) - (+ (match-end 0) 1) - (point-min) - )) - ) - (goto-char b) - (write-region b end file) - (setq cal (put-alist - 'name (replace-as-filename name) cal)) - (setq cal (put-alist 'file file cal)) - (setq args (nconc - (list (car method) - mime/output-buffer-name (car method) - ) - (mime/make-method-args cal (cdr (cdr method))) - )) - (apply (function start-process) args) - (mime/show-output-buffer) - )) - )))) - -(defun mime/decode-message/partial-region (beg end cal) - (goto-char beg) - (let* ((root-dir (expand-file-name - (concat "m-prts-" (user-login-name)) mime/tmp-dir)) - (id (cdr (assoc "id" cal))) - (number (cdr (assoc "number" cal))) - (total (cdr (assoc "total" cal))) - (the-buf (current-buffer)) - file - (mother mime::article/preview-buffer)) - (if (not (file-exists-p root-dir)) - (make-directory root-dir) - ) - (setq id (replace-as-filename id)) - (setq root-dir (concat root-dir "/" id)) - (if (not (file-exists-p root-dir)) - (make-directory root-dir) - ) - (setq file (concat root-dir "/FULL")) - (if (not (file-exists-p file)) - (progn - (re-search-forward "^$") - (goto-char (+ (match-end 0) 1)) - (setq file (concat root-dir "/" number)) - (write-region (point) (point-max) file) - (if (get-buffer "*MIME-temp*") - (kill-buffer "*MIME-temp*") - ) - (switch-to-buffer "*MIME-temp*") - (let ((i 1) - (max (string-to-int total)) - ) - (catch 'tag - (while (<= i max) - (setq file (concat root-dir "/" (int-to-string i))) - (if (not (file-exists-p file)) - (progn - (switch-to-buffer the-buf) - (throw 'tag nil) - )) - (insert-file-contents file) - (goto-char (point-max)) - (setq i (+ i 1)) - ) - (delete-other-windows) - (write-file (concat root-dir "/FULL")) - (setq major-mode 'mime/show-message-mode) - (mime/viewer-mode mother) - (pop-to-buffer (current-buffer)) - )) - ) - (progn - (delete-other-windows) - (find-file file) - (setq major-mode 'mime/show-message-mode) - (mime/viewer-mode mother) - (pop-to-buffer (current-buffer)) - )) - )) - -(defun mime/get-content-decoding-alist (al) - (get-unified-alist mime/content-decoding-condition al) - ) - -(defun mime::article/decode-content-region (cinfo) - (let ((beg (mime::content-info/point-min cinfo)) - (end (mime::content-info/point-max cinfo)) - (ctype (mime::content-info/type cinfo)) - (params (mime::content-info/parameters cinfo)) - (encoding (mime::content-info/encoding cinfo)) - ) - (if ctype - (let (method cal ret) - (setq cal (append (list (cons 'type ctype) - (cons 'encoding encoding) - (cons 'major-mode major-mode) - ) - params)) - (if mime-viewer/decoding-mode - (setq cal (cons - (cons 'mode mime-viewer/decoding-mode) - cal)) - ) - (setq ret (mime/get-content-decoding-alist cal)) - (setq method (cdr (assoc 'method ret))) - (cond ((and (symbolp method) - (fboundp method)) - (funcall method beg end ret) - ) - ((and (listp method)(stringp (car method))) - (mime/start-external-method-region beg end ret) - ) - (t (mime/show-output-buffer - "No method are specified for %s\n" ctype) - )) - )) - )) - -(defun mime/show-output-buffer (&rest forms) - (let ((the-buf (current-buffer))) - (if (null (get-buffer-window mime/output-buffer-name)) - (split-window-vertically (/ (* (window-height) 3) 4)) - ) - (pop-to-buffer mime/output-buffer-name) - (goto-char (point-max)) - (if forms - (insert (apply (function format) forms)) - ) - (pop-to-buffer the-buf) - )) - - ;;; @ content filter ;;; @@ -1060,17 +682,13 @@ listed in key order: (mapconcat (function regexp-quote) mime-viewer/ignored-field-list "\\|") "\\):")) - (if (null ibuf) - (setq ibuf (current-buffer)) - ) (let ((buf (get-buffer mime/output-buffer-name))) (if buf - (progn + (save-excursion (set-buffer buf) (erase-buffer) - (set-buffer ibuf) ))) - (let ((ret (mime-viewer/parse-message ctl encoding ibuf obuf))) + (let ((ret (mime-viewer/setup-buffer ctl encoding ibuf obuf))) (prog1 (switch-to-buffer (car ret)) (if mother @@ -1119,24 +737,9 @@ listed in key order: (setq rpcl (cdr rpcl)) )))) -(defvar mime-preview/after-decoded-position nil) +(autoload 'mime-preview/decode-content "tm-play") -(defun mime-preview/decode-content () - (interactive) - (let ((pc (mime::point-preview-content (point)))) - (if pc - (let ((the-buf (current-buffer))) - (setq mime-preview/after-decoded-position (point)) - (switch-to-buffer (mime::preview-content-info/buffer pc)) - (mime::article/decode-content-region - (mime::preview-content-info/content-info pc)) - (if (eq (current-buffer) - (mime::preview-content-info/buffer pc)) - (progn - (switch-to-buffer the-buf) - (goto-char mime-preview/after-decoded-position) - )) - )))) +(defvar mime-viewer/decoding-mode "play" "MIME body decoding mode") (defun mime-viewer/play-content () (interactive) diff --git a/tm-vm.el b/tm-vm.el index 9649c1d..f7ba9a1 100644 --- a/tm-vm.el +++ b/tm-vm.el @@ -15,7 +15,7 @@ (require 'vm) (defconst tm-vm/RCS-ID - "$Id: tm-vm.el,v 6.1 1995/05/16 12:33:21 morioka Exp $") + "$Id: tm-vm.el,v 6.3 1995/09/26 00:15:07 morioka Exp $") (defconst tm-vm/version (get-version-string tm-vm/RCS-ID)) (define-key vm-mode-map "Z" 'tm-vm/view-message) @@ -74,9 +74,9 @@ This function is called by `mime-viewer/quit' command via (narrow-to-region (vm-start-of mp) (point-max))) (select-window (vm-get-buffer-window (current-buffer))) (mime/viewer-mode nil - (mime::parse-field-body/Content-Type - (message/unfolding-string (or ct ""))) - cte)))) + (mime/parse-Content-Type (or ct "")) + cte) + ))) (defun tm-vm/decode-message-header (&optional count) "Decode MIME header of current message through tiny-mime. -- 1.7.10.4