4
|
1 ;;; mel.el : a MIME encoding/decoding library
|
|
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 ;; Created: 1995/6/25
|
10
|
8 ;; Version: $Id: mel.el,v 1.3 1996/12/29 00:14:58 steve Exp $
|
4
|
9 ;; Keywords: MIME, Base64, Quoted-Printable, uuencode, gzip64
|
|
10
|
|
11 ;; This file is part of MEL (MIME Encoding Library).
|
|
12
|
|
13 ;; This program is free software; you can redistribute it and/or
|
|
14 ;; modify it under the terms of the GNU General Public License as
|
|
15 ;; published by the Free Software Foundation; either version 2, or (at
|
|
16 ;; your option) any later version.
|
|
17
|
|
18 ;; This program is distributed in the hope that it will be useful, but
|
|
19 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
21 ;; General Public License for more details.
|
|
22
|
|
23 ;; You should have received a copy of the GNU General Public License
|
|
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the
|
|
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
26 ;; Boston, MA 02111-1307, USA.
|
|
27
|
|
28 ;;; Code:
|
|
29
|
|
30 ;;; @ region
|
|
31 ;;;
|
|
32
|
|
33 (autoload 'base64-encode-region "mel-b" nil t)
|
|
34 (autoload 'quoted-printable-encode-region "mel-q" nil t)
|
|
35 (autoload 'uuencode-encode-region "mel-u" nil t)
|
|
36 (autoload 'gzip64-encode-region "mel-g" nil t)
|
|
37
|
|
38 (defvar mime-encoding-method-alist
|
|
39 '(("base64" . base64-encode-region)
|
|
40 ("quoted-printable" . quoted-printable-encode-region)
|
|
41 ("x-uue" . uuencode-encode-region)
|
|
42 ("x-gzip64" . gzip64-encode-region)
|
|
43 ("7bit")
|
|
44 ("8bit")
|
|
45 ("binary")
|
10
|
46 )
|
|
47 "Alist of encoding vs. corresponding method to encode region.
|
|
48 Each element looks like (STRING . FUNCTION) or (STRING . nil).
|
|
49 STRING is content-transfer-encoding.
|
|
50 FUNCTION is region encoder and nil means not to encode. [mel.el]")
|
|
51
|
4
|
52
|
|
53 (autoload 'base64-decode-region "mel-b" nil t)
|
|
54 (autoload 'quoted-printable-decode-region "mel-q" nil t)
|
|
55 (autoload 'uuencode-decode-region "mel-u" nil t)
|
|
56 (autoload 'gzip64-decode-region "mel-g" nil t)
|
|
57
|
|
58 (defvar mime-decoding-method-alist
|
|
59 '(("base64" . base64-decode-region)
|
|
60 ("quoted-printable" . quoted-printable-decode-region)
|
|
61 ("x-uue" . uuencode-decode-region)
|
10
|
62 ("x-uuencode" . uuencode-decode-region)
|
4
|
63 ("x-gzip64" . gzip64-decode-region)
|
10
|
64 )
|
|
65 "Alist of encoding vs. corresponding method to decode region.
|
|
66 Each element looks like (STRING . FUNCTION).
|
|
67 STRING is content-transfer-encoding.
|
|
68 FUNCTION is region decoder. [mel.el]")
|
|
69
|
4
|
70
|
|
71 (defun mime-encode-region (beg end encoding)
|
|
72 "Encode region BEG to END of current buffer using ENCODING. [mel.el]"
|
|
73 (interactive
|
|
74 (list (region-beginning) (region-end)
|
|
75 (completing-read "encoding: "
|
|
76 mime-encoding-method-alist
|
|
77 nil t "base64"))
|
|
78 )
|
|
79 (let ((f (cdr (assoc encoding mime-encoding-method-alist))))
|
|
80 (if f
|
|
81 (funcall f beg end)
|
|
82 )))
|
|
83
|
|
84 (defun mime-decode-region (beg end encoding)
|
|
85 "Decode region BEG to END of current buffer using ENCODING. [mel.el]"
|
|
86 (interactive
|
|
87 (list (region-beginning) (region-end)
|
|
88 (completing-read "encoding: "
|
|
89 mime-decoding-method-alist
|
|
90 nil t "base64"))
|
|
91 )
|
|
92 (let ((f (cdr (assoc encoding mime-decoding-method-alist))))
|
|
93 (if f
|
|
94 (funcall f beg end)
|
|
95 )))
|
|
96
|
|
97
|
|
98 ;;; @ file
|
|
99 ;;;
|
|
100
|
|
101 (autoload 'base64-insert-encoded-file "mel-b" nil t)
|
|
102 (autoload 'quoted-printable-insert-encoded-file "mel-q" nil t)
|
|
103 (autoload 'uuencode-insert-encoded-file "mel-u" nil t)
|
|
104 (autoload 'gzip64-insert-encoded-file "mel-g" nil t)
|
|
105
|
|
106 (defvar mime-file-encoding-method-alist
|
|
107 '(("base64" . base64-insert-encoded-file)
|
|
108 ("quoted-printable" . quoted-printable-insert-encoded-file)
|
|
109 ("x-uue" . uuencode-insert-encoded-file)
|
|
110 ("x-gzip64" . gzip64-insert-encoded-file)
|
|
111 ("7bit" . insert-binary-file-contents-literally)
|
|
112 ("8bit" . insert-binary-file-contents-literally)
|
|
113 ("binary" . insert-binary-file-contents-literally)
|
10
|
114 )
|
|
115 "Alist of encoding vs. corresponding method to insert encoded file.
|
|
116 Each element looks like (STRING . FUNCTION).
|
|
117 STRING is content-transfer-encoding.
|
|
118 FUNCTION is function to insert encoded file. [mel.el]")
|
|
119
|
4
|
120
|
|
121 (defun mime-insert-encoded-file (filename encoding)
|
|
122 "Encode region BEG to END of current buffer using ENCODING. [mel.el]"
|
|
123 (interactive
|
|
124 (list (read-file-name "Insert encoded file: ")
|
|
125 (completing-read "encoding: "
|
|
126 mime-encoding-method-alist
|
|
127 nil t "base64"))
|
|
128 )
|
|
129 (let ((f (cdr (assoc encoding mime-file-encoding-method-alist))))
|
|
130 (if f
|
|
131 (funcall f filename)
|
|
132 )))
|
|
133
|
|
134
|
|
135 ;;; @ string
|
|
136 ;;;
|
|
137
|
|
138 (autoload 'base64-encode-string "mel-b")
|
|
139 (autoload 'base64-decode-string "mel-b")
|
|
140
|
|
141 (autoload 'q-encoding-encode-string-for-text "mel-q")
|
|
142 (autoload 'q-encoding-encode-string-for-comment "mel-q")
|
|
143 (autoload 'q-encoding-encode-string-for-phrase "mel-q")
|
|
144 (autoload 'q-encoding-encode-string "mel-q")
|
|
145 (autoload 'q-encoding-decode-string "mel-q")
|
|
146
|
|
147 (autoload 'base64-encoded-length "mel-b")
|
|
148 (autoload 'q-encoding-encoded-length "mel-q")
|
|
149
|
|
150
|
|
151 ;;; @ end
|
|
152 ;;;
|
|
153
|
|
154 (provide 'mel)
|
|
155
|
|
156 ;;; mel.el ends here.
|