4
|
1 ;;; tm-file.el --- tm-view internal method for file extraction
|
|
2
|
|
3 ;; Copyright (C) 1995,1996 Free Software Foundation, Inc.
|
|
4
|
|
5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
|
|
6 ;; modified by Shuhei KOBAYASHI <shuhei-k@jaist.ac.jp>
|
|
7 ;; Version: $Id: tm-file.el,v 1.1.1.1 1996/12/18 03:55:31 steve Exp $
|
|
8 ;; Keywords: mail, news, MIME, multimedia, file, extract
|
|
9
|
|
10 ;; This file is part of tm (Tools for MIME).
|
|
11
|
|
12 ;; This program is free software; you can redistribute it and/or
|
|
13 ;; modify it under the terms of the GNU General Public License as
|
|
14 ;; published by the Free Software Foundation; either version 2, or (at
|
|
15 ;; your option) any later version.
|
|
16
|
|
17 ;; This program is distributed in the hope that it will be useful, but
|
|
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
20 ;; General Public License for more details.
|
|
21
|
|
22 ;; You should have received a copy of the GNU General Public License
|
|
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
|
|
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
25 ;; Boston, MA 02111-1307, USA.
|
|
26
|
|
27 ;;; Code:
|
|
28
|
|
29 (require 'tm-view)
|
|
30
|
|
31 (defun mime-article/extract-file (beg end cal)
|
|
32 (goto-char beg)
|
|
33 (let* ((name
|
|
34 (save-restriction
|
|
35 (narrow-to-region beg end)
|
|
36 (mime-article/get-filename cal)
|
|
37 ))
|
|
38 (encoding (cdr (assq 'encoding cal)))
|
|
39 (filename
|
|
40 (if (and name (not (string-equal 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 (if (file-exists-p filename)
|
|
56 (or (yes-or-no-p (format "File %s exists. Save anyway? " filename))
|
|
57 (error "")))
|
|
58 (re-search-forward "\n\n")
|
|
59 (append-to-buffer tmp-buf (match-end 0) end)
|
|
60 (save-excursion
|
|
61 (set-buffer tmp-buf)
|
|
62 (mime-decode-region (point-min)(point-max) encoding)
|
|
63 (let ((coding-system-for-write 'no-conversion)
|
|
64 (mc-flag nil) ; for Mule
|
|
65 (file-coding-system
|
|
66 (if (featurep 'mule) *noconv*))
|
|
67 kanji-flag ; for NEmacs
|
|
68 (emx-binary-mode t) ; for OS/2
|
|
69 jka-compr-compression-info-list ; for jka-compr
|
|
70 jam-zcat-filename-list ; for jam-zcat
|
|
71 require-final-newline)
|
|
72 (write-file filename)
|
|
73 )
|
|
74 (kill-buffer tmp-buf)
|
|
75 )))
|
|
76
|
|
77
|
|
78 ;;; @ setup
|
|
79 ;;;
|
|
80
|
|
81 (set-atype 'mime/content-decoding-condition
|
|
82 '((type . "application/octet-stream")
|
|
83 (method . mime-article/extract-file)
|
|
84 )
|
|
85 'ignore '(method)
|
|
86 'replacement)
|
|
87
|
|
88 (set-atype 'mime/content-decoding-condition
|
|
89 '((mode . "extract")
|
|
90 (method . mime-article/extract-file)
|
|
91 )
|
|
92 'remove
|
|
93 '((method "tm-file" nil 'file 'type 'encoding 'mode 'name)
|
|
94 (mode . "extract"))
|
|
95 'replacement)
|
|
96
|
|
97
|
|
98 ;;; @ end
|
|
99 ;;;
|
|
100
|
|
101 (provide 'tm-file)
|
|
102
|
|
103 ;;; end of tm-file.el
|