Synch with the semi-1_14 branch.
[elisp/semi.git] / mime-play.el
index ff06bbf..d53ee2f 100644 (file)
@@ -45,6 +45,9 @@ If t, it means current directory."
 (defvar mime-play-find-every-situations t
   "*Find every available situations if non-nil.")
 
+(defvar mime-play-messages-coding-system nil
+  "Coding system to be used for external MIME playback method.")
+
 
 ;;; @ content decoder
 ;;;
@@ -81,27 +84,26 @@ If MODE is specified, play as it.  Default MODE is \"play\"."
 It decodes the entity to call internal or external method.  The method
 is selected from variable `mime-acting-condition'.  If MODE is
 specified, play as it.  Default MODE is \"play\"."
-  (let ((ret
-        (mime-unify-situations (mime-entity-situation entity situation)
-                               mime-acting-condition
-                               mime-acting-situation-example-list
-                               'method ignored-method
-                               mime-play-find-every-situations))
-       method)
+  (let* ((entity-situation (mime-entity-situation entity situation))
+        (ret (mime-unify-situations entity-situation
+                                    mime-acting-condition
+                                    mime-acting-situation-example-list
+                                    'method ignored-method
+                                    mime-play-find-every-situations))
+        method menu s)
     (setq mime-acting-situation-example-list (cdr ret)
          ret (car ret))
     (cond ((cdr ret)
-          (setq ret (mime-popup-menu-select
-                     (cons 
-                      "Methods"
-                      (mapcar
-                       (lambda (situation)
-                         (vector
-                          (format "%s"
-                                  (cdr (assq 'method situation)))
-                          situation t))
-                       ret))))
-          (setq ret (mime-sort-situation ret))
+          (while ret
+            (or (vassoc (setq method
+                              (format "%s"
+                                      (cdr (assq 'method
+                                                 (setq s (pop ret))))))
+                        menu)
+                (push (vector method s t) menu)))
+          (setq ret (mime-sort-situation
+                     (mime-menu-select "Play entity with: "
+                                       (cons "Methods" menu))))
           (add-to-list 'mime-acting-situation-example-list (cons ret 0)))
          (t
           (setq ret (car ret))))
@@ -115,12 +117,13 @@ specified, play as it.  Default MODE is \"play\"."
           ;;  (mime-activate-external-method entity ret)
           ;;  )
          (t
-          (mime-show-echo-buffer "No method are specified for %s\n"
+          (mime-show-echo-buffer "No method is specified for %s\n"
                                  (mime-type/subtype-string
-                                  (cdr (assq 'type situation))
-                                  (cdr (assq 'subtype situation))))
-          (if (y-or-n-p "Do you want to save current entity to disk?")
-              (mime-save-content entity situation))))))
+                                  (cdr (assq 'type entity-situation))
+                                  (cdr (assq 'subtype entity-situation))))
+          (when (y-or-n-p "Do you want to save current entity to disk?")
+            (message "")
+            (mime-save-content entity entity-situation))))))
 
 
 ;;; @ external decoder
@@ -143,8 +146,10 @@ specified, play as it.  Default MODE is \"play\"."
                  (mime-format-mailcap-command
                   method
                   (cons (cons 'filename name) situation))))
-            (start-process command mime-echo-buffer-name
-                           shell-file-name shell-command-switch command))))
+            (binary-to-text-funcall
+             mime-play-messages-coding-system
+             #'start-process command mime-echo-buffer-name
+             shell-file-name shell-command-switch command))))
       (set-alist 'mime-mailcap-method-filename-alist process name)
       (set-process-sentinel process 'mime-mailcap-method-sentinel))))