(What's EMH?): Modify for SEMI 1.7.
[elisp/emh.git] / emh.el
diff --git a/emh.el b/emh.el
index c6187a8..74d906f 100644 (file)
--- a/emh.el
+++ b/emh.el
@@ -1,6 +1,6 @@
 ;;; emh.el --- MIME extender for mh-e
 
-;; Copyright (C) 1995,1996,1997 Free Software Foundation, Inc.
+;; Copyright (C) 1995,1996,1997,1998 Free Software Foundation, Inc.
 
 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
 ;;         OKABE Yasuo <okabe@kudpc.kyoto-u.ac.jp>
@@ -8,7 +8,6 @@
 ;; Created: 1993/11/21
 ;;     Renamed: 1993/11/27 from mh-e-mime.el
 ;;     Renamed: 1997/02/21 from tm-mh-e.el
-;; Version: $Revision: 0.21 $
 ;; Keywords: MH, MIME, multimedia, encoded-word, multilingual, mail
 
 ;; This file is part of emh.
 ;;; Code:
 
 (require 'mh-e)
+(require 'alist)
 (require 'mime-view)
+(eval-when-compile (require 'mime-text))
 
 
 ;;; @ version
 ;;;
 
-(defconst emh-RCS-ID
-  "$Id: emh.el,v 0.21 1997-08-05 09:10:22 morioka Exp $")
-
-(defconst emh-version (get-version-string emh-RCS-ID))
+(defconst emh-version "1.6.0")
 
 
 ;;; @ variable
 ;;;
 
-(defvar emh-automatic-mime-preview t
-  "*If non-nil, show MIME processed message.")
+(defgroup emh nil
+  "MIME Extension for mh-e"
+  :group 'mime
+  :group 'mh)
+
+(defcustom emh-automatic-mime-preview t
+  "*If non-nil, show MIME processed message."
+  :group 'emh
+  :type 'boolean)
 
-(defvar emh-decode-encoded-word t
-  "*If non-nil, decode encoded-word when it is not MIME preview mode.")
+(defcustom emh-decode-encoded-word t
+  "*If non-nil, decode encoded-word when it is not MIME preview mode."
+  :group 'emh
+  :type 'boolean)
 
 
 ;;; @ functions
@@ -93,19 +100,12 @@ nil, `emh-automatic-mime-preview' is used as default value."
                   (setq abuf (get-buffer-create aname))
                   (set-buffer abuf)
                   )
-                (as-binary-input-file
-                 (insert-file-contents msg-filename)
-                 ;; (goto-char (point-min))
-                 (while (re-search-forward "\r$" nil t)
-                   (replace-match "")
-                   )
-                 )
+                (insert-file-contents-as-raw-text msg-filename)
                 (set-buffer-modified-p nil)
                 (setq buffer-read-only t)
                 (setq buffer-file-name msg-filename)
                 (mh-show-mode)
-                (mime-view-mode nil nil nil
-                                aname (concat "show-" folder))
+                (mime-view-buffer aname (concat "show-" folder))
                 (goto-char (point-min))
                 )
             (let ((clean-message-header mh-clean-message-header)
@@ -194,7 +194,8 @@ With arg, turn MIME processing on if arg is positive."
 (defun emh-header-display ()
   (interactive)
   (mh-invalidate-show-buffer)
-  (let ((mime-view-ignored-field-regexp "^:$")
+  (let (mime-view-ignored-field-list
+       mime-view-visible-field-list
        emh-decode-encoded-word)
     (mh-header-display)
     ))
@@ -225,38 +226,31 @@ digest are inserted into the folder after that message."
 ;;; @ for mime-view
 ;;;
 
-(fset 'emh-text-decode-buffer
-      (symbol-function 'mime-text-decode-buffer))
+(set-alist 'mime-raw-representation-type-alist 'mh-show-mode 'binary)
 
-(set-alist 'mime-text-decoder-alist
-          'mh-show-mode
-          (function emh-text-decode-buffer))
 
-(defvar emh-content-header-filter-hook
-  (if window-system
-      '(emh-highlight-header)
-    )
+(defvar emh-display-header-hook (if window-system
+                                   '(emh-highlight-header)
+                                 )
   "Hook for header filtering.")
 
 (autoload 'emh-highlight-header "emh-face")
 
-(defun emh-content-header-filter ()
-  "Header filter for mime-view.
-It is registered to variable `mime-view-content-header-filter-alist'."
-  (goto-char (point-min))
-  (mime-view-cut-header)
-  (emh-text-decode-buffer default-mime-charset)
-  (eword-decode-header)
-  (run-hooks 'emh-content-header-filter-hook)
+(defun emh-header-presentation-method (entity situation)
+  (mime-insert-decoded-header
+   entity
+   mime-view-ignored-field-list mime-view-visible-field-list
+   default-mime-charset)
+  (run-hooks 'emh-display-header-hook)
   )
 
-(set-alist 'mime-view-content-header-filter-alist
-          'mh-show-mode
-          (function emh-content-header-filter))
+(set-alist 'mime-header-presentation-method-alist
+          'mh-show-mode #'emh-header-presentation-method)
+
 
 (defun emh-quitting-method ()
   (let ((buf (current-buffer)))
-    (mime-hide-echo-buffer)
+    (mime-maybe-hide-echo-buffer)
     (pop-to-buffer
      (let ((name (buffer-name buf)))
        (substring name 5)
@@ -267,12 +261,9 @@ It is registered to variable `mime-view-content-header-filter-alist'."
     (mh-show (mh-get-msg-num t))
     ))
 
-(set-alist 'mime-view-quitting-method-alist
-          'mh-show-mode
-          (function emh-quitting-method))
-(set-alist 'mime-view-show-summary-method
-          'mh-show-mode
-          (function emh-quitting-method))
+(set-alist 'mime-preview-quitting-method-alist
+          'mh-show-mode #'emh-quitting-method)
+
 
 (defun emh-following-method (buf)
   (save-excursion
@@ -288,40 +279,38 @@ It is registered to variable `mime-view-content-header-filter-alist'."
       (goto-char last)
       )))
 
-(set-alist 'mime-view-following-method-alist
-          'mh-show-mode
-          (function emh-following-method))
+(set-alist 'mime-preview-following-method-alist
+          'mh-show-mode #'emh-following-method)
 
 
 ;;; @@ for mime-partial
 ;;;
 
-(eval-after-load
-    "mime-view"
-  '(progn
-     (autoload 'mime-combine-message/partials-automatically
-       "mime-partial"
-       "Internal method to combine message/partial messages automatically.")
-     (set-atype 'mime-acting-condition
-               '((type . "message/partial")
-                 (method . mime-combine-message/partials-automatically)
-                 (major-mode . mh-show-mode)
-                 (summary-buffer-exp
-                  . (and (or (string-match "^article-\\(.+\\)$"
-                                           article-buffer)
-                             (string-match "^show-\\(.+\\)$" article-buffer))
-                         (substring article-buffer
-                                    (match-beginning 1) (match-end 1))
-                         ))
-                 ))
-     (set-alist 'mime-view-partial-message-method-alist
-               'mh-show-mode
-               (function
-                (lambda ()
-                  (let ((emh-automatic-mime-preview t))
-                    (emh-show)
-                    ))))
-     ))
+(autoload 'mime-combine-message/partial-pieces-automatically
+  "mime-partial"
+  "Internal method to combine message/partial messages automatically.")
+
+(mime-add-condition
+ 'action
+ '((type . message)(subtype . partial)
+   (method . mime-combine-message/partial-pieces-automatically)
+   (major-mode . mh-show-mode)
+   (summary-buffer-exp
+    . (and (or (string-match "^article-\\(.+\\)$"
+                            article-buffer)
+              (string-match "^show-\\(.+\\)$" article-buffer))
+          (substring article-buffer
+                     (match-beginning 1) (match-end 1))
+          ))
+   ))
+
+(set-alist 'mime-view-partial-message-method-alist
+          'mh-show-mode
+          (function
+           (lambda ()
+             (let ((emh-automatic-mime-preview t))
+               (emh-show)
+               ))))
 
 
 ;;; @ set up
@@ -340,8 +329,8 @@ It is registered to variable `mime-view-content-header-filter-alist'."
     (if buf
        (let ((the-buf (current-buffer)))
          (switch-to-buffer buf)
-         (if (and mime-view-buffer
-                  (setq buf (get-buffer mime-view-buffer))
+         (if (and mime-preview-buffer
+                  (setq buf (get-buffer mime-preview-buffer))
                   )
              (progn
                (switch-to-buffer the-buf)