+;; In Emacs 22, we could use `min-colors' in the face definition. But Emacs
+;; 21 and XEmacs don't support it.
+(defcustom mm-uu-hide-markers
+ (< 16 (or (and (fboundp 'defined-colors)
+ (length (defined-colors)))
+ (and (fboundp 'device-color-cells)
+ (device-color-cells))
+ 0))
+ "If non-nil, hide verbatim markers.
+The value should be nil on displays where the face
+`mm-uu-extract' isn't distinguishable to the face `default'."
+ :type '(choice (const :tag "Hide" t)
+ (const :tag "Don't hide" nil))
+ :version "23.1" ;; No Gnus
+ :group 'gnus-article-mime)
+
+(defface mm-uu-extract '(;; Inspired by `gnus-cite-3'
+ (((type tty)
+ (class color)
+ (background dark))
+ (:background "dark blue"))
+ (((class color)
+ (background dark))
+ (:foreground "light yellow"
+ :background "dark green"))
+ (((type tty)
+ (class color)
+ (background light))
+ (:foreground "dark blue"))
+ (((class color)
+ (background light))
+ (:foreground "dark green"
+ :background "light yellow"))
+ (t
+ ()))
+ "Face for extracted buffers."
+ ;; See `mm-uu-verbatim-marks-extract'.
+ :version "23.1" ;; No Gnus
+ :group 'gnus-article-mime)
+
+(defun mm-uu-copy-to-buffer (&optional from to properties)
+ "Copy the contents of the current buffer to a fresh buffer.
+Return that buffer.
+
+If PROPERTIES is non-nil, PROPERTIES are applied to the buffer,
+see `set-text-properties'. If PROPERTIES equals t, this means to
+apply the face `mm-uu-extract'."
+ (let ((obuf (current-buffer))
+ (multi (and (boundp 'enable-multibyte-characters)
+ enable-multibyte-characters))
+ (coding-system
+ ;; Might not exist in non-MULE XEmacs
+ (when (boundp 'buffer-file-coding-system)
+ buffer-file-coding-system)))
+ (with-current-buffer (generate-new-buffer " *mm-uu*")
+ (if multi (mm-enable-multibyte) (mm-disable-multibyte))
+ (setq buffer-file-coding-system coding-system)