(mime-content-types): Apply "Shin'ichiro Tanaka"
[elisp/semi.git] / mime-w3.el
index 7d0e3d8..fec612c 100644 (file)
 (require 'w3)
 (require 'mime-text)
 
+(defmacro mime-put-keymap-region (start end keymap)
+  `(put-text-property ,start ,end
+                     ',(if (featurep 'xemacs)
+                           'keymap
+                         'local-map)
+                     ,keymap))
+
+(defmacro mime-save-background-color (&rest body)
+  (if (featurep 'xemacs)
+      `(let ((color (color-name (face-background 'default))))
+        (prog1
+            (progn ,@body)
+          (font-set-face-background 'default color (current-buffer))
+          ))
+    (cons 'progn body)))
+
 (defun mime-preview-text/html (entity situation)
-  (save-restriction
-    (narrow-to-region (point-max)(point-max))
-    (mime-text-insert-decoded-body entity)
-    (let ((beg (point-min)))
-      (remove-text-properties beg (point-max) '(face nil))
-      (w3-region beg (point-max))
-      )))
+  (goto-char (point-max))
+  (let ((p (point)))
+    (insert "\n")
+    (goto-char p)
+    (mime-save-background-color
+     (save-restriction
+       (narrow-to-region p p)
+       (mime-text-insert-decoded-body entity)
+       (w3-region p (point-max))
+       (mime-put-keymap-region p (point-max) w3-mode-map)
+       ))))
 
 
 ;;; @ end