;;; ;;; $Id: tm-rich.el,v 1.1 1994/09/05 14:34:06 morioka Exp morioka $ ;;; (provide 'tm-rich) (require 'tm-view) (require 'assoc) (require 'hilit19) (defun mime/get-text/enriched-face (str) (let ((sym (intern str))) (if (eq sym 'italic) 'modeline sym))) (defun mime/decode-text/enriched-region (beg end) (interactive "*r") (save-excursion (save-restriction (narrow-to-region beg end) (goto-char beg) (let (cmd sym (fb (point)) fe b e) (while (re-search-forward "[ \t\n\r]*<[^<>\n\r \t]+>[ \t\n\r]*" nil t) (setq cmd (buffer-substring (match-beginning 0) (match-end 0))) (replace-match "") (string-match "^[ \t\n\r]*<" cmd) (setq cmd (substring cmd (match-end 0))) (string-match ">[ \t\n\r]*$" cmd) (setq cmd (substring cmd 0 (match-beginning 0))) (setq sym (mime/get-text/enriched-face cmd)) (cond ((string= cmd "nl") (fill-region fb (point) t) (insert "\n") (setq fb (point)) ) ((member sym (face-list)) (if (not (bolp)) (insert " ") ) (setq b (point)) (save-excursion (save-restriction (if (re-search-forward (concat "[ \t\n\r]*[ \t\n\r]*") nil t) (progn (replace-match " ") (setq e (- (point) 1)) ) (setq e end) ))) (hilit-unhighlight-region b e) (hilit-region-set-face b e sym) ))) (fill-region fb (point) t) )))) (defun mime/decode-text/enriched-body () (interactive) (save-excursion (save-restriction (let ((beg (point-min)) (end (point-max))) (goto-char (point-min)) (if (search-forward "\n\n" nil t) (setq beg (match-end 0)) ) (mime/decode-text/enriched-region beg end) )))) (aput 'mime/content-filter-alist "text/enriched" (function mime/decode-text/enriched-body)) (aput 'mime/content-filter-alist "text/richtext" (function mime/decode-text/enriched-body))