-(defun mime-viewer/get-name (param)
- (let ((str (mime-viewer/get-subject param)))
- (if (string-match " " str)
- (if (or (string-match mime-viewer/file-name-regexp-1 str)
- (string-match mime-viewer/file-name-regexp-2 str))
- (substring str (match-beginning 0)(match-end 0))
- )
- (replace-as-filename str)
- )))
-
-(defun mime-viewer/make-preview-buffer (&optional buf cinfo obuf)
- (let ((the-buf (current-buffer))
- (mode major-mode)
- pcl dest)
- (setq buf
- (if (null buf)
- (current-buffer)
- (prog1
- (get-buffer buf)
- (switch-to-buffer buf)
- )))
- (or cinfo
- (setq cinfo mime::article/content-info)
- )
- (or obuf
- (setq obuf (concat "*Preview-" (buffer-name buf) "*"))
- )
- (setq pcl (mime::make-flat-content-list cinfo))
- (let ((bf (get-buffer obuf)))
- (switch-to-buffer obuf)
- (setq buffer-read-only nil)
- (if bf
- (erase-buffer)
- ))
- (make-variable-buffer-local 'mime::preview/article-buffer)
- (setq mime::preview/article-buffer the-buf)
- (make-variable-buffer-local 'mime::preview/original-major-mode)
- (setq mime::preview/original-major-mode mode)
- (setq major-mode 'mime/viewer-mode)
- (setq mode-name "MIME-View")
- (setq dest
- (mapcar
- (function
- (lambda (cell)
- (let ((beg (mime::content-info/point-min cell))
- (end (mime::content-info/point-max cell))
- (ctype (mime::content-info/type cell))
- (params (mime::content-info/parameters cell))
- (encoding (mime::content-info/encoding cell))
- he cnum e nb ne subj str)
- (setq cnum (mime::get-point-content-number beg cinfo))
- (switch-to-buffer the-buf)
- (setq he (save-excursion
- (goto-char beg)
- (re-search-forward "^$" nil t)
- (+ (match-end 0) 1)
- ))
- (if (> he (point-max))
- (setq he (point-max))
- )
- (save-excursion
- (save-restriction
- (narrow-to-region beg he)
- (setq subj (mime-viewer/get-subject params))
- ))
- (switch-to-buffer obuf)
- (setq nb (point))
- (narrow-to-region nb nb)
- (switch-to-buffer the-buf)
- (if (mime-viewer/header-visible-p cnum cinfo ctype)
- (progn
- (setq str (buffer-substring beg he))
- (switch-to-buffer obuf)
- (insert str)
- (let ((f (assq
- mode
- mime-viewer/content-header-filter-alist))
- )
- (if (and f (setq f (cdr f)))
- (funcall f)
- (mime-viewer/default-content-header-filter)
- ))
- (run-hooks 'mime-viewer/content-header-filter-hook)
- (switch-to-buffer the-buf)
- ))
- (cond ((mime-viewer/body-visible-p cnum cinfo ctype)
- (let (be)
- (setq str (buffer-substring he end))
- (switch-to-buffer obuf)
- (save-restriction
- (setq be (point-max))
- (narrow-to-region be be)
- (insert str)
- (setq ne (point-max))
- (let ((f (or (assoc-value
- ctype
- mime-viewer/content-filter-alist)
- )))
- (if (and f (fboundp f))
- (funcall f ctype params encoding)
- (mime-viewer/default-content-filter
- cnum cinfo ctype params subj)
- ))
- (setq ne (point-max))
- )
- (switch-to-buffer the-buf)
- ))
- ((equal ctype "message/partial")
- (let (be)
- (switch-to-buffer obuf)
- (save-restriction
- (setq be (point-max))
- (narrow-to-region be be)
- (insert
- mime-viewer/announcement-for-message/partial)
- (setq ne (point-max))
- )
- (switch-to-buffer the-buf)
- ))
- ((and (eq cnum t)
- (null (mime::content-info/children cinfo))
- )
- (let (be)
- (switch-to-buffer obuf)
- (save-restriction
- (setq be (point-max))
- (narrow-to-region be be)
- (mime-viewer/insert-content-subject
- cnum cinfo ctype params subj)
- (setq ne (point-max))
- )
- (switch-to-buffer the-buf)
- ))
- )
- (switch-to-buffer obuf)
- (mime-viewer/default-content-separator
- cnum cinfo ctype params subj)
- (prog1
- (progn
- (goto-char nb)
- (funcall mime-viewer/content-subject-function
- cnum cinfo ctype params subj)
- (setq ne (point-max))
- (widen)
- (mime::preview-content-info/create nb (- ne 1)
- buf cell)
- )
- (goto-char ne)
- ))))
- pcl))
- (set-buffer-modified-p nil)
- (setq buffer-read-only t)
- (switch-to-buffer the-buf)
- (list obuf dest)
- ))