* mime-play.el (mime-save-content-for-broken-message): New function.
+2000-01-31  Yoshiki Hayashi  <t90553@mail.ecc.u-tokyo.ac.jp>
+
+       * EMY 1.13.1 is released.
+
+2000-01-31 Yoshiki Hayashi  <yoshiki@xemacs.org>
+
+       * emy.texi: Describe how to deal with broken message.
+
+2000-01-31 Yoshiki Hayashi  <yoshiki@xemacs.org>
+
+       * mime-play.el (mime-save-content-for-broken-message): New function.
+
+2000-01-28  Yoshiki Hayashi  <yoshiki@xemacs.org>
+
+       * mime-view.el (mime-display-entity): Clean up code.
+
 2000-01-28  Yoshiki Hayashi  <yoshiki@xemacs.org>
 
        * mime-view.el (mime-display-entity): Fix handling of
-       inline Content-Disposition.
+       inline parameter of Content-Disposition.
 
 2000-01-20  Yoshiki Hayashi  <t90553@mail.ecc.u-tokyo.ac.jp>
 
 
 PACKAGEDIR = NONE
 VERSION_SPECIFIC_LISPDIR = NONE
 
-GOMI   = *.elc
+GOMI   = *.elc *.info
 
 VERSION        = $(API).$(RELEASE)
 ARC_DIR = /pub/mule/semi/semi-$(API)-for-flim-$(FLIM_API)
 
+all: elc
 
 elc:
        $(EMACS) $(FLAGS) -f compile-semi \
        $(XEMACS) $(FLAGS) -f install-semi-package $(PACKAGEDIR)
 
 
+info:
+       makeinfo -o emy.info emy.texi
+
 clean:
        -$(RM) $(GOMI)
 
 
 \input texinfo.tex              @c -*- texinfo -*-
 
-@setfilename emy
+@setfilename emy.info
 
 @set VERSION 1.13
 
 Right now only differences between SEMI and EMY are documented.
 
 @menu
-* Manipulating an Entity::     Changing representation of the part
+* Manipulating an Entity::      Changing representation of the part
 * Changing Entity Button::      Where to add button indicating that entity.
 * Adding Buttons::              Where you want to see buttons.
+* How to deal with broken MUA:: Some MUA sends totally broken messages.
 @end menu
 
 @node Manipulating an Entity
 This means you will have buttons around message/* and
 multipart/alternative, and before application/*.
 
+@node How to deal with broken MUA
+@section Illegal MIME messages
+
+Some MUAs send totally broken MIME messages.  According to the standard,
+it's perfectly fine for EMY not to grok those message.  However, EMY
+tries to extract as much information as possible.  Here's some functions
+that might help you.
+
+Some MUAs localized to Japanese sends these strings as a filename
+parameter of Content-Disposition.
+
+@example
+=?ISO-2022-JP?B?GyRCRnxLXDhsGyhC?=
+@end example
+
+It looks like encoded-words. This usage is strictly prohibited by RFC
+2047.  Instead, you should use mechanism described in RFC 2231.
+If you really want to ``decode'' it when saving it to file, you can use
+something like this.
+
+@lisp
+(mime-add-condition
+ 'action
+ '((mode . "extract")
+   (method . mime-save-content-for-broken-message)))
+@end lisp
+
+Unfortunately, there's no easy way to customize looking of buttons.
+It's on EMY's TODO list.
+
+If you are desperate, you can redefine
+@code{mime-view-insert-entity-button}.
+
+@lisp
+(defun mime-view-insert-entity-button (entity &optional body-is-invisible)
+  "Insert entity-button of ENTITY."
+  (let ((entity-node-id (mime-entity-node-id entity))
+       (params (mime-entity-parameters entity))
+       (subject (eword-decode-string (mime-view-entity-title entity))))
+    (mime-insert-button
+     (concat
+      (let ((access-type (assoc "access-type" params))
+           (num (or (cdr (assoc "x-part-number" params))
+                    (if (consp entity-node-id)
+                        (mapconcat (function
+                                    (lambda (num)
+                                      (format "%s" (1+ num))))
+                                   (reverse entity-node-id) ".")
+                      "0"))))
+       (cond (access-type
+              (let ((server (assoc "server" params)))
+                (setq access-type (cdr access-type))
+                (if server
+                    (format "%s %s ([%s] %s)"
+                            num subject access-type (cdr server))
+                  (let ((site (cdr (assoc "site" params)))
+                        (dir (cdr (assoc "directory" params)))
+                        (url (cdr (assoc "url" params))))
+                    (if url
+                        (format "%s %s ([%s] %s)"
+                                num subject access-type url)
+                      (format "%s %s ([%s] %s:%s)"
+                              num subject access-type site dir))))))
+             (t
+              (let ((media-type (mime-entity-media-type entity))
+                    (media-subtype (mime-entity-media-subtype entity))
+                    (charset (cdr (assoc "charset" params)))
+                    (encoding (mime-entity-encoding entity)))
+                (concat
+                 num " " subject
+                 (let ((rest
+                        (format " <%s/%s%s%s>"
+                                media-type media-subtype
+                                (if charset
+                                    (concat "; " charset)
+                                  "")
+                                (if encoding
+                                    (concat " (" encoding ")")
+                                  ""))))
+                   (if (>= (+ (current-column)(length rest))(window-width))
+                       "\n\t")
+                   rest))))))
+      (if body-is-invisible
+         " ..."
+       ""))
+     (function mime-preview-play-current-entity))))
+@end lisp
+
+@strong{Note:} These settings are unsupported until better way is
+implemented.
+
 @node MIME-Edit
-@chapter Composing MIME messages.
+@chapter Composing MIME messages
 
 @vindex mime-edit-attach-at-end-type (MIME-Edit)
 When you are editing MIME message, you might want to insert some part at
 
 (require 'mime-view)
 (require 'alist)
 (require 'filename)
+(require 'eword-decode)
 
 (eval-when-compile
   (condition-case nil
     (if (file-exists-p filename)
        (or (yes-or-no-p (format "File %s exists. Save anyway? " filename))
            (error "")))
-    (mime-write-entity-content entity (expand-file-name filename))
-    ))
+    (mime-write-entity-content entity (expand-file-name filename))))
 
+(defun mime-save-content-for-broken-message (entity situation)
+  (let ((name (or (and (mime-entity-filename entity)
+                      (eword-decode-string
+                       (mime-entity-filename entity)))
+                 (format "%s" (mime-entity-media-type entity))))
+       (dir (if (eq t mime-save-directory)
+                default-directory
+              mime-save-directory))
+       filename)
+    (setq filename (read-file-name
+                   (concat "File name: (default "
+                           (file-name-nondirectory name) ") ")
+                   dir
+                   (concat (file-name-as-directory dir)
+                           (file-name-nondirectory name))))
+    (if (file-directory-p filename)
+       (setq filename (concat (file-name-as-directory filename)
+                              (file-name-nondirectory name))))
+    (if (file-exists-p filename)
+       (or (yes-or-no-p (format "File %s exists. Save anyway? " filename))
+           (error "")))
+    (mime-write-entity-content entity (expand-file-name filename))))
 
 ;;; @ file detection
 ;;;
 
 ;;; @@@ predicate function
 ;;;
 
-;; fix flim
+;; #### fix flim
 (defun mime-view-entity-type/subtype (entity)
   (if (not (mime-entity-media-type entity))
       'text/plain
      ;; When previous entity exists
      (and prev-entity
          (or
-          ;; Check previous eneity
+          ;; Check previous entity
           ;; type/subtype
           (memq (cdr
                  (assq
                     (if (consp entity-node-id)
                         (mapconcat (function
                                     (lambda (num)
-                                      (format "%s" (1+ num))
-                                      ))
+                                      (format "%s" (1+ num))))
                                    (reverse entity-node-id) ".")
-                      "0"))
-                ))
+                      "0"))))
        (cond (access-type
               (let ((server (assoc "server" params)))
                 (setq access-type (cdr access-type))
                             num subject access-type (cdr server))
                   (let ((site (cdr (assoc "site" params)))
                         (dir (cdr (assoc "directory" params)))
-                        (url (cdr (assoc "url" params)))
-                        )
+                        (url (cdr (assoc "url" params))))
                     (if url
                         (format "%s %s ([%s] %s)"
                                 num subject access-type url)
                       (format "%s %s ([%s] %s:%s)"
-                              num subject access-type site dir))
-                    )))
-              )
+                              num subject access-type site dir))))))
              (t
               (let ((media-type (mime-entity-media-type entity))
                     (media-subtype (mime-entity-media-subtype entity))
                                   ""))))
                    (if (>= (+ (current-column)(length rest))(window-width))
                        "\n\t")
-                   rest)))
-              )))
+                   rest))))))
       (if body-is-invisible
          " ..."
        ""))
-     (function mime-preview-play-current-entity))
-    ))
+     (function mime-preview-play-current-entity))))
 
 
 ;;; @@ entity-header
           (children (mime-entity-children entity)))
       ;; Check if attachment is specified.
       ;; if inline is forced or not.
-      (if (not (or (eq t mime-view-force-inline-types)
-                  (memq (mime-entity-media-type entity)
-                        mime-view-force-inline-types)
-                  (memq (mime-view-entity-type/subtype entity)
+      (unless (or (eq t mime-view-force-inline-types)
+                 (memq (mime-entity-media-type entity)
+                       mime-view-force-inline-types)
+                 (memq (mime-view-entity-type/subtype entity)
                         mime-view-force-inline-types)
                   ;; whether Content-Disposition header exists.
-                  ;; #### FIXME.  This is way too ugly.
-                  (not (and
-                        (mime-entity-content-disposition entity)
-                        (not (eq 'inline
-                                 (mime-content-disposition-type
-                                  (mime-entity-content-disposition entity))))))))
-         ;; This is attachment
-         (setq header-is-visible nil
-               body-is-visible nil))
+                 (not (mime-entity-content-disposition entity))
+                 (eq 'inline
+                     (mime-content-disposition-type
+                      (mime-entity-content-disposition entity))))
+       ;; This is attachment
+       (setq header-is-visible nil
+             body-is-visible nil))
       (set-buffer preview-buffer)
       (setq nb (point))
       (save-restriction
 
 
 (require 'custom)
 
-(defconst mime-user-interface-product ["EMY" (1 13 0) "No pain no gain"]
+(defconst mime-user-interface-product ["EMY" (1 13 1) "Haste makes waste"]
   "Product name, version number and code name of MIME-kernel package.")
 
 (autoload 'mule-caesar-region "mule-caesar"