6968a318f429b48d328859dd4d4238fbbaefa34e
[elisp/tm.git] / tm-rich.el
1 ;;;
2 ;;; tm-rich.el --- text/enriched and text/richtext style
3 ;;;                richtext filter for tm-view
4 ;;;
5 ;;; Copyright (C) 1995 Free Software Foundation, Inc.
6 ;;; Copyright (C) 1994,1995 MORIOKA Tomohiko
7 ;;;
8 ;;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
9 ;;; Version:
10 ;;;     $Id: tm-rich.el,v 6.14 1995/09/21 00:18:32 morioka Exp $
11 ;;; Keywords: mail, news, MIME, multimedia, richtext, enriched
12 ;;;
13 ;;; This file is part of tm (Tools for MIME).
14 ;;;
15
16 (require 'tm-view)
17
18 (defvar tm-rich/richtext-module
19   (if (or (< emacs-major-version 19)
20           (and (= emacs-major-version 19)
21                (< emacs-minor-version 29))
22           )
23       'tinyrich
24     'richtext))
25 (require tm-rich/richtext-module)
26
27
28 ;;; @ content filters for tm-view
29 ;;;
30
31 (defun mime-viewer/filter-text/richtext (ctype params encoding)
32   (let* ((mode mime::preview/original-major-mode)
33          (m (assq mode mime-viewer/code-converter-alist))
34          (charset (assoc "charset" params))
35          ;; 1995/9/21
36          ;;   modified by Eric Ding <ericding@San-Jose.ate.slb.com>
37          ;;   (c.f. tm-eng:105)
38          (beg (point-min)) (end (point-max))
39          )
40     (cond ((string= encoding "quoted-printable")
41            (quoted-printable-decode-region beg end)
42            )
43           ((string= encoding "base64")
44            (base64-decode-region beg end)
45            ))
46     ;; end
47     (if (and m (fboundp (setq m (cdr m))))
48         (funcall m beg (point-max) charset encoding)
49       (mime-viewer/default-code-convert-region beg (point-max)
50                                                charset encoding)
51       )
52     (richtext-decode beg (point-max))
53     ))
54
55 (defun mime-viewer/filter-text/enriched (ctype params encoding)
56   (let* ((mode mime::preview/original-major-mode)
57          (m (assq mode mime-viewer/code-converter-alist))
58          (charset (assoc "charset" params))
59          ;; 1995/9/21
60          ;;   modified by Eric Ding <ericding@San-Jose.ate.slb.com>
61          ;;   (c.f. tm-eng:105)
62          (beg (point-min)) (end (point-max))
63          )
64     (cond ((string= encoding "quoted-printable")
65            (quoted-printable-decode-region beg end)
66            )
67           ((string= encoding "base64")
68            (base64-decode-region beg end)
69            ))
70     ;; end
71     (if (and m (fboundp (setq m (cdr m))))
72         (funcall m beg (point-max) charset encoding)
73       (mime-viewer/default-code-convert-region beg (point-max)
74                                                charset encoding)
75       )
76     (enriched-decode beg (point-max))
77     ))
78
79
80 ;;; @ setting
81 ;;;
82
83 (set-alist 'mime-viewer/content-filter-alist
84            "text/richtext" (function mime-viewer/filter-text/richtext))
85
86 (set-alist 'mime-viewer/content-filter-alist
87            "text/enriched" (function mime-viewer/filter-text/enriched))
88
89
90 (run-hooks 'tm-rich-load-hook)
91
92 (provide 'tm-rich)