Function: mml-preview

mml-preview is an interactive and byte-compiled function defined in mml.el.gz.

Signature

(mml-preview &optional RAW)

Documentation

Display current buffer with Gnus, in a new buffer.

If RAW, display a raw encoded MIME message.

The window layout for the preview buffer is controlled by the variables special-display-buffer-names, special-display-regexps, or gnus-buffer-configuration (the first match made will be used), or the pop-to-buffer function.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/mml.el.gz
(defun mml-preview (&optional raw)
  "Display current buffer with Gnus, in a new buffer.
If RAW, display a raw encoded MIME message.

The window layout for the preview buffer is controlled by the variables
`special-display-buffer-names', `special-display-regexps', or
`gnus-buffer-configuration' (the first match made will be used),
or the `pop-to-buffer' function."
  (interactive "P")
  (setq mml-preview-buffer (generate-new-buffer
			    (concat (if raw "*Raw MIME preview of "
				      "*MIME preview of ")
				    (buffer-name))))
  (require 'gnus-msg)		      ; for gnus-setup-posting-charset
  (save-excursion
    (let* ((buf (current-buffer))
	   (article-editing (eq major-mode 'gnus-article-edit-mode))
	   (message-options message-options)
	   (message-this-is-mail (message-mail-p))
	   (message-this-is-news (message-news-p))
	   (message-posting-charset (or (gnus-setup-posting-charset
					 (save-restriction
					   (message-narrow-to-headers-or-head)
					   (message-fetch-field "Newsgroups")))
					message-posting-charset)))
      (message-options-set-recipient)
      (when (boundp 'gnus-buffers)
	(push mml-preview-buffer gnus-buffers))
      (save-restriction
	(widen)
	(set-buffer mml-preview-buffer)
	(erase-buffer)
	(insert-buffer-substring buf))
      (mml-preview-insert-mail-followup-to)
      (let ((message-deletable-headers (if (message-news-p)
					   nil
					 message-deletable-headers))
	    (mail-header-separator (if article-editing
				       ""
				     mail-header-separator)))
	(message-generate-headers
	 (copy-sequence (if (message-news-p)
			    message-required-news-headers
			  message-required-mail-headers)))
	(unless article-editing
	  (if (re-search-forward
	       (concat "^" (regexp-quote mail-header-separator) "\n") nil t)
	      (replace-match "\n"))
	  (setq mail-header-separator ""))
	(message-sort-headers)
	(mml-to-mime))
      (if raw
	  (let ((s (buffer-string)))
	    ;; Insert the content into unibyte buffer.
	    (erase-buffer)
	    (mm-disable-multibyte)
	    (insert s))
	(let ((gnus-newsgroup-charset (car message-posting-charset))
	      gnus-article-prepare-hook gnus-original-article-buffer
	      gnus-displaying-mime)
	  (run-hooks 'gnus-article-decode-hook)
	  (let ((gnus-newsgroup-name "dummy")
		(gnus-newsrc-hashtb (or gnus-newsrc-hashtb
					(gnus-make-hashtable 5))))
	    (gnus-article-prepare-display))))
      ;; Disable article-mode-map.
      (use-local-map nil)
      (add-hook 'kill-buffer-hook
		(lambda ()
		  (mm-destroy-parts gnus-article-mime-handles))
		nil t)
      (setq buffer-read-only t)
      (local-set-key "q" (lambda () (interactive) (kill-buffer nil)))
      (local-set-key "=" (lambda () (interactive) (delete-other-windows)))
      (local-set-key "\r"
		     (lambda ()
		       (interactive)
		       (widget-button-press (point))))
      (local-set-key [mouse-2]
		     (lambda (event)
		       (interactive "@e")
		       (widget-button-press (widget-event-point event) event)))
      ;; FIXME: Buffer is in article mode, but most tool bar commands won't
      ;; work.  Maybe only keep the following icons: search, print, quit
      (goto-char (point-min))))
  (if (and (not (special-display-p (buffer-name mml-preview-buffer)))
	   (boundp 'gnus-buffer-configuration)
	   (assq 'mml-preview gnus-buffer-configuration))
      (let ((gnus-message-buffer (current-buffer)))
	(gnus-configure-windows 'mml-preview))
    (pop-to-buffer mml-preview-buffer)))