;;; mm-view.el --- functions for viewing MIME objects
-;; Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
;; This file is part of GNU Emacs.
(autoload 'vcard-parse-string "vcard")
(autoload 'vcard-format-string "vcard")
(autoload 'fill-flowed "flow-fill")
+ (autoload 'html2text "html2text")
(unless (fboundp 'diff-mode)
(autoload 'diff-mode "diff-mode" "" t nil)))
+(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-render-with-stdin nil
+ "w3m" "-dump" "-T" "text/html")
+ (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 mm-inline-render-with-stdin nil
+ "w3m" "-dump" "-T" "text/html")
+ (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.")
+
+;;; Internal variables.
+
;;;
;;; Functions for displaying various formats inline
;;;
(defun mm-inline-image-emacs (handle)
(let ((b (point-marker))
buffer-read-only)
- (insert "\n")
(put-image (mm-get-image handle) b)
+ (insert "\n\n")
(mm-handle-set-undisplayer
handle
- `(lambda () (remove-images ,b (1+ ,b))))))
+ `(lambda ()
+ (let ((b ,b)
+ buffer-read-only)
+ (remove-images b b)
+ (delete-region b (+ b 2)))))))
(defun mm-inline-image-xemacs (handle)
- (insert "\n")
- (forward-char -1)
- (let ((b (point))
- (annot (make-annotation (mm-get-image handle) nil 'text))
+ (insert "\n\n")
+ (forward-char -2)
+ (let ((annot (make-annotation (mm-get-image handle) nil 'text))
buffer-read-only)
(mm-handle-set-undisplayer
handle
`(lambda ()
- (let (buffer-read-only)
+ (let ((b ,(point-marker))
+ buffer-read-only)
(delete-annotation ,annot)
- (delete-region ,(set-marker (make-marker) b)
- ,(set-marker (make-marker) (point))))))
+ (delete-region (- b 2) b))))
(set-extent-property annot 'mm t)
(set-extent-property annot 'duplicable t)))
(let ((text (mm-get-part handle))
(b (point))
(url-standalone-mode t)
+ (url-gateway-unplugged t)
(w3-honor-stylesheets nil)
- (w3-delay-image-loads t)
(url-current-object
(url-generic-parse-url (format "cid:%s" (mm-handle-id handle))))
(width (window-width))
(let ((w3-strict-width width)
;; Don't let w3 set the global version of
;; this variable.
- (fill-column fill-column)
- (w3-honor-stylesheets nil)
- (w3-delay-image-loads t)
- (url-standalone-mode t))
- (condition-case var
+ (fill-column fill-column))
+ (if (or debug-on-error debug-on-quit)
(w3-region (point-min) (point-max))
- (error
- (delete-region (point-min) (point-max))
- (let ((b (point))
- (charset (mail-content-type-get
- (mm-handle-type handle) 'charset)))
- (if (or (eq charset 'gnus-decoded)
- (eq mail-parse-charset 'gnus-decoded))
+ (condition-case ()
+ (w3-region (point-min) (point-max))
+ (error
+ (delete-region (point-min) (point-max))
+ (let ((b (point))
+ (charset (mail-content-type-get
+ (mm-handle-type handle) 'charset)))
+ (if (or (eq charset 'gnus-decoded)
+ (eq mail-parse-charset 'gnus-decoded))
(save-restriction
(narrow-to-region (point) (point))
(mm-insert-part handle)
(goto-char (point-max)))
- (insert (mm-decode-string (mm-get-part handle)
- charset))))
- (message
- "Error while rendering html; showing as text/plain"))))))
+ (insert (mm-decode-string (mm-get-part handle)
+ charset))))
+ (message
+ "Error while rendering html; showing as text/plain")))))))
(mm-handle-set-undisplayer
handle
`(lambda ()
(delete-region ,(point-min-marker)
,(point-max-marker)))))))))
-(defvar mm-w3m-mode-map nil
- "Local keymap for inlined text/html part rendered by emacs-w3m. It will
-be slightly different from `w3m-mode-map' to use in the article buffer.")
-
-(defvar mm-w3m-mode-command-alist
- '((backward-char)
- (describe-mode)
- (forward-char)
- (goto-line)
- (next-line)
- (previous-line)
- (w3m-antenna)
- (w3m-antenna-add-current-url)
- (w3m-bookmark-add-current-url)
- (w3m-bookmark-add-this-url)
- (w3m-bookmark-view)
- (w3m-close-window)