+(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,
+`mime-raw-message-info' 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-raw-message-info))))
+
+(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-raw-get-uu-filename ()
+ (save-excursion
+ (if (re-search-forward "^begin [0-9]+ " nil t)
+ (if (looking-at ".+$")
+ (buffer-substring (match-beginning 0)(match-end 0))
+ ))))
+
+(defun mime-raw-get-subject (entity)
+ (or (std11-find-field-body '("Content-Description" "Subject"))
+ (let ((ret (mime-entity-content-disposition entity)))
+ (and ret
+ (setq ret (mime-content-disposition-filename ret))
+ (std11-strip-quoted-string ret)
+ ))
+ (let ((ret (mime-entity-content-type entity)))
+ (and ret
+ (setq ret
+ (cdr
+ (let ((param (mime-content-type-parameters ret)))
+ (or (assoc "name" param)
+ (assoc "x-name" param))
+ )))
+ (std11-strip-quoted-string ret)
+ ))
+ (if (member (mime-entity-encoding entity)
+ mime-view-uuencode-encoding-name-list)
+ (mime-raw-get-uu-filename))
+ ""))
+
+
+(defsubst mime-raw-point-to-entity-node-id (point &optional message-info)
+ "Return entity-node-id from POINT in mime-raw-buffer.
+If optional argument MESSAGE-INFO is not specified,
+`mime-raw-message-info' is used."
+ (mime-entity-node-id (mime-raw-find-entity-from-point point message-info)))
+
+(defsubst mime-raw-point-to-entity-number (point &optional message-info)
+ "Return entity-number from POINT in mime-raw-buffer.
+If optional argument MESSAGE-INFO is not specified,
+`mime-raw-message-info' is used."
+ (mime-entity-number (mime-raw-find-entity-from-point point message-info)))
+
+(defun mime-raw-flatten-message-info (&optional message-info)
+ "Return list of entity in mime-raw-buffer.
+If optional argument MESSAGE-INFO is not specified,
+`mime-raw-message-info' is used."
+ (or message-info
+ (setq message-info mime-raw-message-info))
+ (let ((dest (list message-info))
+ (rcl (mime-entity-children message-info)))
+ (while rcl
+ (setq dest (nconc dest (mime-raw-flatten-message-info (car rcl))))
+ (setq rcl (cdr rcl)))
+ dest))
+