1 ;;; mm-view.el --- Functions for viewing MIME objects
2 ;; Copyright (C) 1998 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
5 ;; This file is part of GNU Emacs.
7 ;; GNU Emacs is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation; either version 2, or (at your option)
12 ;; GNU Emacs is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GNU Emacs; see the file COPYING. If not, write to the
19 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 ;; Boston, MA 02111-1307, USA.
32 ;;; Functions for displaying various formats inline
35 (defun mm-inline-image (handle)
36 (let ((type (cadr (split-string (car (mm-handle-type handle)) "/")))
37 buffer-read-only image)
38 (mm-with-unibyte-buffer
39 (insert-buffer-substring (mm-handle-buffer handle))
40 (mm-decode-content-transfer-encoding
41 (mm-handle-encoding handle)
42 (car (mm-handle-type handle)))
43 (setq image (make-image-specifier
44 (vector (intern type) :data (buffer-string)))))
45 (let ((annot (make-annotation image nil 'text)))
46 (set-extent-property annot 'mm t)
47 (set-extent-property annot 'duplicable t)
48 (mm-insert-inline handle " \n"))))
50 (defun mm-inline-text (handle)
51 (let ((type (cadr (split-string (car (mm-handle-type handle)) "/")))
52 text buffer-read-only)
56 (insert-buffer-substring (mm-handle-buffer handle))
57 (mm-decode-content-transfer-encoding
58 (mm-handle-encoding handle)
59 (car (mm-handle-type handle)))
60 (setq text (buffer-string)))
64 (narrow-to-region b (point))
65 (let ((charset (mail-content-type-get
66 (mm-handle-type handle) 'charset)))
68 (mm-decode-body charset nil)))
69 (mm-handle-set-undisplayer
72 (let (buffer-read-only)
74 ,(set-marker (make-marker) (point-min))
75 ,(set-marker (make-marker) (point-max)))))))))
77 (let ((width (window-width)))
80 (mm-with-unibyte-buffer
81 (insert-buffer-substring (mm-handle-buffer handle))
82 (mm-decode-content-transfer-encoding
83 (mm-handle-encoding handle)
84 (car (mm-handle-type handle)))
86 (save-window-excursion
87 (let ((w3-strict-width width))
88 (w3-region (point-min) (point-max)))
89 (setq text (buffer-string))))))
90 (mm-insert-inline handle text))
91 ((or (equal type "enriched")
92 (equal type "richtext"))
94 (mm-with-unibyte-buffer
95 (insert-buffer-substring (mm-handle-buffer handle))
96 (mm-decode-content-transfer-encoding
97 (mm-handle-encoding handle)
98 (car (mm-handle-type handle)))
99 (save-window-excursion
100 (enriched-decode (point-min) (point-max))
101 (setq text (buffer-string)))))
102 (mm-insert-inline handle text))
105 (mm-with-unibyte-buffer
106 (insert-buffer-substring (mm-handle-buffer handle))
107 (mm-decode-content-transfer-encoding
108 (mm-handle-encoding handle)
109 (car (mm-handle-type handle)))
110 (setq text (buffer-string))))
111 (mm-insert-inline handle text)))))
113 (defun mm-insert-inline (handle text)
114 "Insert TEXT inline from HANDLE."
117 (mm-handle-set-undisplayer
120 (let (buffer-read-only)
121 (delete-region ,(set-marker (make-marker) b)
122 ,(set-marker (make-marker) (point))))))))
124 (defun mm-inline-audio (handle)
125 (message "Not implemented"))
127 (defun mm-view-sound-file ()
128 (message "Not implemented"))
130 (defun mm-w3-prepare-buffer ()
136 ;; mm-view.el ends here