;;;
-;;; $Id: tm-rich.el,v 6.0 1995/06/11 10:33:34 morioka Exp $
+;;; tm-rich.el --- text/enriched and text/richtext style
+;;; richtext filter for tm-view
;;;
-;;; by MORIOKA Tomohiko <morioka@jaist.ac.jp>
-;;; modified by YAMATE Keiichirou <ics9118@sem1.info.osaka-cu.ac.jp>
+;;; Copyright (C) 1995 Free Software Foundation, Inc.
+;;; Copyright (C) 1994 .. 1996 MORIOKA Tomohiko
;;;
-
-(provide 'tm-rich)
+;;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
+;;; Version:
+;;; $Id: tm-rich.el,v 7.5 1996/05/07 06:28:36 morioka Exp $
+;;; Keywords: mail, news, MIME, multimedia, richtext, enriched
+;;;
+;;; This file is part of tm (Tools for MIME).
+;;;
+;;; This program is free software; you can redistribute it and/or
+;;; modify it under the terms of the GNU General Public License as
+;;; published by the Free Software Foundation; either version 2, or
+;;; (at your option) any later version.
+;;;
+;;; This program is distributed in the hope that it will be useful,
+;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;;; General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with This program. If not, write to the Free Software
+;;; Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+;;;
+;;; Code:
(require 'tm-view)
-(defvar mime/text/richtext-face-list
- '("bold" "italic" "fixed" "underline"))
-
-(defvar mime/text/enriched-face-list
- '("bold" "italic" "fixed" "underline"))
-
-
-(cond ((and (>= (string-to-int emacs-version) 19) window-system)
- (require 'hilit19)
- (defun mime/set-face-region (b e face)
- (let ((sym (intern face)))
- (if (eq sym 'italic)
- (setq sym 'modeline)
- )
- (if (member sym (face-list))
- (progn
- (hilit-unhighlight-region b e)
- (hilit-region-set-face b e sym)
- ))))
- )
- ((and (boundp 'NEMACS) NEMACS)
- (setq mime/available-face-list
- '("bold" "italic" "underline"))
- (setq mime/available-face-attribute-alist
- '(("bold" . inversed-region)
- ("italic" . underlined-region)
- ("underline" . underlined-region)
- ))
- (defun mime/set-face-region (beg end sym)
- (attribute-add-narrow-attribute
- (cdr (assoc sym mime/available-face-attribute-alist))
- beg end))
- )
- (t
- (setq mime/text/richtext-face-list
- nil)
- (defun mime/set-face-region (beg end sym)
- )
- ))
-
-
-;;; @ text/richtext
+;;; @ content filters for tm-view
;;;
-(defun mime/decode-text/richtext-region (beg end)
- (interactive "*r")
- (save-excursion
- (save-restriction
- (narrow-to-region beg end)
- (while (search-forward "\n" nil t)
- (replace-match "")
- )
- (goto-char beg)
- (let (cmd str (fb (point)) fe b e)
- (while (re-search-forward "<[^<>\n\r \t]+>" nil t)
- (setq b (match-beginning 0))
- (setq cmd (buffer-substring (+ b 1)
- (- (match-end 0) 1)))
- (replace-match "")
- (cond ((string= cmd "nl")
- (if (= fb b)
- (insert "\n")
- (fill-region fb b t)
- )
- (setq fb (point))
- )
- ((member (downcase cmd) mime/text/richtext-face-list)
- (setq b (point))
- (save-excursion
- (save-restriction
- (if (re-search-forward (concat "</" cmd ">") nil t)
- (progn
- (replace-match "")
- (setq e (point))
- )
- (setq e end)
- )))
- (mime/set-face-region b e cmd)
- )))
- (fill-region fb (point-max) t)
- (goto-char (point-max))
- (if (not (eq (preceding-char) ?\n))
- (insert "\n")
- )
- ))))
-
(defun mime-viewer/filter-text/richtext (ctype params encoding)
(let* ((mode mime::preview/original-major-mode)
(m (assq mode mime-viewer/code-converter-alist))
(charset (assoc "charset" params))
- (beg (point-min))
+ ;; 1995/9/21 (c.f. tm-eng:105), 1995/10/3 (c.f. tm-eng:121)
+ ;; modified by Eric Ding <ericding@San-Jose.ate.slb.com>
+ (beg (point-min)) (end (point-max))
)
+ (remove-text-properties beg end '(face nil))
+ (mime/decode-region encoding beg end)
(if (and m (fboundp (setq m (cdr m))))
(funcall m beg (point-max) charset encoding)
(mime-viewer/default-code-convert-region beg (point-max)
charset encoding)
)
- (mime/decode-text/richtext-region beg (point-max))
+ (richtext-decode beg (point-max))
))
-
-;;; @ text/enriched
-;;;
-
-(defun mime/decode-text/enriched-region (beg end)
- (interactive "*r")
- (save-excursion
- (save-restriction
- (narrow-to-region beg end)
- (while (re-search-forward "[\n]+" nil t)
- (let ((str (buffer-substring (match-beginning 0)
- (match-end 0))))
- (if (string= str "\n")
- (replace-match " ")
- (replace-match (substring str 1))
- )))
- (goto-char beg)
- (let (cmd str (fb (point)) fe b e)
- (while (re-search-forward "<\\(<\\|[^<>\n\r \t]+>\\)" nil t)
- (setq b (match-beginning 0))
- (setq cmd (buffer-substring b (match-end 0)))
- (if (string= cmd "<<")
- (replace-match "<")
- (replace-match "")
- (setq cmd (downcase (substring cmd 1 (- (length cmd) 1))))
- )
- (cond ((string= cmd "param")
- (setq b (point))
- (save-excursion
- (save-restriction
- (if (search-forward "</param>" nil t)
- (progn
- (replace-match "")
- (setq e (point))
- )
- (setq e end)
- )))
- (delete-region b e)
- )
- ((member cmd mime/text/enriched-face-list)
- (setq b (point))
- (save-excursion
- (save-restriction
- (if (re-search-forward (concat "</" cmd ">") nil t)
- (progn
- (replace-match "")
- (setq e (point))
- )
- (setq e end)
- )))
- (mime/set-face-region b e cmd)
- )))
- (goto-char (point-max))
- (if (not (eq (preceding-char) ?\n))
- (insert "\n")
- )
- ))))
-
(defun mime-viewer/filter-text/enriched (ctype params encoding)
(let* ((mode mime::preview/original-major-mode)
(m (assq mode mime-viewer/code-converter-alist))
(charset (assoc "charset" params))
- (beg (point-min))
+ ;; 1995/9/21 (c.f. tm-eng:105), 1995/10/3 (c.f. tm-eng:121)
+ ;; modified by Eric Ding <ericding@San-Jose.ate.slb.com>
+ (beg (point-min)) (end (point-max))
)
+ (remove-text-properties beg end '(face nil))
+ (mime/decode-region encoding beg end)
(if (and m (fboundp (setq m (cdr m))))
(funcall m beg (point-max) charset encoding)
- (mime/code-convert-region-to-emacs beg (point-max)
- charset encoding)
+ (mime-viewer/default-code-convert-region beg (point-max)
+ charset encoding)
)
- (mime/decode-text/enriched-region beg (point-max))
+ (enriched-decode beg (point-max))
))
(set-alist 'mime-viewer/content-filter-alist
"text/enriched" (function mime-viewer/filter-text/enriched))
+
+
+;;; @ end
+;;;
+
+(provide 'tm-rich)
+
+(run-hooks 'tm-rich-load-hook)
+
+;;; tm-rich.el ends here