+
+;;; @ 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-representation-type (entity)
+ (with-current-buffer (mime-entity-buffer entity)
+ (or mime-raw-representation-type
+ (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))
+
+(defsubst mime-entity-parent (entity &optional message-info)
+ "Return mother entity of ENTITY.
+If optional argument MESSAGE-INFO is not specified,
+`mime-message-structure' in buffer of ENTITY is used."
+ (mime-raw-find-entity-from-node-id
+ (cdr (mime-entity-node-id entity))
+ (or message-info
+ (save-excursion
+ (set-buffer (mime-entity-buffer entity))
+ mime-message-structure))))
+
+(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
+ (set-buffer (mime-entity-buffer entity))
+ major-mode)))
+ ))
+
+
+(defvar mime-view-uuencode-encoding-name-list '("x-uue" "x-uuencode"))
+
+(defun mime-entity-uu-filename (entity)
+ (if (member (mime-entity-encoding entity)
+ mime-view-uuencode-encoding-name-list)
+ (save-excursion
+ (set-buffer (mime-entity-buffer entity))
+ (goto-char (mime-entity-body-start entity))
+ (if (re-search-forward "^begin [0-9]+ "
+ (mime-entity-body-end entity) t)
+ (if (looking-at ".+$")
+ (buffer-substring (match-beginning 0)(match-end 0))
+ )))))
+
+(defun mime-entity-filename (entity)
+ (or (mime-entity-uu-filename entity)
+ (mime-content-disposition-filename
+ (mime-entity-content-disposition entity))
+ (cdr (let ((param (mime-content-type-parameters
+ (mime-entity-content-type entity))))
+ (or (assoc "name" param)
+ (assoc "x-name" param))
+ ))))
+
+(defun mime-view-entity-title (entity)
+ (or (mime-entity-read-field entity 'Content-Description)
+ (mime-entity-read-field entity 'Subject)
+ (mime-entity-filename entity)
+ ""))
+
+