-;;; mm-view.el --- Functions for viewing MIME objects
-;; Copyright (C) 1998,99 Free Software Foundation, Inc.
+;;; mm-view.el --- functions for viewing MIME objects
+
+;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
+;; 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
;; This file is part of GNU Emacs.
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING. If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;;; Code:
-
+(eval-and-compile
+ (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
(eval-when-compile (require 'cl))
(require 'mail-parse)
(require 'mailcap)
(require 'mm-bodies)
(require 'mm-decode)
+(require 'smime)
-(eval-and-compile
- (autoload 'gnus-article-prepare-display "gnus-art")
- (autoload 'vcard-parse-string "vcard")
- (autoload 'vcard-format-string "vcard")
- (autoload 'fill-flowed "fill-flowed")
- (autoload 'diff-mode "diff-mode"))
+(autoload 'gnus-completing-read "gnus-util")
+(autoload 'gnus-window-inside-pixel-edges "gnus-ems")
+(autoload 'gnus-article-prepare-display "gnus-art")
+(autoload 'vcard-parse-string "vcard")
+(autoload 'vcard-format-string "vcard")
+(autoload 'fill-flowed "flow-fill")
+(autoload 'html2text "html2text" nil t)
+
+(defvar gnus-article-mime-handles)
+(defvar gnus-newsgroup-charset)
+(defvar smime-keys)
+(defvar w3m-cid-retrieve-function-alist)
+(defvar w3m-current-buffer)
+(defvar w3m-display-inline-images)
+(defvar w3m-minor-mode-map)
+
+(defvar mm-text-html-renderer-alist
+ '((w3 . mm-inline-text-html-render-with-w3)
+ (w3m . mm-inline-text-html-render-with-w3m)
+ (w3m-standalone . mm-inline-text-html-render-with-w3m-standalone)
+ (links mm-inline-render-with-file
+ mm-links-remove-leading-blank
+ "links" "-dump" file)
+ (lynx mm-inline-render-with-stdin nil
+ "lynx" "-dump" "-force_html" "-stdin" "-nolist")
+ (html2text mm-inline-render-with-function html2text))
+ "The attributes of renderer types for text/html.")
+
+(defvar mm-text-html-washer-alist
+ '((w3 . gnus-article-wash-html-with-w3)
+ (w3m . gnus-article-wash-html-with-w3m)
+ (w3m-standalone . gnus-article-wash-html-with-w3m-standalone)
+ (links mm-inline-wash-with-file
+ mm-links-remove-leading-blank
+ "links" "-dump" file)
+ (lynx mm-inline-wash-with-stdin nil
+ "lynx" "-dump" "-force_html" "-stdin" "-nolist")
+ (html2text html2text))
+ "The attributes of washer types for text/html.")
+
+(defcustom mm-fill-flowed t
+ "If non-nil a format=flowed article will be displayed flowed."
+ :type 'boolean
+ :version "22.1"
+ :group 'mime-display)
+
+(defcustom mm-inline-large-images-proportion 0.9
+ "Maximum proportion of large image resized when
+`mm-inline-large-images' is set to resize."
+ :type 'float
+ :version "24.1"
+ :group 'mime-display)
+
+;;; Internal variables.
;;;
;;; Functions for displaying various formats inline
;;;
-(defun mm-inline-image-emacs (handle)
- (let ((b (point))
- (overlay nil)
- (string (copy-sequence "[MM-INLINED-IMAGE]"))
- buffer-read-only)
- (insert "\n")
- (buffer-name)
- (setq overlay (make-overlay (point) (point) (current-buffer)))
- (put-text-property 0 (length string) 'display (mm-get-image handle) string)
- (overlay-put overlay 'before-string string)
+(defun mm-inline-image-emacs (handle)
+ (let ((b (point-marker))
+ (inhibit-read-only t))
+ (put-image
+ (let ((image (mm-get-image handle)))
+ (if (eq mm-inline-large-images 'resize)
+ (gnus-rescale-image image
+ (let ((edges (gnus-window-inside-pixel-edges
+ (get-buffer-window (current-buffer)))))
+ (cons (truncate (* mm-inline-large-images-proportion
+ (- (nth 2 edges) (nth 0 edges))))
+ (truncate (* mm-inline-large-images-proportion
+ (- (nth 3 edges) (nth 1 edges)))))))
+ image))
+ b)
+ (insert "\n\n")
(mm-handle-set-undisplayer
handle
`(lambda ()
- (let (buffer-read-only)
- (delete-overlay ,overlay)
- (delete-region ,(set-marker (make-marker) b)
- ,(set-marker (make-marker) (point))))))))
+ (let ((b ,b)
+ (inhibit-read-only t))
+ (remove-images b b)
+ (delete-region b (+ b 2)))))))
(defun mm-inline-image-xemacs (handle)
- (let ((b (point))
- (annot (make-annotation (mm-get-image handle) nil 'text))
- buffer-read-only)
- (insert "\n")
- (mm-handle-set-undisplayer
- handle
- `(lambda ()
- (let (buffer-read-only)
- (delete-annotation ,annot)
- (delete-region ,(set-marker (make-marker) b)
- ,(set-marker (make-marker) (point))))))
- (set-extent-property annot 'mm t)
- (set-extent-property annot 'duplicable t)))
-
-(defun mm-inline-image (handle)
- (if mm-xemacs-p
- (mm-inline-image-xemacs handle)
- (mm-inline-image-emacs handle)))
+ (when (featurep 'xemacs)
+ (insert "\n\n")
+ (forward-char -2)
+ (let ((annot (make-annotation (mm-get-image handle) nil 'text))
+ (inhibit-read-only t))
+ (mm-handle-set-undisplayer
+ handle
+ `(lambda ()
+ (let ((b ,(point-marker))
+ (inhibit-read-only t))
+ (delete-annotation ,annot)
+ (delete-region (- b 2) b))))
+ (set-extent-property annot 'mm t)
+ (set-extent-property annot 'duplicable t))))
+
+(eval-and-compile
+ (if (featurep 'xemacs)
+ (defalias 'mm-inline-image 'mm-inline-image-xemacs)
+ (defalias 'mm-inline-image 'mm-inline-image-emacs)))
+
+;; External.
+(declare-function w3-do-setup "ext:w3" ())
+(declare-function w3-region "ext:w3-display" (st nd))
+(declare-function w3-prepare-buffer "ext:w3-display" (&rest args))
(defvar mm-w3-setup nil)
(defun mm-setup-w3 ()
(require 'url-vars)
(setq mm-w3-setup t)))
-(defun mm-inline-text (handle)
- (let ((type (mm-handle-media-subtype handle))
- text buffer-read-only)
- (cond
- ((equal type "html")
-