Function: gnus-mime-save-part-and-strip

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

Signature

(gnus-mime-save-part-and-strip &optional FILE EVENT)

Documentation

Save the MIME part under point then replace it with an external body.

If FILE is given, use it for the external part.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/gnus-art.el.gz
(defun gnus-mime-save-part-and-strip (&optional file event)
  "Save the MIME part under point then replace it with an external body.
If FILE is given, use it for the external part."
  (interactive (list nil last-nonmenu-event) gnus-article-mode)
  (save-excursion
    (mouse-set-point event)
    (gnus-article-check-buffer)
    (when (gnus-group-read-only-p)
      (error "The current group does not support deleting of parts"))
    (when (mm-complicated-handles gnus-article-mime-handles)
      (error "\
The current article has a complicated MIME structure, giving up..."))
    (let* ((data (get-text-property (point) 'gnus-data))
	   (id (get-text-property (point) 'gnus-part))
	   (handles gnus-article-mime-handles))
      (unless file
	(setq file
	      (and data (mm-save-part data "Delete MIME part and save to: "))))
      (when file
	(with-current-buffer (mm-handle-buffer data)
	  (erase-buffer)
	  (insert "Content-Type: " (mm-handle-media-type data))
	  (mml-insert-parameter-string (cdr (mm-handle-type data))
				       '(charset))
	  ;; Add a filename for the sake of saving the part again.
	  (mml-insert-parameter
	   (mail-header-encode-parameter "name" (file-name-nondirectory file)))
	  (insert "\n")
	  (insert "Content-ID: " (message-make-message-id) "\n")
	  (insert "Content-Transfer-Encoding: binary\n")
	  (insert "\n"))
	(setcdr data
		(cdr (mm-make-handle nil
				     `("message/external-body"
				       (access-type . "LOCAL-FILE")
				       (name . ,file)))))
	;; (set-buffer gnus-summary-buffer)
	(gnus-article-edit-part handles id)))))