+ (save-restriction
+ (narrow-to-region b (point))
+ (let ((charset (drums-content-type-get (nth 1 handle) 'charset)))
+ (when charset
+ (mm-decode-body charset nil)))
+ (setcar
+ (nthcdr 3 handle)
+ `(lambda ()
+ (let (buffer-read-only)
+ (delete-region ,(set-marker (make-marker) (point-min))
+ ,(set-marker (make-marker) (point-max)))))))))
+ )))
+
+(defun mm-inline-audio (handle)
+ (message "Not implemented"))
+
+;;;
+;;; Functions for outputting parts
+;;;
+
+(defun mm-save-part (handle)
+ "Write HANDLE to a file."
+ (let* ((name (drums-content-type-get (cadr handle) 'name))
+ (file (read-file-name "Save MIME part to: "
+ (expand-file-name
+ (or name "") default-directory))))
+ (mm-with-unibyte-buffer
+ (insert-buffer-substring (car handle))
+ (mm-decode-content-transfer-encoding (nth 2 handle))
+ (when (or (not (file-exists-p file))
+ (yes-or-no-p (format "File %s already exists; overwrite? ")))
+ (write-region (point-min) (point-max) file)))))
+
+(defun mm-pipe-part (handle)
+ "Pipe HANDLE to a process."
+ (let* ((name (drums-content-type-get (cadr handle) 'name))
+ (command
+ (read-string "Shell command on MIME part: " mm-last-shell-command)))
+ (mm-with-unibyte-buffer
+ (insert-buffer-substring (car handle))
+ (mm-decode-content-transfer-encoding (nth 2 handle))
+ (shell-command-on-region (point-min) (point-max) command nil))))
+
+(defun mm-interactively-view-part (handle)
+ "Display HANDLE using METHOD."
+ (let* ((type (caadr handle))
+ (methods
+ (mapcar (lambda (i) (list (cdr (assoc "viewer" i))))
+ (mailcap-mime-info type 'all)))
+ (method (completing-read "Viewer: " methods)))
+ (mm-display-external (copy-sequence handle) method)))
+