tm 7.33.
[elisp/tm.git] / tm-file.el
1 ;;;
2 ;;; tm-file.el --- tm-view internal method for file extraction
3 ;;;
4 ;;; Copyright (C) 1995 Free Software Foundation, Inc.
5 ;;; Copyright (C) 1995 MORIOKA Tomohiko
6 ;;;
7 ;;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
8 ;;; Version:
9 ;;;     $Id: tm-file.el,v 7.0 1995/12/12 00:55:25 morioka Exp $
10 ;;; Keywords: mail, news, MIME, multimedia
11 ;;;
12 ;;; This file is part of tm (Tools for MIME).
13 ;;;
14 ;;; This program is free software; you can redistribute it and/or
15 ;;; modify it under the terms of the GNU General Public License as
16 ;;; published by the Free Software Foundation; either version 2, or
17 ;;; (at your option) any later version.
18 ;;;
19 ;;; This program is distributed in the hope that it will be useful,
20 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
22 ;;; General Public License for more details.
23 ;;;
24 ;;; You should have received a copy of the GNU General Public License
25 ;;; along with This program.  If not, write to the Free Software
26 ;;; Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
27 ;;;
28 ;;; Code:
29
30 (require 'tm-view)
31
32 (defun mime-article/extract-file (beg end cal)
33   (let* ((name (or (cdr (assoc "name" cal))
34                    (cdr (assoc "x-name" cal))))
35          (encoding (cdr (assq 'encoding cal)))
36          (file-coding-system *noconv*)
37          (filename
38           (if name
39               (expand-file-name name
40                                 (call-interactively
41                                  (function
42                                   (lambda (dir)
43                                     (interactive "DDirectory: ")
44                                     dir))))
45             (call-interactively
46              (function
47               (lambda (file)
48                 (interactive "FFilename: ")
49                 (expand-file-name file))))))
50          (the-buf (current-buffer))
51          (tmp-buf (generate-new-buffer (file-name-nondirectory filename)))
52          )
53     (goto-char beg)
54     (re-search-forward "\n\n")
55     (append-to-buffer tmp-buf (match-end 0) end)
56     (save-excursion
57       (set-buffer tmp-buf)
58       (mime/decode-region encoding (point-min)(point-max))
59       (let ((mc-flag nil)                   ; for Mule
60             (file-coding-system
61              (if (featurep 'mule) *noconv*))
62             kanji-flag                      ; for NEmacs
63             (emx-binary-mode t)             ; for OS/2
64             jka-compr-compression-info-list ; for jka-compr
65             jam-zcat-filename-list          ; for jam-zcat
66             require-final-newline)
67         (write-file filename)
68         )
69       (kill-buffer tmp-buf)
70       )))
71
72
73 ;;; @ setup
74 ;;;
75
76 (set-atype 'mime/content-decoding-condition
77            '((mode . "extract")
78              (method . mime-article/extract-file)
79              ))
80
81 (set-atype 'mime/content-decoding-condition
82            '((type . "application/octet-stream")
83              (method . mime-article/extract-file)
84              ))
85
86
87 ;;; @ end
88 ;;;
89
90 (provide 'tm-file)