summaryrefslogtreecommitdiff
path: root/lisp/gnus/mm-view.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/gnus/mm-view.el')
-rw-r--r--lisp/gnus/mm-view.el120
1 files changed, 13 insertions, 107 deletions
diff --git a/lisp/gnus/mm-view.el b/lisp/gnus/mm-view.el
index a764fa51c5d..ecfa2ac9582 100644
--- a/lisp/gnus/mm-view.el
+++ b/lisp/gnus/mm-view.el
@@ -22,9 +22,6 @@
;;; Code:
-;; For Emacs <22.2 and XEmacs.
-(eval-and-compile
- (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
(eval-when-compile (require 'cl))
(require 'mail-parse)
(require 'mailcap)
@@ -51,7 +48,6 @@
(defvar mm-text-html-renderer-alist
'((shr . mm-shr)
- (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)
(gnus-w3m . gnus-article-html)
@@ -100,19 +96,19 @@
(- (nth 3 edges) (nth 1 edges)))))))
image))
b)
- (insert "\n\n")
+ (insert "\n")
(mm-handle-set-undisplayer
handle
`(lambda ()
(let ((b ,b)
(inhibit-read-only t))
(remove-images b b)
- (delete-region b (+ b 2)))))))
+ (delete-region b (1+ b)))))))
(defun mm-inline-image-xemacs (handle)
(when (featurep 'xemacs)
- (insert "\n\n")
- (forward-char -2)
+ (insert "\n")
+ (forward-char -1)
(let ((annot (make-annotation (mm-get-image handle) nil 'text))
(inhibit-read-only t))
(mm-handle-set-undisplayer
@@ -121,7 +117,7 @@
(let ((b ,(point-marker))
(inhibit-read-only t))
(delete-annotation ,annot)
- (delete-region (- b 2) b))))
+ (delete-region (1- b) b))))
(set-extent-property annot 'mm t)
(set-extent-property annot 'duplicable t))))
@@ -130,91 +126,6 @@
(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 ()
- (unless mm-w3-setup
- (require 'w3)
- (w3-do-setup)
- (require 'url)
- (require 'w3-vars)
- (require 'url-vars)
- (setq mm-w3-setup t)))
-
-(defun mm-inline-text-html-render-with-w3 (handle)
- (mm-setup-w3)
- (let ((text (mm-get-part handle))
- (b (point))
- (url-standalone-mode t)
- (url-gateway-unplugged t)
- (w3-honor-stylesheets nil)
- (url-current-object
- (url-generic-parse-url (format "cid:%s" (mm-handle-id handle))))
- (width (window-width))
- (charset (mail-content-type-get
- (mm-handle-type handle) 'charset)))
- (save-excursion
- (insert (if charset (mm-decode-string text charset) text))
- (save-restriction
- (narrow-to-region b (point))
- (unless charset
- (goto-char (point-min))
- (when (or (and (boundp 'w3-meta-content-type-charset-regexp)
- (re-search-forward
- w3-meta-content-type-charset-regexp nil t))
- (and (boundp 'w3-meta-charset-content-type-regexp)
- (re-search-forward
- w3-meta-charset-content-type-regexp nil t)))
- (setq charset
- (let ((bsubstr (buffer-substring-no-properties
- (match-beginning 2)
- (match-end 2))))
- (if (fboundp 'w3-coding-system-for-mime-charset)
- (w3-coding-system-for-mime-charset bsubstr)
- (mm-charset-to-coding-system bsubstr nil t))))
- (delete-region (point-min) (point-max))
- (insert (mm-decode-string text charset))))
- (save-window-excursion
- (save-restriction
- (let ((w3-strict-width width)
- ;; Don't let w3 set the global version of
- ;; this variable.
- (fill-column fill-column))
- (if (or debug-on-error debug-on-quit)
- (w3-region (point-min) (point-max))
- (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")))))))
- (mm-handle-set-undisplayer
- handle
- `(lambda ()
- (let ((inhibit-read-only t))
- ,@(if (functionp 'remove-specifier)
- '((dolist (prop '(background background-pixmap foreground))
- (remove-specifier
- (face-property 'default prop)
- (current-buffer)))))
- (delete-region ,(point-min-marker)
- ,(point-max-marker)))))))))
-
(defvar mm-w3m-setup nil
"Whether gnus-article-mode has been setup to use emacs-w3m.")
@@ -306,7 +217,7 @@
handle
`(lambda ()
(let ((inhibit-read-only t))
- (delete-region ,(point-min-marker)
+ (delete-region ,(copy-marker (point-min) t)
,(point-max-marker)))))))))
(defvar mm-w3m-standalone-supports-m17n-p (if (featurep 'mule) 'undecided)
@@ -480,7 +391,7 @@
handle
`(lambda ()
(let ((inhibit-read-only t))
- (delete-region ,(point-min-marker)
+ (delete-region ,(copy-marker (point-min) t)
,(point-max-marker))))))))
(defun mm-insert-inline (handle text)
@@ -493,19 +404,12 @@
handle
`(lambda ()
(let ((inhibit-read-only t))
- (delete-region ,(copy-marker b)
- ,(copy-marker (point))))))))
+ (delete-region ,(copy-marker b t)
+ ,(point-marker)))))))
(defun mm-inline-audio (handle)
(message "Not implemented"))
-(defun mm-w3-prepare-buffer ()
- (require 'w3)
- (let ((url-standalone-mode t)
- (url-gateway-unplugged t)
- (w3-honor-stylesheets nil))
- (w3-prepare-buffer)))
-
(defun mm-view-message ()
(mm-enable-multibyte)
(let (handles)
@@ -616,9 +520,11 @@ If MODE is not set, try to find mode automatically."
(set-auto-mode)))
;; The mode function might have already turned on font-lock.
;; Do not fontify if the guess mode is fundamental.
- (unless (or (symbol-value 'font-lock-mode)
+ (unless (or font-lock-mode
(eq major-mode 'fundamental-mode))
- (font-lock-fontify-buffer))))
+ (if (fboundp 'font-lock-ensure)
+ (font-lock-ensure)
+ (font-lock-fontify-buffer)))))
;; By default, XEmacs font-lock uses non-duplicable text
;; properties. This code forces all the text properties
;; to be copied along with the text.