+ `(lambda ()
+ (let (buffer-read-only)
+ (if (functionp 'remove-specifier)
+ (mapcar (lambda (prop)
+ (remove-specifier
+ (face-property 'default prop)
+ (current-buffer)))
+ '(background background-pixmap foreground)))
+ (delete-region ,(point-min-marker)
+ ,(point-max-marker))))))))
+
+(defun mm-links-remove-leading-blank ()
+ ;; Delete the annoying three spaces preceding each line of links
+ ;; output.
+ (goto-char (point-min))
+ (while (re-search-forward "^ " nil t)
+ (delete-region (match-beginning 0) (match-end 0))))
+
+(defun mm-inline-wash-with-file (post-func cmd &rest args)
+ (let ((file (mm-make-temp-file
+ (expand-file-name "mm" mm-tmp-directory))))
+ (let ((coding-system-for-write 'binary))
+ (write-region (point-min) (point-max) file nil 'silent))
+ (delete-region (point-min) (point-max))
+ (unwind-protect
+ (apply 'call-process cmd nil t nil (mapcar 'eval args))
+ (delete-file file))
+ (and post-func (funcall post-func))))
+
+(defun mm-inline-wash-with-stdin (post-func cmd &rest args)
+ (let ((coding-system-for-write 'binary))
+ (apply 'call-process-region (point-min) (point-max)
+ cmd t t nil args))
+ (and post-func (funcall post-func)))
+
+(defun mm-inline-render-with-file (handle post-func cmd &rest args)
+ (let ((source (mm-get-part handle)))
+ (mm-insert-inline
+ handle
+ (mm-with-unibyte-buffer
+ (insert source)
+ (apply 'mm-inline-wash-with-file post-func cmd args)
+ (buffer-string)))))
+
+(defun mm-inline-render-with-stdin (handle post-func cmd &rest args)
+ (let ((source (mm-get-part handle)))
+ (mm-insert-inline
+ handle
+ (mm-with-unibyte-buffer
+ (insert source)
+ (apply 'mm-inline-wash-with-stdin post-func cmd args)
+ (buffer-string)))))
+
+(defun mm-inline-render-with-function (handle func &rest args)
+ (let ((source (mm-get-part handle)))
+ (mm-insert-inline
+ handle
+ (mm-with-unibyte-buffer
+ (insert source)
+ (apply func args)
+ (buffer-string)))))
+
+(defun mm-inline-text-html (handle)
+ (let* ((func (or mm-inline-text-html-renderer mm-text-html-renderer))
+ (entry (assq func mm-text-html-renderer-alist))
+ buffer-read-only)
+ (if entry
+ (setq func (cdr entry)))
+ (cond
+ ((gnus-functionp func)
+ (funcall func handle))
+ (t
+ (apply (car func) handle (cdr func))))))
+
+(defun mm-inline-text-vcard (handle)
+ (let (buffer-read-only)
+ (mm-insert-inline
+ handle
+ (concat "\n-- \n"
+ (ignore-errors