(bbdb-extract-field-value): Use `eword-decode-string' instead of
[elisp/tm.git] / tm-view.el
index e8b817c..25aa9fc 100644 (file)
@@ -1,10 +1,10 @@
 ;;; tm-view.el --- interactive MIME viewer for GNU Emacs
 
-;; Copyright (C) 1995,1996 Free Software Foundation, Inc.
+;; Copyright (C) 1995,1996,1997 Free Software Foundation, Inc.
 
 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
 ;; Created: 1994/7/13 (1994/8/31 obsolete tm-body.el)
-;; Version: $Revision: 7.75 $
+;; Version: $Revision: 7.82 $
 ;; Keywords: mail, news, MIME, multimedia
 
 ;; This file is part of tm (Tools for MIME).
@@ -20,8 +20,8 @@
 ;; General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with This program; see the file COPYING.  If not, write to
-;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 ;; Boston, MA 02111-1307, USA.
 
 ;;; Code:
@@ -42,7 +42,7 @@
 ;;;
 
 (defconst mime-viewer/RCS-ID
-  "$Id: tm-view.el,v 7.75 1996/09/14 08:56:05 morioka Exp $")
+  "$Id: tm-view.el,v 7.82 1997/02/18 10:51:17 tmorioka Exp $")
 
 (defconst mime-viewer/version (get-version-string mime-viewer/RCS-ID))
 (defconst mime/viewer-version mime-viewer/version)
 
 (defvar mime/content-decoding-condition
   '(((type . "text/plain")
-     (method "tm-plain" nil 'file 'type 'encoding 'mode 'name))
+     (method "tm-plain" nil 'file 'type 'encoding 'mode 'name)
+     (mode "play" "print")
+     )
     ((type . "text/html")
      (method "tm-html" nil 'file 'type 'encoding 'mode 'name)
-     (mode . "play"))
+     (mode . "play")
+     )
     ((type . "text/x-rot13-47")
-     (method . mime-article/decode-caesar))
-    
+     (method . mime-article/decode-caesar)
+     (mode . "play")
+     )
     ((type . "audio/basic")
-     (method "tm-au"    nil 'file 'type 'encoding 'mode 'name))
+     (method "tm-au"    nil 'file 'type 'encoding 'mode 'name)
+     (mode . "play")
+     )
     
     ((type . "image/jpeg")
-     (method "tm-image" nil 'file 'type 'encoding 'mode 'name))
+     (method "tm-image" nil 'file 'type 'encoding 'mode 'name)
+     (mode "play" "print")
+     )
     ((type . "image/gif")
-     (method "tm-image" nil 'file 'type 'encoding 'mode 'name))
+     (method "tm-image" nil 'file 'type 'encoding 'mode 'name)
+     (mode "play" "print")
+     )
     ((type . "image/tiff")
-     (method "tm-image" nil 'file 'type 'encoding 'mode 'name))
+     (method "tm-image" nil 'file 'type 'encoding 'mode 'name)
+     (mode "play" "print")
+     )
     ((type . "image/x-tiff")
-     (method "tm-image" nil 'file 'type 'encoding 'mode 'name))
+     (method "tm-image" nil 'file 'type 'encoding 'mode 'name)
+     (mode "play" "print")
+     )
     ((type . "image/x-xbm")
-     (method "tm-image" nil 'file 'type 'encoding 'mode 'name))
+     (method "tm-image" nil 'file 'type 'encoding 'mode 'name)
+     (mode "play" "print")
+     )
     ((type . "image/x-pic")
-     (method "tm-image" nil 'file 'type 'encoding 'mode 'name))
+     (method "tm-image" nil 'file 'type 'encoding 'mode 'name)
+     (mode "play" "print")
+     )
     ((type . "image/x-mag")
-     (method "tm-image" nil 'file 'type 'encoding 'mode 'name))
+     (method "tm-image" nil 'file 'type 'encoding 'mode 'name)
+     (mode "play" "print")
+     )
     
     ((type . "video/mpeg")
-     (method "tm-mpeg"  nil 'file 'type 'encoding 'mode 'name))
+     (method "tm-mpeg"  nil 'file 'type 'encoding 'mode 'name)
+     (mode . "play")
+     )
     
+    ((type . "application/postscript")
+     (method "tm-ps" nil 'file 'type 'encoding 'mode 'name)
+     (mode "play" "print")
+     )
     ((type . "application/octet-stream")
-     (method "tm-file"  nil 'file 'type 'encoding 'mode 'name))
+     (method "tm-file"  nil 'file 'type 'encoding 'mode 'name)
+     (mode "play" "print")
+     )
     
     ;;((type . "message/external-body")
     ;; (method "xterm" nil
     ;;        "-e" "showexternal"
     ;;         'file '"access-type" '"name" '"site" '"directory"))
     ((type . "message/rfc822")
-     (method . mime-article/view-message/rfc822))
+     (method . mime-article/view-message/rfc822)
+     (mode . "play")
+     )
     ((type . "message/partial")
-     (method . mime-article/decode-message/partial))
+     (method . mime-article/decode-message/partial)
+     (mode . "play")
+     )
     
-    ((method "metamail" t
-            "-m" "tm" "-x" "-d" "-z" "-e" 'file)(mode . "play"))
+    ((method "metamail" t "-m" "tm" "-x" "-d" "-z" "-e" 'file)
+     (mode . "play")
+     )
     ((method "tm-file"  nil 'file 'type 'encoding 'mode 'name)
-     (mode . "extract"))
+     (mode . "extract")
+     )
     ))
 
 (defvar mime-viewer/childrens-header-showing-Content-Type-list
@@ -346,6 +380,9 @@ Each elements are regexp of field-name. [tm-view.el]")
 
 (defvar mime-viewer/following-method-alist nil)
 
+(defvar mime-viewer/following-required-fields-list
+  '("From"))
+
 
 ;;; @@ X-Face
 ;;;
@@ -695,8 +732,10 @@ The compressed face will be piped to this command.")
 (defun mime-viewer/define-keymap (&optional mother)
   (let ((mime/viewer-mode-map (if mother
                                  (copy-keymap mother)
-                               (make-keymap))))
-    (suppress-keymap mime/viewer-mode-map)
+                               (make-keymap)
+                               )))
+    (or mother
+       (suppress-keymap mime/viewer-mode-map))
     (define-key mime/viewer-mode-map
       "u"        (function mime-viewer/up-content))
     (define-key mime/viewer-mode-map
@@ -704,6 +743,10 @@ The compressed face will be piped to this command.")
     (define-key mime/viewer-mode-map
       "n"        (function mime-viewer/next-content))
     (define-key mime/viewer-mode-map
+      "\e\t"     (function mime-viewer/previous-content))
+    (define-key mime/viewer-mode-map
+      "\t"       (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))
@@ -716,7 +759,7 @@ The compressed face will be piped to this command.")
     (define-key mime/viewer-mode-map
       "v"        (function mime-viewer/play-content))
     (define-key mime/viewer-mode-map
-      "e"         (function mime-viewer/extract-content))
+      "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
@@ -771,11 +814,10 @@ key               feature
 ---            -------
 
 u              Move to upper content
-p              Move to previous content
-n              Move to next content
+p or M-TAB     Move to previous content
+n or TAB       Move to next content
 SPC            Scroll up or move to next content
-M-SPC          Scroll down or move to previous content
-DEL            Scroll down or move to previous content
+M-SPC or DEL   Scroll down or move to previous content
 RET            Move to next line
 M-RET          Move to previous line
 v              Decode current content as `play mode'
@@ -947,10 +989,34 @@ button-2  Move to point under the mouse cursor
                      rcnum (cdr rcnum))
                )
              )
+           (let ((rest mime-viewer/following-required-fields-list))
+             (while rest
+               (let ((field-name (car rest)))
+                 (or (std11-field-body field-name)
+                     (insert
+                      (format
+                       (concat field-name
+                               ": "
+                               (save-excursion
+                                 (set-buffer the-buf)
+                                 (set-buffer mime::preview/mother-buffer)
+                                 (set-buffer mime::preview/article-buffer)
+                                 (std11-field-body field-name)
+                                 )
+                               "\n")))
+                     ))
+               (setq rest (cdr rest))
+               ))
            (mime/decode-message-header)
            )
-         (funcall (cdr (assq mode mime-viewer/following-method-alist))
-                  new-buf)
+         (let ((f (cdr (assq mode mime-viewer/following-method-alist))))
+           (if (functionp f)
+               (funcall f new-buf)
+             (message
+              (format
+               "Sorry, following method for %s is not implemented yet."
+               mode))
+             ))
          ))))
 
 (defun mime-viewer/display-x-face ()
@@ -991,7 +1057,7 @@ button-2   Move to point under the mouse cursor
         (i (- (length pcl) 1))
         beg)
     (catch 'tag
-      (while (>= i 0)
+      (while (> i 0)
        (setq beg (mime::preview-content-info/point-min (nth i pcl)))
        (if (> p beg)
            (throw 'tag (goto-char beg))