Abolish `mime-entity-cooked-p'; use `mime-entity-cooked-p' of FLIM.
authormorioka <morioka>
Sun, 28 Jun 1998 20:06:44 +0000 (20:06 +0000)
committermorioka <morioka>
Sun, 28 Jun 1998 20:06:44 +0000 (20:06 +0000)
(mime-view-buffer): New optional argument `representation-type'; use
`mime-open-entity'.
(mime-view-mode): New implementation.

mime-view.el

index 1e0fe3f..0fb973d 100644 (file)
@@ -156,9 +156,6 @@ mother-buffer."
        (cdr (or (assq major-mode mime-raw-representation-type-alist)
                 (assq t mime-raw-representation-type-alist))))))
 
-(defsubst mime-entity-cooked-p (entity)
-  (eq (mime-entity-representation-type entity) 'cooked))
-
 (defun mime-entity-situation (entity)
   "Return situation of ENTITY."
   (append (or (mime-entity-content-type entity)
@@ -918,10 +915,33 @@ MEDIA-TYPE must be (TYPE . SUBTYPE), TYPE or t.  t means default."
       )))
 
 (defun mime-view-buffer (&optional raw-buffer preview-buffer mother
-                                  default-keymap-or-function)
+                                  default-keymap-or-function
+                                  representation-type)
+  "View RAW-BUFFER in MIME-View mode.
+Optional argument PREVIEW-BUFFER is either nil or a name of preview
+buffer.
+Optional argument DEFAULT-KEYMAP-OR-FUNCTION is nil, keymap or
+function.  If it is a keymap, keymap of MIME-View mode will be added
+to it.  If it is a function, it will be bound as default binding of
+keymap of MIME-View mode.
+Optional argument REPRESENTATION-TYPE is representation-type of
+message.  It must be nil, `binary' or `cooked'.  If it is nil,
+`binary' is used as default."
   (interactive)
+  (or raw-buffer
+      (setq raw-buffer (current-buffer)))
+  (or representation-type
+      (setq representation-type
+           (save-excursion
+             (set-buffer raw-buffer)
+             (cdr (or (assq major-mode mime-raw-representation-type-alist)
+                      (assq t mime-raw-representation-type-alist)))
+             )))
+  (if (eq representation-type 'binary)
+      (setq representation-type 'buffer)
+    )
   (mime-display-message
-   (mime-parse-buffer raw-buffer)
+   (mime-open-entity representation-type raw-buffer)
    preview-buffer mother default-keymap-or-function))
 
 (defun mime-view-mode (&optional mother ctl encoding
@@ -950,17 +970,27 @@ button-2  Move to point under the mouse cursor
                and decode current content as `play mode'
 "
   (interactive)
-  (let ((message
-        (save-excursion
-          (if raw-buffer (set-buffer raw-buffer))
-          (or mime-view-redisplay
-              (setq mime-message-structure (mime-parse-message ctl)))
-          )))
-    (or (mime-entity-encoding message)
-       (mime-entity-set-encoding-internal message encoding))
-    (mime-display-message message preview-buffer
-                         mother default-keymap-or-function)
-    ))
+  (unless mime-view-redisplay
+    (save-excursion
+      (if raw-buffer (set-buffer raw-buffer))
+      (let ((type
+            (cdr
+             (or (assq major-mode mime-raw-representation-type-alist)
+                 (assq t mime-raw-representation-type-alist)))))
+       (if (eq type 'binary)
+           (setq type 'buffer)
+         )
+       (setq mime-message-structure (mime-open-entity type raw-buffer))
+       (or (mime-entity-content-type mime-message-structure)
+           (mime-entity-set-content-type-internal
+            mime-message-structure ctl))
+       )
+      (or (mime-entity-encoding mime-message-structure)
+         (mime-entity-set-encoding-internal mime-message-structure encoding))
+      ))
+  (mime-display-message mime-message-structure preview-buffer
+                       mother default-keymap-or-function)
+  )
 
 
 ;;; @@ playing