Function: gnus-mime-copy-part

gnus-mime-copy-part is an interactive and byte-compiled function defined in gnus-art.el.gz.

Signature

(gnus-mime-copy-part &optional HANDLE ARG EVENT)

Documentation

Put the MIME part under point into a new buffer.

If auto-compression-mode(var)/auto-compression-mode(fun) is enabled, compressed files like .gz and .bz2 are decompressed.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/gnus-art.el.gz
(defun gnus-mime-copy-part (&optional handle arg event)
  "Put the MIME part under point into a new buffer.
If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
are decompressed."
  (interactive (list nil current-prefix-arg last-nonmenu-event)
	       gnus-article-mode)
  (mouse-set-point event)
  (gnus-article-check-buffer)
  (unless handle
    (setq handle (get-text-property (point) 'gnus-data)))
  (when handle
    (let ((filename (mm-handle-filename handle))
	  contents dont-decode charset coding-system)
      (mm-with-unibyte-buffer
	(mm-insert-part handle)
	(setq contents (or (condition-case nil
			       (mm-decompress-buffer filename nil 'sig)
			     (error
			      (setq dont-decode t)
			      nil))
			   (buffer-string))))
      (setq filename (cond (filename (file-name-nondirectory filename))
			   (dont-decode "*raw data*")
			   (t "*decoded*")))
      (cond
       (dont-decode)
       ((not arg)
	(unless (setq charset (mail-content-type-get
			       (mm-handle-type handle) 'charset))
	  (unless (setq coding-system (mm-with-unibyte-buffer
					(insert contents)
					(mm-find-buffer-file-coding-system)))
	    (setq charset gnus-newsgroup-charset))))
       ((numberp arg)
	(setq charset (or (cdr (assq arg
				     gnus-summary-show-article-charset-alist))
			  (read-coding-system "Charset: ")))))
      (switch-to-buffer (generate-new-buffer filename))
      (if (or coding-system
	      (and charset
		   (setq coding-system (mm-charset-to-coding-system
					charset nil t))
		   (not (eq coding-system 'ascii))))
	  (progn
	    (mm-enable-multibyte)
	    (insert (decode-coding-string contents coding-system))
	    (setq buffer-file-coding-system last-coding-system-used))
	(mm-disable-multibyte)
	(insert contents)
	(setq buffer-file-coding-system mm-binary-coding-system))
      ;; We do it this way to make `normal-mode' set the appropriate mode.
      (unwind-protect
	  (progn
	    (setq buffer-file-name (expand-file-name filename))
	    (normal-mode))
	(setq buffer-file-name nil))
      (goto-char (point-min)))))