tm 7.67.
[elisp/tm.git] / tm-view.el
index 9c88f3a..30b5bd1 100644 (file)
@@ -8,7 +8,7 @@
 ;;; modified by Steven L. Baur <steve@miranova.com>
 ;;; Maintainer: MORIOKA Tomohiko <morioka@jaist.ac.jp>
 ;;; Created: 1994/7/13 (1994/8/31 obsolete tm-body.el)
-;;; Version: $Revision: 7.59 $
+;;; Version: $Revision: 7.65 $
 ;;; Keywords: mail, news, MIME, multimedia
 ;;;
 ;;; This file is part of tm (Tools for MIME).
@@ -45,7 +45,7 @@
 ;;;
 
 (defconst mime-viewer/RCS-ID
-  "$Id: tm-view.el,v 7.59 1996/05/11 16:23:16 morioka Exp $")
+  "$Id: tm-view.el,v 7.65 1996/05/23 16:45:10 shuhei-k Exp $")
 
 (defconst mime-viewer/version (get-version-string mime-viewer/RCS-ID))
 (defconst mime/viewer-version mime-viewer/version)
     "application/octet-stream"
     "application/x-selection" "application/x-comment"))
 
-(defvar mime-viewer/content-subject-omitting-Content-Type-list
+(defvar mime-viewer/content-button-ignored-ctype-list
   '("application/x-selection"))
 
-(defvar mime-viewer/content-subject-showing-Content-Type-list
+(defvar mime-viewer/content-button-visible-ctype-list
   '("application/pgp"))
 
 (defvar mime-viewer/uuencode-encoding-name-list '("x-uue" "x-uuencode"))
@@ -136,7 +136,7 @@ Each elements are regexp of field-name. [tm-view.el]")
          ":"))
 
 (defvar mime-viewer/visible-field-list
-  '("Dnas.*")
+  '("Dnas.*" "Message-Id")
   "All fields that match this list will be displayed in MIME preview buffer.
 Each elements are regexp of field-name. [tm-view.el]")
 
@@ -193,54 +193,69 @@ Each elements are regexp of field-name. [tm-view.el]")
     ))
 
 
-;;; @@ content subject
+;;; @@ content button
 ;;;
 
-(defun mime-viewer/insert-content-subject
-  (rcnum cinfo ctype params subj)
+(defun mime-preview/insert-content-button
+  (rcnum cinfo ctype params subj encoding)
   (save-restriction
     (narrow-to-region (point)(point))
-    (insert
-     (let ((access-type (assoc "access-type" params))
-          (num (or (assoc-value "x-part-number" params)
-                   (if (consp rcnum)
-                       (mapconcat (function
-                                   (lambda (num)
-                                     (format "%s" (1+ num))
-                                     ))
-                                  (reverse rcnum) ".")
-                     "0"))
-               ))
-       (if access-type
-          (let ((server (assoc "server" params)))
-            (setq access-type (cdr access-type))
-            (if server
-                (format "[%s %s ([%s] %s)]\n" num subj
-                        access-type (cdr server))
-              (let ((site (assoc-value "site" params))
-                    (dir (assoc-value "directory" params))
-                    )
-                (format "[%s %s ([%s] %s:%s)]\n" num subj
-                        access-type site dir)
-                )))
-        (format "[%s %s (%s)]\n" num subj ctype)
-        )))
+    (let ((access-type (assoc "access-type" params))
+         (charset (assoc "charset" params))
+         (num (or (assoc-value "x-part-number" params)
+                  (if (consp rcnum)
+                      (mapconcat (function
+                                  (lambda (num)
+                                    (format "%s" (1+ num))
+                                    ))
+                                 (reverse rcnum) ".")
+                    "0"))
+              ))
+      (cond (access-type
+            (let ((server (assoc "server" params)))
+              (setq access-type (cdr access-type))
+              (if server
+                  (insert (format "[%s %s ([%s] %s)]\n" num subj
+                                  access-type (cdr server)))
+                (let ((site (assoc-value "site" params))
+                      (dir (assoc-value "directory" params))
+                      )
+                  (insert (format "[%s %s ([%s] %s:%s)]\n" num subj
+                                  access-type site dir))
+                  )))
+            )
+           (t
+            (insert (concat "[" num " " subj))
+            (let ((rest
+                   (if (setq charset (cdr charset))
+                       (if encoding
+                           (format " <%s; %s (%s)>]\n"
+                                   ctype charset encoding)
+                         (format " <%s; %s>]\n" ctype charset)
+                         )
+                     (format " <%s>]\n" ctype)
+                     )))
+              (if (>= (+ (current-column)(length rest))(window-width))
+                  (setq rest (concat "\n\t" rest))
+                )
+              (insert rest)
+              ))))
     (tm:add-button (point-min)(1- (point-max))
                   (function mime-viewer/play-content))
     ))
 
-(defun mime-viewer/default-content-subject-function
-  (rcnum cinfo ctype params subj)
+(defun mime-preview/default-content-button-function
+  (rcnum cinfo ctype params subj encoding)
   (if (and (consp rcnum)
           (not (member
                 ctype
-                mime-viewer/content-subject-omitting-Content-Type-list)))
-      (mime-viewer/insert-content-subject
-       rcnum cinfo ctype params subj)
+                mime-viewer/content-button-ignored-ctype-list)))
+      (mime-preview/insert-content-button
+       rcnum cinfo ctype params subj encoding)
     ))
 
-(defvar mime-viewer/content-subject-function
-  (function mime-viewer/default-content-subject-function))
+(defvar mime-preview/content-button-function
+  (function mime-preview/default-content-button-function))
 
 
 ;;; @@ content header filter
@@ -287,7 +302,7 @@ Each elements are regexp of field-name. [tm-view.el]")
 ;;; @@ content separator
 ;;;
 
-(defun mime-viewer/default-content-separator (rcnum cinfo ctype params subj)
+(defun mime-preview/default-content-separator (rcnum cinfo ctype params subj)
   (if (and (not (mime-viewer/header-visible-p rcnum cinfo ctype))
           (not (mime-viewer/body-visible-p rcnum cinfo ctype))
           )
@@ -460,37 +475,34 @@ The compressed face will be piped to this command.")
     (set-buffer obuf)
     (setq nb (point))
     (narrow-to-region nb nb)
-    (funcall mime-viewer/content-subject-function
-            rcnum cinfo ctype params subj)
+    (funcall mime-preview/content-button-function
+            rcnum cinfo ctype params subj encoding)
     (if (mime-viewer/header-visible-p rcnum cinfo ctype)
        (mime-preview/display-header beg he)
       )
-    (set-buffer ibuf)
     (if (and (null rcnum)
             (member
-             ctype mime-viewer/content-subject-showing-Content-Type-list))
+             ctype mime-viewer/content-button-visible-ctype-list))
        (save-excursion
-         (set-buffer obuf)
          (goto-char (point-max))
-         (mime-viewer/insert-content-subject rcnum cinfo ctype params subj)
+         (mime-preview/insert-content-button
+          rcnum cinfo ctype params subj encoding)
          ))
     (cond ((mime-viewer/body-visible-p rcnum cinfo ctype)
-          (mime-viewer/display-body he end obuf
-                                    rcnum cinfo ctype params subj encoding)
+          (mime-preview/display-body he end
+                                     rcnum cinfo ctype params subj encoding)
           )
          ((equal ctype "message/partial")
-          (mime-viewer/display-message/partial obuf)
+          (mime-preview/display-message/partial)
           )
          ((and (null rcnum)
                (null (mime::content-info/children cinfo))
                )
-          (set-buffer obuf)
           (goto-char (point-max))
-          (mime-viewer/insert-content-subject rcnum cinfo ctype params subj)
-          )
-         (t (set-buffer obuf))
-         )
-    (mime-viewer/default-content-separator rcnum cinfo ctype params subj)
+          (mime-preview/insert-content-button
+           rcnum cinfo ctype params subj encoding)
+          ))
+    (mime-preview/default-content-separator rcnum cinfo ctype params subj)
     (prog1
        (progn
          (setq ne (point-max))
@@ -513,23 +525,19 @@ The compressed face will be piped to this command.")
     (run-hooks 'mime-viewer/content-header-filter-hook)
     ))
 
-(defun mime-viewer/display-body (beg end obuf
-                                    rcnum 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 (cdr (or (assoc ctype mime-viewer/content-filter-alist)
-                       (assq t mime-viewer/content-filter-alist)))))
-       (and (functionp f)
-            (funcall f ctype params encoding)
-            )))))
-
-(defun mime-viewer/display-message/partial (obuf)
-  (set-buffer obuf)
+(defun mime-preview/display-body (beg end
+                                     rcnum cinfo ctype params subj encoding)
+  (save-restriction
+    (narrow-to-region (point-max)(point-max))
+    (insert-buffer-substring mime::preview/article-buffer beg end)
+    (let ((f (cdr (or (assoc ctype mime-viewer/content-filter-alist)
+                     (assq t mime-viewer/content-filter-alist)))))
+      (and (functionp f)
+          (funcall f ctype params encoding)
+          )
+      )))
+
+(defun mime-preview/display-message/partial ()
   (save-restriction
     (goto-char (point-max))
     (if (not (search-backward "\n\n" nil t))
@@ -713,6 +721,8 @@ The compressed face will be piped to this command.")
         "<"        (function beginning-of-buffer))
       (define-key mime/viewer-mode-map
         ">"        (function end-of-buffer))
+      (define-key mime/viewer-mode-map
+        "?"        (function describe-mode))
       (if mouse-button-2
          (define-key mime/viewer-mode-map
            mouse-button-2 (function tm:button-dispatcher))
@@ -769,7 +779,8 @@ M-RET               Move to previous line
 v              Decode current content as `play mode'
 e              Decode current content as `extract mode'
 C-c C-p                Decode current content as `print mode'
-f              Display X-Face
+a              Followup to current content.
+x              Display X-Face
 q              Quit
 button-2       Move to point under the mouse cursor
                and decode current content as `play mode'