- (unless (mm-handle-cache handle)
- (unless func
- (error (format "Access type (%s) is not supported" access-type)))
- (with-temp-buffer
- (mm-insert-part handle)
- (goto-char (point-max))
- (insert "\n\n")
- (setq handles (mm-dissect-buffer t)))
- (unless (bufferp (car handles))
- (mm-destroy-parts handles)
- (error "Multipart external body is not supported"))
- (save-excursion ;; single part
- (set-buffer (setq buf (mm-handle-buffer handles)))
- (let (good)
- (unwind-protect
- (progn
- (funcall func handle)
- (setq good t))
- (unless good
- (mm-destroy-parts handles))))
- (mm-handle-set-cache handle handles))
- (setq gnus-article-mime-handles
- (mm-merge-handles gnus-article-mime-handles handles)))
- (unless no-display
- (save-excursion
- (save-restriction
- (narrow-to-region (point) (point))
- (gnus-display-mime (mm-handle-cache handle))
- (mm-handle-set-undisplayer
- handle
- `(lambda ()
- (let (buffer-read-only)
- (condition-case nil
- ;; This is only valid on XEmacs.
- (mapcar (lambda (prop)
- (remove-specifier
- (face-property 'default prop) (current-buffer)))
- '(background background-pixmap foreground))
- (error nil))
- (delete-region ,(point-min-marker) ,(point-max-marker))))))))))
+ (unless func
+ (error "Access type (%s) is not supported" access-type))
+ (mm-with-part handle
+ (goto-char (point-max))
+ (insert "\n\n")
+ ;; It should be just a single MIME handle.
+ (setq handles (mm-dissect-buffer t)))
+ (unless (bufferp (car handles))
+ (mm-destroy-parts handles)
+ (error "Multipart external body is not supported"))
+ (with-current-buffer (mm-handle-buffer handles)
+ (let (good)
+ (unwind-protect
+ (progn
+ (funcall func handle)
+ (setq good t))
+ (unless good
+ (mm-destroy-parts handles))))
+ (mm-handle-set-cache handle handles))
+ (setq gnus-article-mime-handles
+ (mm-merge-handles gnus-article-mime-handles handles))))
+
+;;;###autoload
+(defun mm-inline-external-body (handle &optional no-display)
+ "Show the external-body part of HANDLE.
+This function replaces the buffer of HANDLE with a buffer contains
+the entire message.
+If NO-DISPLAY is nil, display it. Otherwise, do nothing after replacing."
+ (unless (mm-handle-cache handle)
+ (mm-extern-cache-contents handle))
+ (unless no-display
+ (save-excursion
+ (save-restriction
+ (narrow-to-region (point) (point))
+ (mm-display-part (mm-handle-cache handle))))
+ ;; Move undisplayer added to the cached handle to the parent.
+ (mm-handle-set-undisplayer
+ handle (mm-handle-undisplayer (mm-handle-cache handle)))
+ (mm-handle-set-undisplayer (mm-handle-cache handle) nil)))