Function: gnus-mime-inline-part

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

Signature

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

Documentation

Insert the MIME part under point into the current buffer.

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-inline-part (&optional handle arg event)
  "Insert the MIME part under point into the current buffer.
Compressed files like .gz and .bz2 are decompressed."
  (interactive (list nil current-prefix-arg last-nonmenu-event)
	       gnus-article-mode)
  (if event (mouse-set-point event))
  (gnus-article-check-buffer)
  (let* ((inhibit-read-only t)
	 (b (point))
	 (btn ;; position where the MIME button exists
	  (if handle
	      (if (eq handle (get-text-property b 'gnus-data))
		  b
		(article-goto-body)
		(or (text-property-any (point) (point-max) 'gnus-data handle)
		    (text-property-any (point-min) (point) 'gnus-data handle)))
	    (setq handle (get-text-property b 'gnus-data))
	    b))
	 start)
    (when handle
      (when (= b (prog1
		     btn
		   (setq start (next-single-property-change btn 'gnus-data
							    nil (point-max))
			 btn (previous-single-property-change start
							      'gnus-data))))
	(setq b btn))
      (if (and (not arg) (mm-handle-undisplayer handle))
	  (progn
	    (setq b (copy-marker b)
		  btn (copy-marker btn))
	    (mm-remove-part handle))
	(cond
	 ((not arg) nil)
	 ((numberp arg)
	  (if (mm-handle-undisplayer handle)
	      (mm-remove-part handle)))
	 ((mm-handle-undisplayer handle)
	  (mm-remove-part handle)))
	(goto-char start)
	(unless (bolp)
	  ;; This is a header button.
	  (forward-line 1))
	(mm-display-inline handle))
      ;; Toggle the button appearance between `[button]...' and `[button]'.
      (when (markerp btn)
	(setq btn (prog1 (marker-position btn)
		    (set-marker btn nil))))
      (goto-char btn)
      (let ((displayed-p (mm-handle-displayed-p handle)))
	(gnus-insert-mime-button handle (get-text-property btn 'gnus-part)
				 (list displayed-p))
	(delete-region
	 (point)
	 (next-single-property-change (point) 'gnus-data nil (point-max)))
	(setq start (point))
	(if (search-backward "\n\n" nil t)
	    (progn
	      (goto-char start)
	      (unless (or displayed-p (eolp))
		;; Add extra newline.
		(insert (propertize (buffer-substring (1- start) start)
				    'gnus-undeletable t))))
	  ;; We're in the article header.
	  (delete-char -1)
	  (let ((ovl (make-overlay btn (point))))
	    (overlay-put ovl 'gnus-button-attachment-extra t)
	    (overlay-put ovl 'evaporate t))
	  (save-restriction
	    (message-narrow-to-field)
	    (let ((gnus-treatment-function-alist
		   '((gnus-treat-highlight-headers
		      gnus-article-highlight-headers))))
	      (gnus-treat-article 'head)))))
      (when (markerp b)
	(setq b (prog1 (marker-position b)
		  (set-marker b nil))))
      (goto-char b))))