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