tm 6.8
authormorioka <morioka>
Mon, 2 Mar 1998 14:14:24 +0000 (14:14 +0000)
committermorioka <morioka>
Mon, 2 Mar 1998 14:14:24 +0000 (14:14 +0000)
13 files changed:
Makefile
Makefile.bc
README.eng
decode-b.c
gnus/Makefile
gnus/tm-gnus3.el
methods/tmdecode
rel-6eng.ol [new file with mode: 0644]
rel-6jp.ol [new file with mode: 0644]
tm-partial.el
tm-rich.el
tm-view.el
tm-vm.el

index 334d0a3..9c99c6b 100644 (file)
--- a/Makefile
+++ b/Makefile
 #      TMDIR18 = for Emacs 18.* (NEMACS, NEpoch or MULE 1)
 #      TMDIR19 = for Emacs 19.* (FSF original, XEmacs or MULE 2)
 
-       TMDIR18 = /usr/local/lib/emacs/local.lisp/tm
-       TMDIR19 = /usr/local/lib/mule/site-lisp
+       # TMDIR18 = /usr/local/lib/emacs/local.lisp/tm
+       # TMDIR19 = /usr/local/lib/mule/site-lisp
+       TMDIR18 = $(HOME)/lib/emacs18/lisp
+       TMDIR19 = $(HOME)/lib/emacs19/lisp
 
        TLSRCDIR = ../tl
 
@@ -29,14 +31,14 @@ CFLAGS      = -O
 
 UTILS  = ol2 decode-b
 GOMI   = $(UTILS) *.elc
-FILES  = tm/README.eng tm/Makefile tm/Makefile.bc \
+FILES  = tm/README.eng tm/rel-*.ol tm/Makefile tm/Makefile.bc \
        tm/*.el tm/*.c tm/methods \
        tm/doc/Makefile tm/doc/*.pln tm/doc/*.ol tm/doc/*.tex tm/doc/*.texi \
        tm/gnus/Makefile tm/gnus/Makefile.bc tm/gnus/*.el \
        tm/mh-e/Makefile tm/mh-e/Makefile.bc tm/mh-e/*.el \
        tl/README.eng tl/Makefile tl/Makefile.bc tl/*.el tl/doc/*.texi
 
-TARFILE = tm5.21.8.tar
+TARFILE = tm6.08.tar
 
 
 nemacs:
index de6699f..5b9b2c1 100644 (file)
@@ -1,5 +1,5 @@
 #
-# $Id: Makefile.bc,v 1.4 1995/01/31 10:44:26 morioka Exp $
+# $Id: Makefile.bc,v 1.4 1995/01/31 10:44:26 morioka Exp morioka $
 #
 
 TMMEL  = tm-view.el tm-rmail.el tm-comp.el
@@ -8,7 +8,9 @@ TMMELC  = ${TMMEL:el=elc}
 TM_EL  = signature.el \
        tiny-mime.el tm-misc.el tm-$(EMACS_TYPE).el $(TMMEL) tm-rich.el
 TM_ELC = ${TM_EL:el=elc}
-ALL_EL = $(TM_EL) tm-setup.el mime-setup.el
+ALL_EL = $(TM_EL) tm-ftp.el tm-latex.el tm-partial.el \
+       tm-vm.el \
+       tm-setup.el mime-setup.el
 
 .SUFFIXES:     .el .elc
 
index 9c001b8..f40f3e8 100644 (file)
@@ -1,6 +1,6 @@
 [README for tm (English Version)]
 by MORIOKA Tomohiko <morioka@jaist.ac.jp>
-$Id: README.eng,v 1.1 1995/01/12 17:23:45 morioka Exp $
+$Id: README.eng,v 1.2 1995/02/09 15:47:58 morioka Exp $
 
 1 What's tm?
 
@@ -8,7 +8,7 @@ Tm is a MIME package for GNU Emacs. Tm has following functions:
 
        - MIME style multilingual header
        - MIME message viewer (mime/viewer-mode)
-       - MIME extenders for mh-e, GNUS and RMAIL
+       - MIME extenders for mh-e, GNUS, RMAIL and vm
 
 
 2 Documents
index 2bf63ea..8eece33 100644 (file)
@@ -1,5 +1,9 @@
 /*
- * $Id: decode-b.c,v 1.1 1994/07/22 06:22:43 morioka Exp morioka $
+ * $Id: decode-b.c,v 1.2 1995/02/04 02:51:53 morioka Exp $
+ *
+ * modified by Kenji Rikitake <kenji@reseau.toyonaka.osaka.jp>
+ *     based on Henry Spencer's un64 shell script
+ * 
  */
 
 #include <stdio.h>
@@ -32,33 +36,36 @@ main()
     char  str[128];
     char* sp;
     int   ret;
-    unsigned long int value;
-    unsigned char* buf = (void*)&value;
+    unsigned int   v1, v2, v3, v4, o1, o2, o3;
     
-    while(fgets(str, 128, rfp)){
-       for(sp = str; *sp; ){
-           if( (*sp == '\r') || (*sp == '\n') ) break;
-           value  = get_base64_char_value(*sp++) * 64 * 64 * 64;
-           ret = get_base64_char_value(*sp++);
-           value += ret * 64 * 64;
-           ret = get_base64_char_value(*sp++);
-           if(ret >= 0){
-               value += ret * 64;
-               ret = get_base64_char_value(*sp++);
-               if(ret >= 0){
-                   value += ret;
-                   fwrite(&buf[1], 1, 3, wfp);
-               }
-               else{
-                   fwrite(&buf[1], 1, 2, wfp);
+    while (fgets(str, 128, rfp)) {
+       for (sp = str; *sp; ) {
+           if ((*sp == '\r') || (*sp == '\n')) break;
+           v1 = get_base64_char_value(*sp++);
+           v2 = get_base64_char_value(*sp++);
+           if (0 <= (v3 = get_base64_char_value(*sp++))) {
+               if (0 <= (v4 = get_base64_char_value(*sp++))) {
+                   o1 = (v1 << 2) + (v2 >> 4);
+                   o2 = ((v2 & 0x0f) << 4) + (v3 >> 2);
+                   o3 = ((v3 & 0x03) << 6) + v4;
+                   putc(o1, wfp);
+                   putc(o2, wfp);
+                   putc(o3, wfp);
+                   }
+               else {
+                   o1 = (v1 << 2) + (v2 >> 4);
+                   o2 = ((v2 & 0x0f) << 4) + (v3 >> 2);
+                   putc(o1, wfp);
+                   putc(o2, wfp);
                    return 0;
+                   }
                }
-           }
-           else{
-               fwrite(&buf[1], 1, 1, wfp);
+           else {
+               o1 = (v1 << 2) + (v2 >> 4);
+               putc(o1, wfp);
                return 0;
+               }
            }
-       }
-    }
+        }
     return 0;
 }
index c20085b..e847c7e 100644 (file)
@@ -1,5 +1,5 @@
 #
-# $Id: Makefile,v 1.4 1995/01/13 20:50:22 morioka Exp $
+# $Id: Makefile,v 1.4 1995/01/13 20:50:22 morioka Exp morioka $
 #
 
 # Please specify emacs executables:
 #      TMDIR18 = for Emacs 18.* (NEMACS, NEpoch or MULE 1)
 #      TMDIR19 = for Emacs 19.* (FSF original, XEmacs or MULE 2)
 
-       TMDIR18 = /usr/local/lib/emacs/local.lisp/tm
-       TMDIR19 = /usr/local/lib/mule/site-lisp
+#      TMDIR18 = /usr/local/lib/emacs/local.lisp/tm
+#      TMDIR19 = /usr/local/lib/mule/site-lisp
+       TMDIR18 = $(HOME)/lib/emacs18/lisp
+       TMDIR19 = $(HOME)/lib/emacs19/lisp
 
        TMSRCDIR = ..
        TLSRCDIR = ../../tl
index cc3db7c..d820b41 100644 (file)
@@ -1,5 +1,5 @@
 ;;;
-;;; $Id: tm-gnus3.el,v 5.5 1995/01/13 20:46:48 morioka Exp $
+;;; $Id: tm-gnus3.el,v 6.0 1995/03/11 22:51:37 morioka Exp $
 ;;;
 
 (provide 'tm-gnus3)
@@ -7,22 +7,21 @@
 (require 'tm-view)
 (require 'tl-list)
 
-(setq mime/go-to-top-node-method-alist
-      (put-alist 'gnus-Article-mode
-                (if (string-match (regexp-quote "3.14.4") gnus-version)
-                    (function
-                     (lambda ()
-                       (mime/exit-view-mode)
-                       (delete-other-windows)
-                       (gnus-Article-show-summary)
-                       ))
-                  (function
-                   (lambda ()
-                     (mime/exit-view-mode)
-                     (delete-other-windows)
-                     (gnus-Article-show-subjects)
-                     )))
-                mime/go-to-top-node-method-alist))
+(set-alist 'mime-viewer/quitting-method-alist
+          'gnus-Article-mode
+          (if (string-match (regexp-quote "3.14.4") gnus-version)
+              (function
+               (lambda ()
+                 (mime-viewer/kill-buffer)
+                 (delete-other-windows)
+                 (gnus-Article-show-summary)
+                 ))
+            (function
+             (lambda ()
+               (mime-viewer/kill-buffer)
+               (delete-other-windows)
+               (gnus-Article-show-subjects)
+               ))))
 
 (defun tm-gnus/view-message (arg)
   "MIME decode and play this message."
index b09d8ae..b3cf43a 100755 (executable)
@@ -7,8 +7,8 @@ case "binary":
        /bin/cp $2 $3
        breaksw
 case "base64":
-       #decode-b < $2 > $3
-       mmencode -u $2 > $3
+       decode-b < $2 > $3
+       #mmencode -u $2 > $3
        breaksw
 case "quoted-printable":
        mmencode -q -u $2 > $3
diff --git a/rel-6eng.ol b/rel-6eng.ol
new file mode 100644 (file)
index 0000000..448292a
--- /dev/null
@@ -0,0 +1,129 @@
+* changed points of tm-view
+
+  Internal structure of tm-view 6.* is changed from tm-view 5.21, such 
+as, data structures, symbol names. I write main differences between tm 
+5.21.
+
+** internal structure
+
+*** content-info
+
+  Buffer local variable of article buffer `mime/content-list', which
+memorizes content structres of message in article buffer, is renamed
+to `mime::article/content-info', and data structure is changed.
+
+  Old data structure ``content-list'' used in buffer local variable
+`mime/content-list' was a following list:
+
+       content-list = (Ba Ea children)
+
+               Ba: point-min of this content in article buffer
+               Ea: point-max of this content in article buffer
+               children: content-list's list of contents included in
+                         this content. nil when this content is not
+                         multipart
+
+
+  New data structure ``content-info'' used in buffer local variable
+`mime::article/content-info' is following vector:
+
+       content-info
+        = [point-min point-max type parameters encoding children]
+
+               point-min:  point-min of this content in article buffer
+               point-max:  point-max of this content in article buffer
+                           (This value is not equal Ea.
+                            point-max = Ea + 1)
+               type:       content-type/subtype of this content
+               parameters: assoc-list which represents parameters of
+                           Content-Type field of this content
+               encoding:   Content-Transfer-Encoding of this content
+               children:   content-info's list of contents included
+                           in this content. nil when this content is
+                           not multipart
+
+
+  In tm-view 5.21, this data structure was generated and referenced by
+list processing functions (basic lisp functions) dynamically. In
+tm-view 6.*, however, it is generated by generator function
+`mime::make-content-info', and it is referenced by reference functions
+mime::content-info/FOO (FOO = { point-min | point-max | type |
+parameters | encoding | children }).
+
+
+*** preview-content-info
+
+  Buffer local variable of preview buffer
+`mime/preview-flat-content-list', which memorizes content structres of
+message in preview buffer, is renamed to `mime::preview/content-list,
+and data structure is changed.
+
+  Old data structure used in buffer local variable
+`mime/preview-flat-content-list' was a list which elements are
+following list:
+
+       (Bp Ep buf Ba Ea)
+
+               Bp: point-min of this content in preview buffer
+               Ep: point-max of this content in preview buffer
+               buf: article buffer for this content
+               Ba: point-min of this content in article buffer
+               Ea: point-max of this content in article buffer
+
+
+  New data structure ``preview-content-info'' used in buffer local
+variable `mime::preview/content-list'' is a list which elements are
+following vector:
+
+       [Bp Ep buf cinfo]
+
+               Bp: point-min of this content in preview buffer
+               Ep: point-max of this content in preview buffer
+               buf: article buffer for this content
+               cinfo: content-info which represents this content
+
+
+  In tm-view 5.21, this data structure was generated and referenced by
+list processing functions (basic lisp functions) dynamically. In
+tm-view 6.*, however, it is generated by generator function
+`mime::make-preview-content-info', and it is referenced by reference
+functions mime::preview-content-info/FOO (FOO = { Bp | Ep | buf |
+cinfo }).
+
+
+*** etc
+
+- parser is changed
+
+- naming rule is changed
+
+- buffer local variable in article buffer `mime/preview-buffer' is
+  renamed to `mime::article/preview-buffer'
+
+- function `mime/exit-view-mode' is renamed to `mime-viewer/kill-buffer'
+
+- command functions of mime/viewer-mode are renamed from mime/FOO to
+  mime-viewer/FOO. (ex. `mime/up-content' --> `mime-viewer/up-content')
+
+- command function `mime/quit-view-mode' is renamed to `mime-viewer/quit'
+
+- etc...
+
+
+** variables
+
+(1) variable `mime/content-filter-alist' is renamed to
+    `mime-viewer/content-filter-alist'
+
+(2) variable `mime/make-content-subject-function' is renamed to
+    `mime-viewer/content-subject-function' and arguments are changed
+
+(3) variable `mime/make-content-header-filter' is renamed to
+    `mime-viewer/content-header-filter-function'
+
+(4) variable `mime/default-showing-Content-Type-list' is renamed to
+    `mime-viewer/default-showing-Content-Type-list'
+
+(5) variable `mime/go-to-top-node-method-alist' is renamed to
+    `mime-viewer/quitting-method-alist' and changed initial value
+    because of changes between tm-view 5.21 and tm-view 6.*.
diff --git a/rel-6jp.ol b/rel-6jp.ol
new file mode 100644 (file)
index 0000000..1a005de
--- /dev/null
@@ -0,0 +1,124 @@
+* tm-view \e$B$NJQ99E@$K$D$$$F\e(B
+
+  tm-view 6.* \e$B$G$OFbIt9=B$$,JQ99$5$l!"%G!<%?9=B$$d\e(B symbol \e$BL>$J$I$,JQ99\e(B
+\e$B$5$l$F$$$^$9!#0J2<$G$O!"\e(Btm-view 5.21 \e$B$+$i$N<g$JJQ99E@$r5s$2$^$9!#\e(B
+
+** \e$BFbIt9=B$$NJQ99\e(B
+
+*** content-info
+
+  article buffer \e$B$K$*$$$F!"\e(Bmessage \e$B$K4^$^$l$k\e(B content \e$B$N9=B$$r5-21$9$k\e(B 
+buffer local \e$BJQ?t\e(B mime/content-list \e$B$r\e(B mime::article/content-info \e$B$K2~\e(B
+\e$BL>$7!"%G!<%?9=B$$rJQ99$7$?!#6qBNE*$K$O!"=>Mh!"\e(B
+
+       content-list = (Ba Ea Children)
+
+       \e$BC"$7!"\e(B
+               Ba: article buffer \e$B$G$N$3$N\e(B content \e$B$N@hF,\e(B point
+               Ea: article buffer \e$B$G$N$3$N\e(B content \e$B$NKvHx\e(B point
+               Children: \e$B$3$N\e(B content \e$B$K4^$^$l$k\e(B content \e$B$N>pJs!#\e(B
+                         content-list \e$B$rMWAG$H$9$k\e(B list \e$B$GI=$7!"\e(B
+                         multipart \e$B$N\e(B content \e$B$G$J$$>l9g$O\e(B nil \e$B$,F~$k\e(B
+
+\e$B$H$$$&\e(B list \e$B$GI=8=$7$F$$$?$N$r!"\e(B
+
+       content-info
+        = [point-min point-max type parameters encoding children]
+
+       \e$BC"$7!"\e(B
+               point-min: article buffer \e$B$G$N$3$N\e(B content \e$B$N@hF,\e(B 
+                          point
+               point-max: article buffer \e$B$G$N$3$N\e(B content \e$B$NKvHx\e(B 
+                          point\e$B!J\e(BEa \e$B$H$O0[$J$j!"\e(Bpoint-min \e$B$H\e(B 
+                          point-max \e$B$G:n$i$l$k\e(B region \e$B$,$=$N\e(B content 
+                          \e$B$K$J$k$h$&$K$J$C$F$$$k!#\e(Bpoint-max = Ea + 1 
+                          \e$B$N4X78$,@.$jN)$D!K\e(B
+               type:       \e$B$3$N\e(B content \e$B$N\e(B content-type/subtype
+               parameters: \e$B$3$N\e(B content \e$B$N\e(B Content-Type field \e$B$N\e(B 
+                           paraeter \e$B$rI=$9O"A[%j%9%H\e(B
+               encoding:   \e$B$3$N\e(B content \e$B$N\e(B Content-Transfer-Encoding.
+               children: \e$B$3$N\e(B content \e$B$K4^$^$l$k\e(B content \e$B$N>pJs!#\e(B
+                         content-info \e$B$rMWAG$H$9$k\e(B list \e$B$GI=$7!"\e(B
+                         multipart \e$B$N\e(B content \e$B$G$J$$>l9g$O\e(B nil \e$B$,F~$k\e(B
+
+\e$B$H$$$&\e(B vector \e$B$GI=8=$9$k$h$&$K$7$?!#\e(B
+
+  \e$B$^$?!"=>Mh!"\e(Blist \e$B=hM}4X?t$r;H$C$FD>@\\e(B list \e$B$r@8@.!&;2>H$7$F$$$?$N$r!"\e(B
+\e$B@8@.4X?t\e(B mime::make-content-info, \e$B;2>H4X?t\e(B mime::content-info/FOO (FOO
+= {point-min|point-max|type|parameters|encoding|children}) \e$B$r;H$&$h$&\e(B
+\e$B$K$7$?!#\e(B
+
+  \e$B$^$?!"=>Mh!"\e(BContent-Type, Content-Transfer-Encoding field \e$B$N>pJs$r$$\e(B
+\e$B$A$$$A\e(B buffer \e$B$r8!:w$7$F5a$a$F$$$?$N$r!"\e(Bcontent-info \e$B$r;2>H$9$k$h$&$K\e(B
+\e$B$7$?!#\e(B
+
+*** preview-content-info
+
+  preview buffer \e$B$K$*$$$F!"\e(Bmessage \e$B$K4^$^$l$k\e(B content \e$B$N9=B$$r5-21$9$k\e(B 
+buffer local \e$BJQ?t\e(B mime/preview-flat-content-list \e$B$r\e(B
+mime::preview/content-list \e$B$K2~L>$7!"%G!<%?9=B$$rJQ99$7$?!#6qBNE*$K$O!"\e(B
+\e$B=>Mh!"\e(B
+
+       (Bp Ep buf Ba Ea)
+
+       \e$BC"$7!"\e(B
+               Bp: preview buffer \e$B$G$N$3$N\e(B content \e$B$N@hF,\e(B point
+               Ep: preview buffer \e$B$G$N$3$N\e(B content \e$B$NKvHx\e(B point
+               buf: \e$B$3$N\e(B content \e$B$KBP1~$9$k\e(B article buffer
+               Ba: article buffer \e$B$G$N$3$N\e(B content \e$B$N@hF,\e(B point
+               Ea: article buffer \e$B$G$N$3$N\e(B content \e$B$NKvHx\e(B point
+
+\e$B$H$$$&\e(B list \e$B$GI=8=$7$F$$$?$N$r!"\e(B
+
+       [Bp Ep buf cinfo]
+
+       \e$BC"$7!"\e(B
+               Bp: preview buffer \e$B$G$N$3$N\e(B content \e$B$N@hF,\e(B point
+               Ep: preview buffer \e$B$G$N$3$N\e(B content \e$B$NKvHx\e(B point
+               buf: \e$B$3$N\e(B content \e$B$KBP1~$9$k\e(B article buffer
+               cinfo: \e$B$3$N\e(B content \e$B$rI=$9\e(B content-info
+
+\e$B$H$$$&\e(B vector \e$B$GI=8=$9$k$h$&$K$7$?!#\e(B
+
+  \e$B$^$?!"=>Mh!"\e(Blist \e$B=hM}4X?t$r;H$C$FD>@\\e(B list \e$B$r@8@.!&;2>H$7$F$$$?$N$r!"\e(B
+\e$B@8@.4X?t\e(B mime::make-preview-content-info, \e$B;2>H4X?t\e(B 
+mime::preview-content-info/FOO (FOO = {Bp|Ep|buf|cinfo}) \e$B$r;H$&$h$&$K\e(B
+\e$B$7$?!#\e(B
+
+
+*** \e$B$=$NB>\e(B
+
+\e$B!&\e(Bparser \e$B$rJQ99$7$?\e(B
+
+\e$B!&L?L>5,B'$rJQ99$7$?\e(B
+
+\e$B!&\e(Barticle buffer \e$B$N\e(B buffer local \e$BJQ?t\e(B mime/preview-buffer \e$B$r\e(B 
+  mime::article/preview-buffer \e$B$K2~L>$7$?!#\e(B
+
+\e$B!&4X?t\e(B mime/exit-view-mode \e$B$r\e(B mime-viewer/kill-buffer \e$B$K2~L>$7$?!#\e(B
+
+\e$B!&\e(Bmime/viewer-mode \e$B$N3F4X?t$r\e(B mime/FOO \e$B$+$i\e(B mime-viewer/FOO \e$B$K2~L>$7$?!#\e(B
+  \e$B!JNc!'\e(Bmime/up-content \e$B"*\e(B mime-viewer/up-content\e$B!K\e(B
+
+\e$B!&4X?t\e(B mime/quit-view-mode \e$B$r\e(B mime-viewer/quit \e$B$K2~L>$7$?!#\e(B
+
+\e$B!&$=$NB>\e(B
+
+
+** \e$B<g$JJQ?tL>$NJQ99\e(B
+
+(1) \e$BJQ?t\e(B mime/content-filter-alist \e$B$r\e(B mime-viewer/content-filter-alist
+    \e$B$K2~L>$7$?!#\e(B
+
+(2) \e$BJQ?t\e(B mime/make-content-subject-function \e$B$r\e(B
+    mime-viewer/content-subject-function \e$B$K2~L>$7!"0z?t$rJQ99$7$?!#\e(B
+
+(3) \e$BJQ?t\e(B mime/make-content-header-filter \e$B$r\e(B
+    mime-viewer/content-header-filter-function \e$B$K2~L>$7$?!#\e(B
+
+(4) \e$BJQ?t\e(B mime/default-showing-Content-Type-list \e$B$r\e(B
+    mime-viewer/default-showing-Content-Type-list \e$B$K2~L>$7$?!#\e(B
+
+(5) \e$BJQ?t\e(B mime/go-to-top-node-method-alist \e$B$r\e(B
+    mime-viewer/quitting-method-alist \e$B$K2~L>$7$?!#$^$?!"\e(Bsymbol \e$BL>$d;E\e(B
+    \e$BMM$NJQ99$K$H$b$J$$!"=i4|@_Dj$rJQ99$7$?!#\e(B
index acaa524..9954209 100644 (file)
@@ -8,7 +8,7 @@
 ;; original file is 
 ;;  gif.el written by Art Mellor @ Cayman Systems, Inc. 1991
 
-;;; $Id: tm-partial.el,v 1.5 1994/12/05 05:13:25 morioka Exp $
+;;; $Id: tm-partial.el,v 2.0 1995/03/12 16:14:44 morioka Exp $
 
 (require 'tm-view)
 
@@ -43,7 +43,7 @@
         (number (cdr (assoc "number" cal)))
         (total (cdr (assoc "total" cal)))
         (buffer (generate-new-buffer id))
-        (mother mime/preview-buffer)
+        (mother mime::article/preview-buffer)
         target
         subject-buf
         (article-buf (buffer-name (current-buffer)))
        (mime/gp:display-article)
        (save-excursion
          (set-buffer article-buf)
-         (make-variable-buffer-local 'mime/content-list)
-         (setq mime/content-list (mime/parse-contents)))
+         ;; (make-variable-buffer-local 'mime/content-list)
+         ;; (setq mime/content-list (mime/parse-contents))
+         (make-variable-buffer-local 'mime::article/content-info)
+         (setq mime::article/content-info (mime-viewer/parse))
+         )
        (delete-other-windows)
        (switch-to-buffer buffer)
        (goto-char (point-min))
index 5ac2d8b..b5ed5b3 100644 (file)
@@ -1,5 +1,5 @@
 ;;;
-;;; $Id: tm-rich.el,v 3.0 1994/11/29 17:59:32 morioka Exp $
+;;; $Id: tm-rich.el,v 4.0 1995/03/12 14:31:58 morioka Exp $
 ;;;
 ;;;          by MORIOKA Tomohiko  <morioka@jaist.ac.jp>
 ;;; modified by YAMATE Keiichirou <ics9118@sem1.info.osaka-cu.ac.jp>
@@ -96,7 +96,7 @@
          )
        ))))
 
-(defun mime/decode-text/richtext (&optional ctl)
+(defun mime-viewer/filter-text/richtext (&optional ctype params)
   (interactive)
   (save-excursion
     (save-restriction
          )
        ))))
 
-(defun mime/decode-text/enriched (&optional ctl)
+(defun mime-viewer/filter-text/enriched (&optional ctype params)
   (interactive)
   (save-excursion
     (save-restriction
 ;;; @ setting
 ;;;
 
-(set-alist 'mime/content-filter-alist
-          "text/richtext" (function mime/decode-text/richtext))
+(set-alist 'mime-viewer/content-filter-alist
+          "text/richtext" (function mime-viewer/filter-text/richtext))
 
-(set-alist 'mime/content-filter-alist
-          "text/enriched" (function mime/decode-text/enriched))
+(set-alist 'mime-viewer/content-filter-alist
+          "text/enriched" (function mime-viewer/filter-text/enriched))
index 24ca642..4e8afd2 100644 (file)
 ;;; @ version
 ;;;
 
-(defconst mime/viewer-RCS-ID
-  "$Id: tm-view.el,v 5.21 1994/11/21 18:38:48 morioka Exp morioka $")
+(defconst mime-viewer/RCS-ID
+  "$Id: tm-view.el,v 6.8 1995/03/12 15:58:32 morioka Exp $")
 
-(defconst mime/viewer-version (get-version-string mime/viewer-RCS-ID))
+(defconst mime-viewer/version (get-version-string mime-viewer/RCS-ID))
+(defconst mime/viewer-version mime-viewer/version)
 
 
 ;;; @ constants
             "-m" "tm" "-x" "-d" "-z" "-e" 'file)(mode . "play"))
     ))
 
-(defvar mime/content-filter-alist
-  '(("text/plain" . mime/decode-text/plain)))
+(defvar mime-viewer/content-filter-alist
+  '(("text/plain" . mime-viewer/filter-text/plain)))
 
-(defvar mime/make-content-subject-function
+(defvar mime-viewer/content-subject-function
   (function
-   (lambda (cid subj ctype)
+   (lambda (cnum subj ctype params)
      (insert
       (format "[%s %s (%s)]\n"
-             (if (listp cid)
+             (if (listp cnum)
                  (mapconcat (function
                              (lambda (num)
                                (format "%s" (+ num 1))
                                ))
-                            cid ".")
+                            cnum ".")
                "0")
-             subj (car ctype)))
+             subj ctype))
      )))
 
-(defvar mime/make-content-header-filter
-;;(setq mime/make-content-header-filter
-  (function
-   (lambda (cid)
-     (if (listp cid)
-        (delete-region (goto-char (point-min))
-                       (or (and (re-search-forward "^$" nil t)
-                                (match-end 0))
-                           (point-max))
-                       )
-       )
-     )))
+(defvar mime-viewer/content-header-filter-function
+  (function mime-viewer/default-content-header-filter-function))
 
-(defvar mime/default-showing-Content-Type-list
-;;(setq mime/default-showing-Content-Type-list
+(defun mime-viewer/default-content-header-filter-function (cnum)
+  (if (listp cnum)
+      (delete-region (goto-char (point-min))
+                    (or (and (re-search-forward "^$" nil t)
+                             (match-end 0))
+                        (point-max))
+                    )
+    ))
+
+(defvar mime-viewer/default-showing-Content-Type-list
   '("text/plain" "text/richtext" "text/enriched"
     "text/x-latex" "application/x-latex"
     "application/octet-stream" nil))
 
-(defvar mime/go-to-top-node-method-alist
-;;(setq mime/go-to-top-node-method-alist
-  '((gnus-article-mode . (lambda ()
-                          (mime/exit-view-mode)
-                          (delete-other-windows)
-                          (gnus-article-show-summary)
-                          ))
-    (rmail-mode . (lambda ()
-                   (mime/exit-view-mode)
-                   (rmail-summary)
-                   (delete-other-windows)
-                   ))
-    (mh-show-mode . (lambda ()
-                     (let ((win (get-buffer-window
-                                 mime/output-buffer-name))
-                           (buf
-                            (nth 2 (car mime/preview-flat-content-list)))
-                           )
-                       (if win
-                           (delete-window win)
-                         )
-                       (mime/exit-view-mode)
-                       (pop-to-buffer
-                        (let ((name (buffer-name buf)))
-                          (string-match "show-" name)
-                          (substring name (match-end 0))
-                          ))
-                       )))
-    (mime/show-message-mode . (lambda ()
-                               (set-window-configuration
-                                mime/show-mode-old-window-configuration)
-                               (let ((mother mime/mother-buffer))
-                                 (kill-buffer
-                                  (nth 2 (car
-                                          mime/preview-flat-content-list)))
-                                 (mime/exit-view-mode)
-                                 (pop-to-buffer mother)
-                                 (goto-char (point-min))
-                                 (mime/up-content)
-                                 )))
+(defvar mime-viewer/quitting-method-alist
+  '((gnus-article-mode
+     . (lambda ()
+        (mime-viewer/kill-buffer)
+        (delete-other-windows)
+        (gnus-article-show-summary)
+        ))
+    (rmail-mode
+     . (lambda ()
+        (mime-viewer/kill-buffer)
+        (rmail-summary)
+        (delete-other-windows)
+        ))
+    (mh-show-mode
+     . (lambda ()
+        (let ((win (get-buffer-window
+                    mime/output-buffer-name))
+              (buf
+               (mime::preview-content-info/buffer
+                (car mime::preview/content-list)))
+              )
+          (if win
+              (delete-window win)
+            )
+          (mime-viewer/kill-buffer)
+          (pop-to-buffer
+           (let ((name (buffer-name buf)))
+             (string-match "show-" name)
+             (substring name (match-end 0))
+             ))
+          )))
+    (mime/show-message-mode
+     . (lambda ()
+        (set-window-configuration
+         mime/show-mode-old-window-configuration)
+        (let ((mother mime/mother-buffer))
+          (kill-buffer
+           (mime::preview-content-info/buffer
+            (car mime::preview/content-list)))
+          (mime-viewer/kill-buffer)
+          (pop-to-buffer mother)
+          (goto-char (point-min))
+          (mime-viewer/up-content)
+          )))
     ))
 
-(defvar mime/use-internal-decoder nil)
+(defvar mime-viewer/decoding-mode "play" "MIME body decoding mode")
+
+
+;;; @ data structure
+;;;
+
+;;; @@ content-info
+;;;
+
+(defun mime::make-content-info (beg end ctype params encoding children)
+  (vector beg end ctype params encoding children)
+  )
+
+(defun mime::content-info/point-min (cinfo)
+  (elt cinfo 0)
+  )
+
+(defun mime::content-info/point-max (cinfo)
+  (elt cinfo 1)
+  )
+
+(defun mime::content-info/type (cinfo)
+  (elt cinfo 2)
+  )
+
+(defun mime::content-info/parameters (cinfo)
+  (elt cinfo 3)
+  )
+
+(defun mime::content-info/encoding (cinfo)
+  (elt cinfo 4)
+  )
+
+(defun mime::content-info/children (cinfo)
+  (elt cinfo 5)
+  )
+
+;;; @@ preview-content-info
+;;;
+
+(defun mime::make-preview-content-info (beg end buf cinfo)
+  (vector beg end buf cinfo)
+  )
+
+(defun mime::preview-content-info/point-min (pcinfo)
+  (elt pcinfo 0)
+  )
+
+(defun mime::preview-content-info/point-max (pcinfo)
+  (elt pcinfo 1)
+  )
+
+(defun mime::preview-content-info/buffer (pcinfo)
+  (elt pcinfo 2)
+  )
+
+(defun mime::preview-content-info/content-info (pcinfo)
+  (elt pcinfo 3)
+  )
+
 
-(defvar mime/body-decoding-mode "play" "MIME body decoding mode")
+;;; @ buffer local variables
+;;;
+
+(defvar mime::article/content-info)
+(defvar mime::article/preview-buffer)
+
+(defvar mime::preview/content-list nil)
+(defvar mime::preview/original-major-mode nil)
 
 
 ;;; @ parser
 ;;;
 
-(defun mime/parse-contents ()
+(defun mime-viewer/parse-message ()
+  (make-variable-buffer-local 'mime::article/content-info)
+  (setq mime::article/content-info (mime-viewer/parse))
+  (let ((ret (mime-viewer/make-preview-buffer)))
+    (make-variable-buffer-local 'mime::article/preview-buffer)
+    (setq mime::article/preview-buffer (car ret))
+    ret))
+
+(defun mime-viewer/parse ()
   (save-excursion
     (save-restriction
-      (goto-char (point-min))
-      (let* ((ctl (mime/Content-Type))
-            (ctype (car ctl))
-            (boundary (assoc "boundary" (cdr ctl)))
-            beg end dest)
-       (if (stringp ctype)
-           (setq ctype (downcase ctype))
-         )
-       (search-forward "\n\n" nil t)
-       (cond (boundary
-              (let ((sep (concat "\n--"
-                                 (setq boundary
-                                       (message/strip-quoted-string
-                                        (cdr boundary)))
-                                 "\n"))
-                    cb ce ct ret ncb)
-                (setq beg (match-end 0))
-                (search-forward (concat "\n--" boundary "--\n") nil t)
-                (setq end (match-beginning 0))
-                (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 (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 (mime/parse-contents))
-                          ))
-                      (setq dest (nconc dest (list ret)))
-                      (goto-char (nth 1 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 (mime/parse-contents))
-                        ))
-                    (setq dest (append dest (list ret)))
-                    ))
-                (setq beg (point-min))
-                (goto-char beg)
-                (search-forward (concat "\n--" boundary "--\n") nil t)
-                (setq end (match-beginning 0))
-                ))
-             ((string= ctype "message/rfc822")
-              (save-excursion
-                (save-restriction
-                  (narrow-to-region (match-end 0) (point-max))
-                  (setq dest (list (mime/parse-contents)))
+      (let ((ctl (progn
+                  (goto-char (point-min))
+                  (mime/Content-Type)
                   ))
-              (setq beg (point-min))
-              (setq end (point-max))
-              )
-             (t (setq beg (point-min))
-                (setq end (point-max))
-                ))
-       (list beg end dest)
-       ))))
+           (encoding (progn
+                       (goto-char (point-min))
+                       (mime/Content-Transfer-Encoding)
+                       ))
+           )
+       (let ((ctype (car ctl))
+             (params (cdr ctl))
+             )
+         (if (stringp ctype)
+             (setq ctype (downcase ctype))
+           )
+         (if (stringp encoding)
+             (setq encoding (downcase encoding))
+           )
+         (let ((boundary (assoc "boundary" params)))
+           (search-forward "\n\n" nil t)
+           (cond (boundary
+                  (setq boundary
+                        (message/strip-quoted-string (cdr boundary)))
+                  (mime-viewer/parse-multipart 
+                   (match-end 0)
+                   (progn
+                     (search-forward (concat "--" boundary "--\n") nil t)
+                     (match-beginning 0)
+                     )
+                    boundary ctype params encoding)
+                  )
+                 ((string= ctype "message/rfc822")
+                  (mime::make-content-info
+                   (point-min) (point-max)
+                   ctype params encoding
+                   (save-excursion
+                     (save-restriction
+                       (narrow-to-region (match-end 0) (point-max))
+                       (list (mime-viewer/parse))
+                       ))
+                   )
+                  )
+                 (t 
+                  (mime::make-content-info (point-min) (point-max)
+                                           ctype params encoding nil)
+                  ))
+           ))))))
+
+(defun mime-viewer/parse-multipart (beg end boundary ctype params encoding)
+  (let ((sep (concat "^--" 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 (mime-viewer/parse))
+             ))
+         (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 (mime-viewer/parse))
+           ))
+       (setq children (nconc children (list ret)))
+       ))
+    (setq beg (point-min))
+    (goto-char beg)
+    (mime::make-content-info beg end ctype params encoding children)
+    ))
 
 (defun mime/Content-Type ()
   (save-excursion
   (replace-as-filename (mime/get-subject param))
   )
 
-(defun mime/make-preview-buffer (&optional buf cl obuf)
-  (let ((the-buf (current-buffer)) fcl)
-    (if (null buf)
-       (setq buf (current-buffer))
-      (setq buf (get-buffer buf))
-      )
-    (if (null cl)
+(defun mime-viewer/make-preview-buffer (&optional buf cinfo obuf)
+  (let ((the-buf (current-buffer)) pcl dest)
+    (setq buf
+         (if (null buf)
+             (current-buffer)
+           (get-buffer buf)
+           ))
+    (if (null cinfo)
        (progn
          (switch-to-buffer buf)
-         (setq cl mime/content-list)
+         (setq cinfo mime::article/content-info)
          ))
     (if (null obuf)
        (setq obuf (concat "*Preview-" (buffer-name buf) "*"))
       )
-    (setq fcl (mime/make-flat-content-list cl))
+    (setq pcl (mime::make-flat-content-list cinfo))
     (if (get-buffer obuf)
        (kill-buffer obuf)
       )
-    (let ((r fcl) cell cid ctype beg end e nb ne subj dest str)
-      (while r
-       (setq cell (car r))
-       (setq beg (car cell))
-       (setq end (nth 1 cell))
-       (setq cid (mime/get-point-content-number beg cl))
-       (switch-to-buffer buf)
-       (save-excursion
-         (save-restriction
-           (narrow-to-region beg end)
-           (goto-char beg)
-           (setq ctype (mime/Content-Type))
-           (setq e
-                 (if (not (member (car ctype)
-                                  mime/default-showing-Content-Type-list))
-                     (progn
-                       (goto-char beg)
-                       (search-forward "\n\n" nil t)
-                       (match-end 0)
-                       )
-                   (+ end 1)
-                   ))
-           ))
-       (if (> e (point-max))
-           (setq e (point-max))
-         )
-       (setq str (buffer-substring beg e))
-       (switch-to-buffer obuf)
-       (setq nb (point))
-       (insert str)
-       (setq ne (point))
-       (save-excursion
-         (save-restriction
-           (narrow-to-region nb ne)
-           (mime/decode-message-header)
-           (setq subj (mime/get-subject (cdr ctype)))
-           (let ((f (cdr (assoc (car ctype) mime/content-filter-alist))))
-             (if (and f (fboundp f))
-                 (funcall f ctype)
-               ))
-           (funcall mime/make-content-header-filter cid)
-           (goto-char nb)
-           (funcall mime/make-content-subject-function cid subj ctype)
-           (setq ne (point-max))
-           (setq dest (nconc dest (list (list nb (- ne 1) buf beg end))))
-           ))
-       (goto-char ne)
-       (setq r (cdr r))
-       )
-      (set-buffer-modified-p nil)
-      (setq buffer-read-only t)
-      (switch-to-buffer the-buf)
-      (list obuf dest)
-      )))
+    (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))
+                   cnum e nb ne subj str)
+               (setq cnum (mime::get-point-content-number beg cinfo))
+               (switch-to-buffer buf)
+               (setq e
+                     (if (not
+                          (member
+                           ctype
+                           mime-viewer/default-showing-Content-Type-list))
+                         (save-excursion
+                           (save-restriction
+                             (goto-char beg)
+                             (search-forward "\n\n" nil t)
+                             (match-end 0)
+                             ))
+                       end))
+               (if (> e (point-max))
+                   (setq e (point-max))
+                 )
+               (setq str (buffer-substring beg e))
+               (switch-to-buffer obuf)
+               (setq nb (point))
+               (insert str)
+               (setq ne (point))
+               (prog1
+                   (save-excursion
+                     (save-restriction
+                       (narrow-to-region nb ne)
+                       (mime/decode-message-header)
+                       (setq subj (mime/get-subject params))
+                       (let ((f
+                              (cdr
+                               (assoc ctype
+                                      mime-viewer/content-filter-alist))))
+                         (if (and f (fboundp f))
+                             (funcall f ctype params)
+                           ))
+                       (funcall mime-viewer/content-header-filter-function
+                                cnum)
+                       (goto-char nb)
+                       (funcall mime-viewer/content-subject-function
+                                cnum subj ctype params)
+                       (setq ne (point-max))
+                       (mime::make-preview-content-info 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)
+    ))
 
-(defun mime/parse-message ()
-  (interactive)
-  (make-variable-buffer-local 'mime/content-list)
-  (setq mime/content-list (mime/parse-contents))
-  (let ((ret (mime/make-preview-buffer)))
-    (make-variable-buffer-local 'mime/preview-buffer)
-    (setq mime/preview-buffer (car ret))
-    ret))
 
 ;;; @ content information
 ;;;
 
-(defun mime/get-point-content-number (p &optional cl)
-  (if (null cl)
-      (setq cl mime/content-list)
+(defun mime::get-point-content-number (p &optional cinfo)
+  (if (null cinfo)
+      (setq cinfo mime::article/content-info)
     )
-  (let ((b (car cl))
-       (e (nth 1 cl))
-       (c (nth 2 cl))
+  (let ((b (mime::content-info/point-min cinfo))
+       (e (mime::content-info/point-max cinfo))
+       (c (mime::content-info/children cinfo))
        )
     (if (and (<= b p)(<= p e))
        (or (let (co ret (sn 0))
              (catch 'tag
                (while c
                  (setq co (car c))
-                 (setq ret (mime/get-point-content-number p co))
+                 (setq ret (mime::get-point-content-number p co))
                  (cond ((eq ret t) (throw 'tag (list sn)))
                        (ret (throw 'tag (cons sn ret)))
                        )
                  )))
            t))))
 
-(defun mime/get-content-region (cn &optional cl)
-  (if (null cl)
-      (setq cl mime/content-list)
+(defun mime::article/get-content-region (cn &optional cinfo)
+  (if (null cinfo)
+      (setq cinfo mime::article/content-info)
     )
   (if (eq cn t)
-      cl
+      cinfo
     (let ((sn (car cn)))
       (if (null sn)
-         cl
-       (let ((rcl (nth sn (nth 2 cl))))
-         (if rcl
-             (mime/get-content-region (cdr cn) rcl)
+         cinfo
+       (let ((rc (nth sn (mime::content-info/children cinfo))))
+         (if rc
+             (mime::article/get-content-region (cdr cn) rc)
            ))
        ))))
 
-(defun mime/make-flat-content-list (&optional cl)
-  (if (null cl)
-      (setq cl mime/content-list)
+(defun mime::make-flat-content-list (&optional cinfo)
+  (if (null cinfo)
+      (setq cinfo mime::article/content-info)
     )
-  (let ((dest (list cl))
-       (rcl (nth 2 cl))
+  (let ((dest (list cinfo))
+       (rcl (mime::content-info/children cinfo))
        )
     (while rcl
-      (setq dest (append dest (mime/make-flat-content-list (car rcl))))
+      (setq dest (nconc dest (mime::make-flat-content-list (car rcl))))
       (setq rcl (cdr rcl))
       )
     dest))
 
-(defun mime/get-point-preview-content (p &optional fcl)
-  (if (null fcl)
-      (setq fcl mime/preview-flat-content-list)
+(defun mime::point-preview-content (p &optional pcl)
+  (if (null pcl)
+      (setq pcl mime::preview/content-list)
     )
   (catch 'tag
-    (let ((r fcl) cell)
+    (let ((r pcl) cell)
       (while r
        (setq cell (car r))
-       (if (and (<= (car cell) p)(<= p (nth 1 cell)))
+       (if (and (<= (mime::preview-content-info/point-min cell) p)
+                (<= p (mime::preview-content-info/point-max cell))
+                )
            (throw 'tag cell)
          )
        (setq r (cdr r))
        ))
-    (car (last fcl))
+    (car (last pcl))
     ))
 
 
         (total (cdr (assoc "total" cal)))
         (the-buf (current-buffer))
         file
-        (mother mime/preview-buffer))
+        (mother mime::article/preview-buffer))
     (if (not (file-exists-p root-dir))
        (shell-command (concat "mkdir " root-dir))
       )
   (get-unified-alist mime/content-decoding-condition al)
   )
 
-(defun mime/decode-content-region (beg end)
+(defun mime::article/decode-content-region (cinfo)
   (interactive "*r")
-  (let (ctl encoding)
-    (save-excursion
-      (save-restriction
-       (narrow-to-region beg end)
-       (and (goto-char beg)
-            (setq ctl (mime/Content-Type))
-            (goto-char beg)
-            (setq encoding (mime/Content-Transfer-Encoding "7bit"))
-            )))
-    (if ctl
-       (let ((ctype (downcase (car ctl))) method cal ret)
-         (setq ctl (cdr ctl))
-         (setq cal (nconc (list (cons 'type ctype)
-                                (cons 'encoding encoding)
-                                (cons 'major-mode major-mode)
-                                )
-                          ctl))
-         (if mime/body-decoding-mode
+  (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/body-decoding-mode)
+                        (cons 'mode mime-viewer/decoding-mode)
                         cal))
            )
          (setq ret (mime/get-content-decoding-alist cal))
 ;;; @ content filter
 ;;;
 
-(defun mime/decode-text/plain (ctl)
-  (interactive)
+(defun mime-viewer/filter-text/plain (ctype params)
   (save-excursion
     (save-restriction
-      (let ((charset (cdr (assoc "charset" (cdr ctl))))
-           (encoding 
+      (let ((charset (cdr (assoc "charset" params)))
+           (encoding
             (save-excursion
               (save-restriction
                 (goto-char (point-min))
     (progn
       (setq mime/viewer-mode-map (make-keymap))
       (suppress-keymap mime/viewer-mode-map)
-      (define-key mime/viewer-mode-map "u" 'mime/up-content)
-      (define-key mime/viewer-mode-map "p" 'mime/previous-content)
-      (define-key mime/viewer-mode-map "n" 'mime/next-content)
-      (define-key mime/viewer-mode-map " " 'mime/scroll-up-content)
-      (define-key mime/viewer-mode-map "\M- " 'mime/scroll-down-content)
-      (define-key mime/viewer-mode-map "\177" 'mime/scroll-down-content)
-      (define-key mime/viewer-mode-map "\C-m" 'mime/next-line-content)
-      (define-key mime/viewer-mode-map "\C-\M-m" 'mime/previous-line-content)
-      (define-key mime/viewer-mode-map "v" 'mime/play-content)
-      (define-key mime/viewer-mode-map "e" 'mime/extract-content)
-      (define-key mime/viewer-mode-map "\C-c\C-p" 'mime/print-content)
-      (define-key mime/viewer-mode-map "q" 'mime/quit-view-mode)
-      (define-key mime/viewer-mode-map "\C-c\C-x" 'mime/exit-view-mode)
+      (define-key mime/viewer-mode-map
+       "u"        (function mime-viewer/up-content))
+      (define-key mime/viewer-mode-map
+       "p"        (function mime-viewer/previous-content))
+      (define-key mime/viewer-mode-map
+       "n"        (function mime-viewer/next-content))
+      (define-key mime/viewer-mode-map
+       " "        (function mime-viewer/scroll-up-content))
+      (define-key mime/viewer-mode-map
+       "\M- "     (function mime-viewer/scroll-down-content))
+      (define-key mime/viewer-mode-map
+       "\177"     (function mime-viewer/scroll-down-content))
+      (define-key mime/viewer-mode-map
+       "\C-m"     (function mime-viewer/next-line-content))
+      (define-key mime/viewer-mode-map
+       "\C-\M-m"  (function mime-viewer/previous-line-content))
+      (define-key mime/viewer-mode-map
+       "v"        (function mime-viewer/play-content))
+      (define-key mime/viewer-mode-map
+       "e"        (function mime-viewer/extract-content))
+      (define-key mime/viewer-mode-map
+       "\C-c\C-p" (function mime-viewer/print-content))
+      (define-key mime/viewer-mode-map
+       "q"        (function mime-viewer/quit))
+      (define-key mime/viewer-mode-map
+       "\C-c\C-x" (function mime-viewer/kill-buffer))
       ))
 
 (defun mime/viewer-mode (&optional mother)
@@ -753,13 +857,13 @@ q Quit
          (erase-buffer)
          (switch-to-buffer the-buf)
          )))
-  (let ((ret (mime/parse-message))
+  (let ((ret (mime-viewer/parse-message))
        (mode major-mode))
     (switch-to-buffer (car ret))
     (setq major-mode 'mime/viewer-mode)
     (setq mode-name "MIME-View")
-    (make-variable-buffer-local 'mime/viewer-original-major-mode)
-    (setq mime/viewer-original-major-mode
+    (make-variable-buffer-local 'mime::preview/original-major-mode)
+    (setq mime::preview/original-major-mode
          (if mother
              (progn
                (make-variable-buffer-local
@@ -771,10 +875,12 @@ q Quit
                'mime/show-message-mode)
            mode))
     (use-local-map mime/viewer-mode-map)
-    (make-variable-buffer-local 'mime/preview-flat-content-list)
-    (setq mime/preview-flat-content-list (nth 1 ret))
+    (make-variable-buffer-local 'mime::preview/content-list)
+    (setq mime::preview/content-list (nth 1 ret))
     (goto-char
-     (let ((ce (nth 1 (car mime/preview-flat-content-list)))
+     (let ((ce (mime::preview-content-info/point-max
+               (car mime::preview/content-list)
+               ))
           e)
        (goto-char (point-min))
        (search-forward "\n\n" nil t)
@@ -785,155 +891,167 @@ q       Quit
     (run-hooks 'mime/viewer-mode-hook)
     ))
 
-(defun mime/decode-content ()
+(defun mime::preview/decode-content ()
   (interactive)
-  (let ((pc (mime/get-point-preview-content (point))))
+  (let ((pc (mime::point-preview-content (point))))
     (if pc
        (let ((the-buf (current-buffer)))
-         (switch-to-buffer (nth 2 pc))
-         (mime/decode-content-region (nth 3 pc)(nth 4 pc))
-         (if (eq (current-buffer) (nth 2 pc))
+         (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))
              (switch-to-buffer the-buf)
            )
          ))))
 
-(defun mime/play-content ()
+(defun mime-viewer/play-content ()
   (interactive)
-  (let ((mime/body-decoding-mode "play"))
-    (mime/decode-content)
+  (let ((mime-viewer/decoding-mode "play"))
+    (mime::preview/decode-content)
     ))
 
-(defun mime/extract-content ()
+(defun mime-viewer/extract-content ()
   (interactive)
-  (let ((mime/body-decoding-mode "extract"))
-    (mime/decode-content)
+  (let ((mime-viewer/decoding-mode "extract"))
+    (mime::preview/decode-content)
     ))
 
-(defun mime/print-content ()
+(defun mime-viewer/print-content ()
   (interactive)
-  (let ((mime/body-decoding-mode "print"))
-    (mime/decode-content)
+  (let ((mime-viewer/decoding-mode "print"))
+    (mime::preview/decode-content)
     ))
 
-(defun mime/up-content ()
+(defun mime-viewer/up-content ()
   (interactive)
-  (let ((pc (mime/get-point-preview-content (point)))
+  (let ((pc (mime::point-preview-content (point))) cinfo
        (the-buf (current-buffer))
        cn r)
-    (switch-to-buffer (nth 2 pc))
-    (setq cn (mime/get-point-content-number (nth 3 pc)))
+    (switch-to-buffer (mime::preview-content-info/buffer pc))
+    (setq cinfo (mime::preview-content-info/content-info pc))
+    (setq cn (mime::get-point-content-number
+             (mime::content-info/point-min cinfo)))
     (if (eq cn t)
-       (mime/quit-view-mode the-buf (nth 2 pc))
-      (setq r (mime/get-content-region (butlast cn)))
+       (mime-viewer/quit the-buf
+                         (mime::preview-content-info/buffer pc)
+                         )
+      (setq r (mime::article/get-content-region (butlast cn)))
       (switch-to-buffer the-buf)
       (catch 'tag
-       (let ((rfcl mime/preview-flat-content-list) cell)
-         (while rfcl
-           (setq cell (car rfcl))
-           (if (and (= (car r)(nth 3 cell))
-                    (= (nth 1 r)(nth 4 cell))
-                    )
+       (let ((rpcl mime::preview/content-list) cell)
+         (while rpcl
+           (setq cell (car rpcl))
+           (if (eq r (mime::preview-content-info/content-info cell))
                (progn
-                 (goto-char (nth 0 cell))
+                 (goto-char (mime::preview-content-info/point-min cell))
                  (throw 'tag nil)
                  ))
-           (setq rfcl (cdr rfcl))
+           (setq rpcl (cdr rpcl))
            )))
       )))
 
-(defun mime/previous-content ()
+(defun mime-viewer/previous-content ()
   (interactive)
-  (let* ((fcl mime/preview-flat-content-list)
+  (let* ((pcl mime::preview/content-list)
         (p (point))
-        (i (- (length fcl) 1))
-        )
+        (i (- (length pcl) 1))
+        beg)
     (catch 'tag
       (while (>= i 0)
-       (if (> p (car (nth i fcl)))
-           (throw 'tag (goto-char (car (nth i fcl))))
+       (setq beg (mime::preview-content-info/point-min (nth i pcl)))
+       (if (> p beg)
+           (throw 'tag (goto-char beg))
          )
        (setq i (- i 1))
        ))
     ))
 
-(defun mime/next-content ()
+(defun mime-viewer/next-content ()
   (interactive)
-  (let ((fcl mime/preview-flat-content-list)
+  (let ((pcl mime::preview/content-list)
        (p (point))
-       )
+       beg)
     (catch 'tag
-      (while fcl
-       (if (< p (car (car fcl)))
-           (throw 'tag (goto-char (car (car fcl))))
+      (while pcl
+       (setq beg (mime::preview-content-info/point-min (car pcl)))
+       (if (< p beg)
+           (throw 'tag (goto-char beg))
          )
-       (setq fcl (cdr fcl))
+       (setq pcl (cdr pcl))
        ))
     ))
 
-(defun mime/scroll-up-content (&optional h)
+(defun mime-viewer/scroll-up-content (&optional h)
   (interactive)
   (if (null h)
       (setq h (- (window-height) 1))
     )
-  (let ((fcl mime/preview-flat-content-list)
+  (let ((pcl mime::preview/content-list)
        (p (point))
-       np)
-    (setq np (or (catch 'tag
-                  (while fcl
-                    (if (< p (car (car fcl)))
-                        (throw 'tag (car (car fcl)))
-                      )
-                    (setq fcl (cdr fcl))
-                    ))
-                (point-max)))
+       np beg)
+    (setq np
+         (or (catch 'tag
+               (while pcl
+                 (setq beg (mime::preview-content-info/point-min (car pcl)))
+                 (if (< p beg)
+                     (throw 'tag beg)
+                   )
+                 (setq pcl (cdr pcl))
+                 ))
+             (point-max)))
     (forward-line h)
     (if (> (point) np)
        (goto-char np)
       )))
 
-(defun mime/scroll-down-content (&optional h)
+(defun mime-viewer/scroll-down-content (&optional h)
   (interactive)
   (if (null h)
       (setq h (- (window-height) 1))
     )
-  (let ((fcl mime/preview-flat-content-list)
+  (let ((pcl mime::preview/content-list)
        (p (point))
-       pp)
-    (setq pp (or (let ((i (- (length fcl) 1)))
-                  (catch 'tag
-                    (while (> i 0)
-                      (if (> p (nth 1 (nth i fcl)))
-                          (throw 'tag (nth 1 (nth i fcl)))
-                        )
-                      (setq i (- i 1))
-                      )))
-                (point-min)))
+       pp beg)
+    (setq pp
+         (or (let ((i (- (length pcl) 1)))
+               (catch 'tag
+                 (while (> i 0)
+                   (setq beg (mime::preview-content-info/point-min
+                              (nth i pcl)))
+                   (if (> p beg)
+                       (throw 'tag beg)
+                     )
+                   (setq i (- i 1))
+                   )))
+             (point-min)))
     (forward-line (- h))
     (if (< (point) pp)
        (goto-char pp)
       )))
 
-(defun mime/next-line-content ()
+(defun mime-viewer/next-line-content ()
   (interactive)
-  (mime/scroll-up-content 1)
+  (mime-viewer/scroll-up-content 1)
   )
 
-(defun mime/previous-line-content ()
+(defun mime-viewer/previous-line-content ()
   (interactive)
-  (mime/scroll-down-content 1)
+  (mime-viewer/scroll-down-content 1)
   )
 
-(defun mime/quit-view-mode (&optional the-buf buf)
+(defun mime-viewer/quit (&optional the-buf buf)
   (interactive)
   (if (null the-buf)
       (setq the-buf (current-buffer))
     )
   (if (null buf)
-      (setq buf (nth 2 (mime/get-point-preview-content (point))))
+      (setq buf (mime::preview-content-info/buffer
+                (mime::point-preview-content (point))))
     )
   (let ((r (progn
             (switch-to-buffer buf)
-            (assoc major-mode mime/go-to-top-node-method-alist)
+            (assoc major-mode mime-viewer/quitting-method-alist)
             )))
     (if r
        (progn
@@ -942,7 +1060,7 @@ q  Quit
          ))
     ))
 
-(defun mime/exit-view-mode ()
+(defun mime-viewer/kill-buffer ()
   (interactive)
   (kill-buffer (current-buffer))
   )
index 3f630ac..f119edd 100644 (file)
--- a/tm-vm.el
+++ b/tm-vm.el
 (require 'vm)
 
 (defconst tm-vm/RCS-ID
-  "$Id: tm-vm.el,v 1.7 1994/12/08 14:48:55 morioka Exp $")
+  "$Id: tm-vm.el,v 2.0 1995/03/11 22:57:32 morioka Exp $")
 (defconst tm-vm/version (get-version-string tm-vm/RCS-ID))
 
 (define-key vm-mode-map "Z" 'tm-vm/view-message)
 
-(set-alist 'mime/go-to-top-node-method-alist
+(set-alist 'mime-viewer/quitting-method-alist
           'vm-mode
           'tm-vm/quit-view-message)
 
-(set-alist 'mime/go-to-top-node-method-alist
+(set-alist 'mime-viewer/quitting-method-alist
           'vm-virtual-mode
           'tm-vm/quit-view-message)
 
 ;;;
 
 (defun tm-vm/quit-view-message()
-  (mime/exit-view-mode)
+  (mime-viewer/kill-buffer)
   (let ((w (get-buffer-window mime/output-buffer-name)))
     (if w (delete-window w)))
   (vm-display vm-summary-buffer t
-             '(mime/exit-view-mode)
+             '(mime-viewer/kill-buffer)
              '(this-command))
   (vm-widen-page)
   (goto-char (point-max))
@@ -58,7 +58,8 @@
   (goto-char (point-min))
   (if vm-honor-page-delimiters
       (vm-narrow-to-page))
-  (select-window (get-buffer-window vm-summary-buffer)))
+  (select-window (get-buffer-window vm-summary-buffer))
+  )
 
 (defun tm-vm/view-message ()
   "Decode and view MIME message for VM"
@@ -75,4 +76,5 @@
   (narrow-to-region (point) (vm-start-of (car vm-message-pointer)))
   (goto-char (point-min))
   (select-window (vm-get-buffer-window (current-buffer)))
-  (mime/viewer-mode))
+  (mime/viewer-mode)
+  )