Update.
[elisp/semi.git] / mime-play.el
index aa025df..70fb849 100644 (file)
@@ -240,6 +240,7 @@ 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 (method ret)
+    (in-calist-package 'mime-view)
     (setq ret
          (mime-delq-null-situation
           (ctree-find-calist mime-acting-condition
@@ -383,33 +384,46 @@ Otherwise `mime-show-echo-buffer' uses it as height of mime-echo
 window.")
 
 (defun mime-show-echo-buffer (&rest forms)
-  "Show mime-echo buffer to display MIME-playing information."
+  "Show mime-echo buffer to display MIME-playing information.
+It returns the list of window, start and end positions of inserted text.
+A window height of the buffer `mime-echo-buffer-name' will be determined
+by `mime-echo-window-height' (its value or its return value) whenever
+this function is called."
   (get-buffer-create mime-echo-buffer-name)
   (let ((the-win (selected-window))
-       (win (get-buffer-window mime-echo-buffer-name)))
-    (unless win
+       (win (get-buffer-window mime-echo-buffer-name))
+       (height (if (functionp mime-echo-window-height)
+                   (funcall mime-echo-window-height)
+                 mime-echo-window-height))
+       start)
+    (if win
+       (progn
+         (select-window win)
+         (enlarge-window (- height (window-height)))
+         )
       (unless (and mime-echo-window-is-shared-with-bbdb
                   (condition-case nil
-                      (setq win (get-buffer-window bbdb-buffer-name))
+                      (select-window
+                       (setq win (get-buffer-window bbdb-buffer-name))
+                       )
                     (error nil)))
        (select-window (get-buffer-window (or mime-preview-buffer
                                              (current-buffer))))
-       (setq win (split-window-vertically
-                  (- (window-height)
-                     (if (functionp mime-echo-window-height)
-                         (funcall mime-echo-window-height)
-                       mime-echo-window-height)
-                     )))
-       )
-      (set-window-buffer win mime-echo-buffer-name)
-      )
-    (select-window win)
-    (goto-char (point-max))
+       (let ((window-min-height 1))
+         (setq win (split-window-vertically (- (window-height) height)))
+         )
+       (set-window-buffer win mime-echo-buffer-name)
+       (select-window win)
+       ))
+    (goto-char (setq start (point-max)))
     (if forms
-       (insert (apply (function format) forms))
-      )
-    (select-window the-win)
-    ))
+       (let ((buffer-read-only nil))
+         (insert (apply (function format) forms))
+         ))
+    (prog1
+       (list win start (point))
+      (select-window the-win)
+      )))
 
 
 ;;; @ file name
@@ -545,7 +559,6 @@ It is registered to variable `mime-preview-quitting-method-alist'."
 ;;;
 
 (defun mime-store-message/partial-piece (entity cal)
-  (goto-char (mime-entity-point-min entity))
   (let* ((root-dir
          (expand-file-name
           (concat "m-prts-" (user-login-name)) temporary-file-directory))
@@ -553,7 +566,7 @@ It is registered to variable `mime-preview-quitting-method-alist'."
         (number (cdr (assoc "number" cal)))
         (total (cdr (assoc "total" cal)))
         file
-        (mother mime-preview-buffer)
+        (mother (current-buffer))
         )
     (or (file-exists-p root-dir)
        (make-directory root-dir)