update.
[elisp/emh.git] / emh.el
diff --git a/emh.el b/emh.el
index 880940a..ae51877 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.12 $
 ;; Keywords: MH, MIME, multimedia, encoded-word, multilingual, mail
 
 ;; This file is part of emh.
 
 (require 'mh-e)
 (require 'mime-view)
+(or (get-unified-alist mime-acting-condition '((type . text)))
+    (error "Please install latest SEMI."))
+(eval-when-compile (require 'mime-text))
 
 
 ;;; @ version
 ;;;
 
-(defconst emh-RCS-ID
-  "$Id: emh.el,v 0.12 1997-03-18 12:47:58 morioka Exp $")
-
-(defconst emh-version (get-version-string emh-RCS-ID))
+(defconst emh-version "1.2.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,13 +101,9 @@ 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 "")
-                   )
-                 )
+                (let ((coding-system-for-read 'raw-text))
+                  (insert-file-contents msg-filename)
+                  )
                 (set-buffer-modified-p nil)
                 (setq buffer-read-only t)
                 (setq buffer-file-name msg-filename)
@@ -177,9 +181,9 @@ With arg, turn MIME processing on if arg is positive."
   (save-excursion
     (set-buffer mh-show-buffer)
     (if (null emh-automatic-mime-preview)
-       (if (and mime::preview/article-buffer
-                (get-buffer mime::preview/article-buffer))
-           (kill-buffer mime::preview/article-buffer)
+       (if (and mime-raw-buffer
+                (get-buffer mime-raw-buffer))
+           (kill-buffer mime-raw-buffer)
          )))
   (mh-invalidate-show-buffer)
   (mh-show (mh-get-msg-num t))
@@ -225,12 +229,11 @@ 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-buffer-coding-system-alist
+          'mh-show-mode 'no-conversion)
 
 (set-alist 'mime-text-decoder-alist
-          'mh-show-mode
-          (function emh-text-decode-buffer))
+          'mh-show-mode 'mime-text-decode-buffer)
 
 (defvar emh-content-header-filter-hook
   (if window-system
@@ -245,8 +248,7 @@ digest are inserted into the folder after that message."
 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)
+  (eword-decode-header default-mime-charset)
   (run-hooks 'emh-content-header-filter-hook)
   )
 
@@ -255,13 +257,8 @@ It is registered to variable `mime-view-content-header-filter-alist'."
           (function emh-content-header-filter))
 
 (defun emh-quitting-method ()
-  (let ((win (get-buffer-window
-             mime/output-buffer-name))
-       (buf (current-buffer))
-       )
-    (if win
-       (delete-window win)
-      )
+  (let ((buf (current-buffer)))
+    (mime-maybe-hide-echo-buffer)
     (pop-to-buffer
      (let ((name (buffer-name buf)))
        (substring name 5)
@@ -272,9 +269,8 @@ 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-preview-quitting-method-alist
+          'mh-show-mode #'emh-quitting-method)
 (set-alist 'mime-view-show-summary-method
           'mh-show-mode
           (function emh-quitting-method))
@@ -301,29 +297,30 @@ It is registered to variable `mime-view-content-header-filter-alist'."
 ;;; @@ for mime-partial
 ;;;
 
-(call-after-loaded
- 'mime-partial
- (function
-  (lambda ()
-    (set-atype 'mime/content-decoding-condition
-              '((type . "message/partial")
-                (method . mime-article/grab-message/partials)
-                (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-method-to-combine-message/partial-pieces
+  "mime-partial"
+  "Internal method to combine message/partial messages automatically.")
+
+(set-atype 'mime-acting-condition
+          '((type . message)(subtype . partial)
+            (method . mime-method-to-combine-message/partial-pieces)
+            (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
@@ -342,8 +339,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::article/preview-buffer
-                  (setq buf (get-buffer mime::article/preview-buffer))
+         (if (and mime-preview-buffer
+                  (setq buf (get-buffer mime-preview-buffer))
                   )
              (progn
                (switch-to-buffer the-buf)
@@ -354,49 +351,12 @@ It is registered to variable `mime-view-content-header-filter-alist'."
          ))))
 
 (add-hook 'mh-before-quit-hook (function emh-summary-before-quit))
-            
-
-;;; @@ for emh-comp.el
-;;;
-
-(autoload 'emh-edit-again "emh-comp"
-  "Clean-up a draft or a message previously sent and make it resendable." t)
-(autoload 'emh-extract-rejected-mail "emh-comp"
-  "Extract a letter returned by the mail system and make it re-editable." t)
-(autoload 'emh-forward "emh-comp"
-  "Forward a message or message sequence by MIME style." t)
-
-(call-after-loaded
- 'mime-setup
- (function
-  (lambda ()
-    (substitute-key-definition
-     'mh-edit-again 'emh-edit-again mh-folder-mode-map)
-    (substitute-key-definition
-     'mh-extract-rejected-mail 'emh-extract-rejected-mail
-     mh-folder-mode-map)
-    (substitute-key-definition
-     'mh-forward 'emh-forward mh-folder-mode-map)
-
-    (call-after-loaded
-     'mh-comp
-     (function
-      (lambda ()
-       (require 'emh-comp)
-       ))
-     'mh-letter-mode-hook)
-    )))
 
 
 ;;; @ for BBDB
 ;;;
 
-(call-after-loaded
- 'bbdb
- (function
-  (lambda ()
-    (require 'mime-bbdb)
-    )))
+(eval-after-load "bbdb" '(require 'mime-bbdb))
 
 
 ;;; @ end