2 ;;; tm-text.el --- a content filter module of tm-view to display
3 ;;; text/plain, text/richtext and text/enriched
6 ;;; Copyright (C) 1995 Free Software Foundation, Inc.
7 ;;; Copyright (C) 1994 .. 1996 MORIOKA Tomohiko
9 ;;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
11 ;;; $Id: tm-text.el,v 7.20 1996/07/18 12:46:20 morioka Exp $
12 ;;; Keywords: mail, news, MIME, multimedia, text
14 ;;; This file is part of tm (Tools for MIME).
16 ;;; This program is free software; you can redistribute it and/or
17 ;;; modify it under the terms of the GNU General Public License as
18 ;;; published by the Free Software Foundation; either version 2, or
19 ;;; (at your option) any later version.
21 ;;; This program is distributed in the hope that it will be useful,
22 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
23 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 ;;; General Public License for more details.
26 ;;; You should have received a copy of the GNU General Public License
27 ;;; along with This program. If not, write to the Free Software
28 ;;; Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
35 (defvar mime-viewer/code-converter-alist
36 '((mime/show-message-mode . mime-charset/decode-buffer)
37 (mime/temporary-message-mode . mime-charset/decode-buffer)
38 (t . mime-charset/maybe-decode-buffer)
41 (defun mime-charset/decode-buffer (charset &optional encoding)
42 (decode-mime-charset-region (point-min)(point-max)
43 (or charset default-mime-charset))
46 (defun mime-charset/maybe-decode-buffer (charset &optional encoding)
47 (or (member encoding '(nil "7bit" "8bit" "binary"))
48 (mime-charset/decode-buffer beg end charset)
51 (defun mime-preview/decode-text-buffer (charset encoding)
52 (mime-decode-region (point-min) (point-max) encoding)
53 (let* ((mode mime::preview/original-major-mode)
54 (m (or (save-excursion
55 (set-buffer mime::preview/article-buffer)
56 mime::article/code-converter)
57 (cdr (or (assq mode mime-viewer/code-converter-alist)
58 (assq t mime-viewer/code-converter-alist)))
62 (funcall m charset encoding)
66 ;;; @ content filters for tm-view
69 (defun mime-preview/filter-for-text/plain (ctype params encoding)
70 (mime-preview/decode-text-buffer (cdr (assoc "charset" params)) encoding)
71 (goto-char (point-max))
72 (if (not (eq (char-after (1- (point))) ?\n))
75 (if browse-url-browser-function
77 (goto-char (point-min))
78 (while (re-search-forward tm:URL-regexp nil t)
79 (let ((beg (match-beginning 0))
81 (tm:add-button beg end
82 (function tm:browse-url)
83 (list (buffer-substring beg end))))
85 (run-hooks 'mime-viewer/plain-text-preview-hook)
88 (defun mime-preview/filter-for-text/richtext (ctype params encoding)
89 (let* ((mode mime::preview/original-major-mode)
90 (m (assq mode mime-viewer/code-converter-alist))
91 (charset (cdr (assoc "charset" params)))
94 (remove-text-properties beg (point-max) '(face nil))
95 (mime-preview/decode-text-buffer charset encoding)
96 (richtext-decode beg (point-max))
99 (defun mime-preview/filter-for-text/enriched (ctype params encoding)
100 (let* ((mode mime::preview/original-major-mode)
101 (m (assq mode mime-viewer/code-converter-alist))
102 (charset (cdr (assoc "charset" params)))
105 (remove-text-properties beg (point-max) '(face nil))
106 (mime-preview/decode-text-buffer charset encoding)
107 (enriched-decode beg (point-max))
116 ;;; tm-text.el ends here