1 ;;; mm-extern.el --- showing message/external-body
2 ;; Copyright (C) 2000 Free Software Foundation, Inc.
4 ;; Author: Shenghuo Zhu <zsh@cs.rochester.edu>
5 ;; Keywords: message external-body
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published
11 ;; by the Free Software Foundation; either version 2, or (at your
12 ;; option) any later version.
14 ;; GNU Emacs is distributed in the hope that it will be useful, but
15 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 ;; General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
34 (defvar mm-extern-function-alist
35 '((local-file . mm-extern-local-file)
37 ;;; (ftp . mm-extern-ftp)
38 ;;; (anon-ftp . mm-extern-anon-ftp)
39 ;;; (tftp . mm-extern-tftp)
40 ;;; (mail-server . mm-extern-mail-server))
43 (defun mm-extern-local-file (handle)
44 (let ((name (cdr (assq 'name (cdr (mm-handle-type handle)))))
45 (coding-system-for-read mm-binary-coding-system))
46 (mm-disable-multibyte-mule4)
47 (mm-insert-file-contents name nil nil nil nil t)))
49 (defun mm-extern-url (handle)
51 (let ((url (cdr (assq 'url (cdr (mm-handle-type handle)))))
52 (name buffer-file-name)
53 (coding-system-for-read mm-binary-coding-system))
55 (error "URL is not specified"))
56 (mm-with-unibyte-current-buffer-mule4
57 (url-insert-file-contents url))
58 (mm-disable-multibyte-mule4)
59 (setq buffer-file-name name)))
62 (defun mm-inline-external-body (handle &optional no-display)
63 "Show the external-body part of HANDLE.
64 This function replaces the buffer of HANDLE with a buffer contains
66 If NO-DISPLAY is nil, display it. Otherwise, do nothing after replacing."
67 (let* ((access-type (cdr (assq 'access-type
68 (cdr (mm-handle-type handle)))))
69 (func (cdr (assq (intern access-type) mm-extern-function-alist)))
70 gnus-displaying-mime buf
72 (unless (mm-handle-cache handle)
74 (error (format "Access type (%s) is not supported." access-type)))
76 (mm-insert-part handle)
77 (goto-char (point-max))
79 (setq handles (mm-dissect-buffer t)))
80 (unless (bufferp (car handles))
81 (mm-destroy-parts handles)
82 (error "Multipart external body is not supported."))
83 (save-excursion ;; single part
84 (kill-buffer (mm-handle-buffer handles))
85 (set-buffer (setq buf (generate-new-buffer " *mm*")))
89 ;; Don't require gnus-util
90 (when (gnus-buffer-exists-p buf)
93 (setcar handles (current-buffer))
94 (mm-handle-set-cache handle handles))
95 (push handles gnus-article-mime-handles))
99 (narrow-to-region (point) (point))
100 (gnus-display-mime (mm-handle-cache handle))
101 (mm-handle-set-undisplayer
104 (let (buffer-read-only)
106 ;; This is only valid on XEmacs.
107 (mapcar (lambda (prop)
109 (face-property 'default prop) (current-buffer)))
110 '(background background-pixmap foreground))
112 (delete-region ,(point-min-marker) ,(point-max-marker))))))))))
114 ;; mm-extern.el ends here