- (interactive)
- (or mode
- (setq mode "play")
- )
- (let ((cinfo (get-text-property (point) 'mime-view-cinfo)))
- (if cinfo
- (let ((the-buf (current-buffer))
- (raw-buffer (get-text-property (point) 'mime-view-raw-buffer))
- )
- (setq mime-preview-after-decoded-position (point))
- (set-buffer raw-buffer)
- (mime-playback-entity cinfo mode)
- (if (eq (current-buffer) raw-buffer)
- (progn
- (set-buffer the-buf)
- (goto-char mime-preview-after-decoded-position)
- ))
- ))))
-
-(defun mime-playback-entity (cinfo &optional mode)
- (let ((beg (mime-entity-info-point-min cinfo))
- (end (mime-entity-info-point-max cinfo))
- (c-type (mime-entity-info-media-type cinfo))
- (c-subtype (mime-entity-info-media-subtype cinfo))
- (params (mime-entity-info-parameters cinfo))
- (encoding (mime-entity-info-encoding cinfo))
- )
- (or c-type
- (setq c-type 'text
- c-subtype 'plain))
- ;; Check for VM
- (if (< beg (point-min))
- (setq beg (point-min))
- )
- (if (< (point-max) end)
- (setq end (point-max))
- )
- (let (method cal ret)
- (setq cal (list* (cons 'type c-type)
- (cons 'subtype c-subtype)
- (cons 'encoding encoding)
- (cons 'major-mode major-mode)
- params))
- (if mode
- (setq cal (cons (cons 'mode mode) cal))
- )
- (setq ret (mime/get-content-decoding-alist cal))
- (setq method (cdr (assq 'method ret)))
- (cond ((and (symbolp method)
- (fboundp method))
- (funcall method beg end ret)
- )
- ((and (listp method)(stringp (car method)))
- (mime-activate-external-method beg end ret)
- )
- (t
- (mime-show-echo-buffer
- "No method are specified for %s\n" ctype)
- ))
- )
- ))
-
-
-;;; @ method selector
-;;;
-
-(defun mime/get-content-decoding-alist (al)
- (get-unified-alist mime-acting-condition al)
- )
+ (interactive "P")
+ (let ((entity (get-text-property (point) 'mime-view-entity)))
+ (if entity
+ (let ((situation
+ (get-text-property (point) 'mime-view-situation)))
+ (or mode
+ (setq mode "play"))
+ (setq situation
+ (if (assq 'mode situation)
+ (put-alist 'mode mode (copy-alist situation))
+ (cons (cons 'mode mode)
+ situation)))
+ (if ignore-examples
+ (setq situation
+ (cons (cons 'ignore-examples ignore-examples)
+ situation)))
+ (mime-play-entity entity situation)))))
+
+;;;###autoload
+(defun mime-play-entity (entity &optional situation ignored-method)
+ "Play entity specified by ENTITY.
+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* ((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)
+ (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))))
+ (setq method (cdr (assq 'method ret)))
+ (cond ((and (symbolp method)
+ (fboundp method))
+ (funcall method entity ret))
+ ((stringp method)
+ (mime-activate-mailcap-method entity ret))
+ ;; ((and (listp method)(stringp (car method)))
+ ;; (mime-activate-external-method entity ret)
+ ;; )
+ (t
+ (mime-show-echo-buffer "No method is specified for %s\n"
+ (mime-type/subtype-string
+ (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))))))