-(defvar mime-view-redisplay nil)
-
-(defun mime-view-setup-buffers (&optional ctl encoding ibuf obuf)
- (if ibuf
- (progn
- (get-buffer ibuf)
- (set-buffer ibuf)
- ))
- (or mime-view-redisplay
- (setq mime-raw-message-info (mime-parse-message ctl encoding))
- )
- (let* ((cinfo mime-raw-message-info)
- (pcl (mime-raw-flatten-message-info cinfo))
- (the-buf (current-buffer))
- (mode major-mode)
- )
- (or obuf
- (setq obuf (concat "*Preview-" (buffer-name the-buf) "*")))
- (set-buffer (get-buffer-create obuf))
- (let ((inhibit-read-only t))
- ;;(setq buffer-read-only nil)
- (widen)
- (erase-buffer)
- (setq mime-raw-buffer the-buf)
- (setq mime-preview-original-major-mode mode)
- (setq major-mode 'mime-view-mode)
- (setq mode-name "MIME-View")
- (while pcl
- (mime-view-display-entity (car pcl) cinfo the-buf obuf)
- (setq pcl (cdr pcl))
- )
- (set-buffer-modified-p nil)
- )
- (setq buffer-read-only t)
- (set-buffer the-buf)
- )
- (setq mime-preview-buffer obuf)
- )
-
-(defun mime-view-display-entity (entity message-info ibuf obuf)
- "Display ENTITY."
- (let* ((beg (mime-entity-point-min entity))
- (end (mime-entity-point-max entity))
- (media-type (mime-entity-media-type entity))
- (media-subtype (mime-entity-media-subtype entity))
- (ctype (if media-type
- (if media-subtype
- (format "%s/%s" media-type media-subtype)
- (symbol-name media-type)
- )))
- (params (mime-entity-parameters entity))
- (encoding (mime-entity-encoding entity))
- (entity-node-id (mime-entity-node-id entity))
- he e nb ne subj)
- (set-buffer ibuf)
- (goto-char beg)
- (setq he (if (re-search-forward "^$" nil t)
- (1+ (match-end 0))
- end))
- (if (> he end)
- (setq he end)
- )
- (save-restriction
- (narrow-to-region beg end)
- (setq subj
- (eword-decode-string
- (mime-raw-get-subject params encoding)))
- )
- (set-buffer obuf)
- (setq nb (point))
- (narrow-to-region nb nb)
- (mime-view-entity-button-function entity message-info subj)
- (if (mime-view-header-visible-p entity message-info)
- (mime-view-display-header beg he)
- )
- (if (and (null entity-node-id)
- (member
- ctype mime-view-content-button-visible-ctype-list))
- (save-excursion
- (goto-char (point-max))
- (mime-view-insert-entity-button entity message-info subj)
- ))
- (cond ((mime-view-body-visible-p entity message-info)
- (mime-view-display-body he end
- entity-node-id message-info
- ctype params subj encoding)
- )
- ((and (eq media-type 'message)(eq media-subtype 'partial))
- (mime-view-insert-message/partial-button)
- )
- ((and (null entity-node-id)
- (null (mime-entity-children message-info))
- )
- (goto-char (point-max))
- (mime-view-insert-entity-button entity message-info subj)
- ))
- (mime-view-entity-separator-function entity message-info)
- (setq ne (point-max))
- (widen)
- (put-text-property nb ne 'mime-view-raw-buffer ibuf)
- (put-text-property nb ne 'mime-view-entity-info entity)
- (goto-char ne)
- ))
-
-(defun mime-raw-get-uu-filename (param &optional encoding)
- (if (member (or encoding
- (cdr (assq 'encoding param))
- )
- mime-view-uuencode-encoding-name-list)
- (save-excursion
- (or (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 (param &optional encoding)
- (or (std11-find-field-body '("Content-Description" "Subject"))
- (let (ret)
- (if (or (and (setq ret (mime/Content-Disposition))
- (setq ret (assoc "filename" (cdr ret)))
- )
- (setq ret (assoc "name" param))
- (setq ret (assoc "x-name" param))
- )
- (std11-strip-quoted-string (cdr ret))
- ))
- (mime-raw-get-uu-filename param encoding)
- ""))
-
-
-;;; @ entity information
-;;;
-
-(defun mime-raw-point-to-entity-number (position &optional message-info)
- "Return entity-number from POTION 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 ((b (mime-entity-point-min message-info))
- (e (mime-entity-point-max message-info))
- (c (mime-entity-children message-info))
+(defun mime-display-entity (entity &optional situation
+ default-situation preview-buffer)
+ (or preview-buffer
+ (setq preview-buffer (current-buffer)))
+ (let* ((raw-buffer (mime-entity-buffer entity))
+ (start (mime-entity-point-min entity))
+ e nb ne)
+ (set-buffer raw-buffer)
+ (goto-char start)
+ (or situation
+ (setq situation
+ (or (ctree-match-calist mime-preview-condition
+ (append (mime-entity-situation entity)
+ default-situation))
+ default-situation)))
+ (let ((button-is-invisible
+ (eq (cdr (assq 'entity-button situation)) 'invisible))
+ (header-is-visible
+ (eq (cdr (assq 'header situation)) 'visible))
+ (header-presentation-method
+ (or (cdr (assq 'header-presentation-method situation))
+ (cdr (assq major-mode mime-header-presentation-method-alist))))
+ (body-presentation-method
+ (cdr (assq 'body-presentation-method situation)))
+ (children (mime-entity-children entity)))
+ (set-buffer preview-buffer)
+ (setq nb (point))
+ (narrow-to-region nb nb)
+ (or button-is-invisible
+ (if (mime-view-entity-button-visible-p entity)
+ (mime-view-insert-entity-button entity)
+ ))
+ (when header-is-visible
+ (if header-presentation-method
+ (funcall header-presentation-method entity situation)
+ (mime-insert-header entity
+ mime-view-ignored-field-list
+ mime-view-visible-field-list))
+ (goto-char (point-max))
+ (insert "\n")
+ (run-hooks 'mime-display-header-hook)