tm 7.67.
[elisp/tm.git] / tm-w3.el
1 ;;;
2 ;;; tm-w3.el: a tm-view internal decoder for HTML
3 ;;;
4 ;;; by MORIOKA Tomohiko <morioka@jaist.ac.jp> (1995/09/14)
5 ;;;
6 ;;; based on tm-latex.el by OKABE Yasuo <okabe@kudpc.kyoto-u.ac.jp>
7 ;;;
8 ;;; $Id: tm-w3.el,v 3.0 1995/10/20 10:42:41 morioka Exp $
9 ;;;
10
11 (require 'tm-view)
12
13 (autoload 'w3-mode "w3" "HTML viewer" t)
14
15 (defvar mime-viewer/html-default-mode (function w3-mode))
16
17 (defun mime-viewer/decode-html (beg end cal)
18   (let* ((cur-buf (current-buffer))
19          new-buf
20          (name (or (cdr (assoc "name" cal))
21                    (cdr (assoc "x-name" cal))
22                    (concat (make-temp-name "tm") ".html"))))
23     (switch-to-buffer mime::article/preview-buffer)
24     (funcall mime/find-file-function (expand-file-name name mime/tmp-dir))
25     (if (or (<= (buffer-size) 0)
26             (y-or-n-p "Replace the existing buffer?"))
27         (progn
28           (erase-buffer)
29           (setq new-buf (current-buffer))
30           (save-excursion
31             (set-buffer cur-buf)
32             (goto-char beg)
33             (re-search-forward "^$")
34             (append-to-buffer new-buf (+ (match-end 0) 1) end)
35             )))
36     (mime/decode-region encoding (point-min)(point-max))
37     (call-interactively mime-viewer/html-default-mode)
38     ))
39
40 (set-atype 'mime/content-decoding-condition
41            '((type . "text/html")
42              (method . mime-viewer/decode-html)
43              ))
44
45 (provide 'tm-w3)