annotate lisp/tm/tm-file.el @ 4:b82b59fe008d r19-15b3

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