(mime-entity-situation): Add information of Content-Disposition.
[elisp/semi.git] / mime-view.el
index bcd0595..04ddfe3 100644 (file)
   :type 'file)
 
 
-;;; @ buffer local variables
-;;;
-
-;;; @@ in raw-buffer
+;;; @ in raw-buffer (representation space)
 ;;;
 
 (defvar mime-raw-message-info nil
@@ -121,27 +118,6 @@ This value is overridden by buffer local variable
 `mime-raw-representation-type' if it is not nil.")
 
 
-;;; @@ in preview-buffer
-;;;
-
-(defvar mime-mother-buffer nil
-  "Mother buffer corresponding with the (MIME-preview) buffer.
-If current MIME-preview buffer is generated by other buffer, such as
-message/partial, it is called `mother-buffer'.")
-(make-variable-buffer-local 'mime-mother-buffer)
-
-(defvar mime-raw-buffer nil
-  "Raw buffer corresponding with the (MIME-preview) buffer.")
-(make-variable-buffer-local 'mime-raw-buffer)
-
-(defvar mime-preview-original-window-configuration nil
-  "Window-configuration before mime-view-mode is called.")
-(make-variable-buffer-local 'mime-preview-original-window-configuration)
-
-
-;;; @ entity information
-;;;
-
 (defsubst mime-raw-find-entity-from-node-id (entity-node-id
                                             &optional message-info)
   "Return entity from ENTITY-NODE-ID in mime-raw-buffer.
@@ -186,6 +162,43 @@ If optional argument MESSAGE-INFO is not specified,
          message-info))))
 
 
+;;; @ in preview-buffer (presentation space)
+;;;
+
+(defvar mime-mother-buffer nil
+  "Mother buffer corresponding with the (MIME-preview) buffer.
+If current MIME-preview buffer is generated by other buffer, such as
+message/partial, it is called `mother-buffer'.")
+(make-variable-buffer-local 'mime-mother-buffer)
+
+(defvar mime-raw-buffer nil
+  "Raw buffer corresponding with the (MIME-preview) buffer.")
+(make-variable-buffer-local 'mime-raw-buffer)
+
+(defvar mime-preview-original-window-configuration nil
+  "Window-configuration before mime-view-mode is called.")
+(make-variable-buffer-local 'mime-preview-original-window-configuration)
+
+(defun mime-preview-original-major-mode (&optional recursive)
+  "Return major-mode of original buffer.
+If optional argument RECURSIVE is non-nil and current buffer has
+mime-mother-buffer, it returns original major-mode of the
+mother-buffer."
+  (if (and recursive mime-mother-buffer)
+      (save-excursion
+       (set-buffer mime-mother-buffer)
+       (mime-preview-original-major-mode recursive)
+       )
+    (save-excursion
+      (set-buffer
+       (mime-entity-buffer
+       (get-text-property (point-min) 'mime-view-entity)))
+      major-mode)))
+
+
+;;; @ entity information
+;;;
+
 (defsubst mime-entity-parent (entity &optional message-info)
   "Return mother entity of ENTITY.
 If optional argument MESSAGE-INFO is not specified,
@@ -197,10 +210,30 @@ If optional argument MESSAGE-INFO is not specified,
         (set-buffer (mime-entity-buffer entity))
         mime-raw-message-info))))
 
-(defsubst mime-entity-situation (entity)
+(defun mime-entity-situation (entity)
   "Return situation of ENTITY."
   (append (or (mime-entity-content-type entity)
              (make-mime-content-type 'text 'plain))
+         (let ((d (mime-entity-content-disposition entity)))
+           (cons (cons 'disposition-type
+                       (mime-content-disposition-type d))
+                 (mapcar (function
+                          (lambda (param)
+                            (let ((name (car param)))
+                              (cons (cond ((string= name "filename")
+                                           'filename)
+                                          ((string= name "creation-date")
+                                           'creation-date)
+                                          ((string= name "modification-date")
+                                           'modification-date)
+                                          ((string= name "read-date")
+                                           'read-date)
+                                          ((string= name "size")
+                                           'size)
+                                          (t (cons 'disposition (car param))))
+                                    (cdr param)))))
+                         (mime-content-disposition-parameters d))
+                 ))
          (list (cons 'encoding (mime-entity-encoding entity))
                (cons 'major-mode
                      (save-excursion
@@ -898,7 +931,6 @@ The compressed face will be piped to this command.")
             ))
       (setq ne (point-max))
       (widen)
-      (put-text-property nb ne 'mime-view-raw-buffer raw-buffer)
       (put-text-property nb ne 'mime-view-entity entity)
       (goto-char ne)
       (if children
@@ -1162,21 +1194,6 @@ It decodes current entity to call internal or external method as
 ;;; @@ following
 ;;;
 
-(defun mime-preview-original-major-mode (&optional recursive)
-  "Return major-mode of original buffer.
-If a current buffer has mime-mother-buffer, return original major-mode
-of the mother-buffer."
-  (if (and recursive mime-mother-buffer)
-      (save-excursion
-       (set-buffer mime-mother-buffer)
-       (mime-preview-original-major-mode recursive)
-       )
-    (save-excursion
-      (set-buffer
-       (mime-entity-buffer
-       (get-text-property (point-min) 'mime-view-entity)))
-      major-mode)))
-
 (defun mime-preview-follow-current-entity ()
   "Write follow message to current entity.
 It calls following-method selected from variable