comparison lisp/mel/mel.el @ 70:131b0175ea99 r20-0b30

Import from CVS: tag r20-0b30
author cvs
date Mon, 13 Aug 2007 09:02:59 +0200
parents 7e54bd776075
children c0c698873ce1
comparison
equal deleted inserted replaced
69:804d1389bcd6 70:131b0175ea99
1 ;;; mel.el : a MIME encoding/decoding library 1 ;;; mel.el : a MIME encoding/decoding library
2 2
3 ;; Copyright (C) 1995,1996,1997 Free Software Foundation, Inc. 3 ;; Copyright (C) 1995,1996 Free Software Foundation, Inc.
4 4
5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp> 5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; modified by Shuhei KOBAYASHI <shuhei-k@jaist.ac.jp> 6 ;; modified by Shuhei KOBAYASHI <shuhei-k@jaist.ac.jp>
7 ;; Created: 1995/6/25 7 ;; Created: 1995/6/25
8 ;; Version: $Id: mel.el,v 1.4 1997/03/22 05:29:07 steve Exp $ 8 ;; Version: $Id: mel.el,v 1.1.1.1 1996/12/18 22:43:38 steve Exp $
9 ;; Keywords: MIME, Base64, Quoted-Printable, uuencode, gzip64 9 ;; Keywords: MIME, Base64, Quoted-Printable, uuencode, gzip64
10 10
11 ;; This file is part of MEL (MIME Encoding Library). 11 ;; This file is part of MEL (MIME Encoding Library).
12 12
13 ;; This program is free software; you can redistribute it and/or 13 ;; This program is free software; you can redistribute it and/or
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, 25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
26 ;; Boston, MA 02111-1307, USA. 26 ;; Boston, MA 02111-1307, USA.
27 27
28 ;;; Code: 28 ;;; Code:
29 29
30 ;;; @ variable
31 ;;;
32
33 (defvar mime-temp-directory (or (getenv "MIME_TMP_DIR")
34 (getenv "TM_TMP_DIR")
35 "/tmp/")
36 "*Directory for temporary files.")
37
38
39 ;;; @ region 30 ;;; @ region
40 ;;; 31 ;;;
41 32
42 (autoload 'base64-encode-region 33 (autoload 'base64-encode-region "mel-b" nil t)
43 "mel-b" "Encode current region by base64." t) 34 (autoload 'quoted-printable-encode-region "mel-q" nil t)
44 (autoload 'quoted-printable-encode-region 35 (autoload 'uuencode-encode-region "mel-u" nil t)
45 "mel-q" "Encode current region by Quoted-Printable." t) 36 (autoload 'gzip64-encode-region "mel-g" nil t)
46 (autoload 'uuencode-encode-region
47 "mel-u" "Encode current region by unofficial uuencode format." t)
48 (autoload 'gzip64-encode-region
49 "mel-g" "Encode current region by unofficial x-gzip64 format." t)
50 37
51 (defvar mime-encoding-method-alist 38 (defvar mime-encoding-method-alist
52 '(("base64" . base64-encode-region) 39 '(("base64" . base64-encode-region)
53 ("quoted-printable" . quoted-printable-encode-region) 40 ("quoted-printable" . quoted-printable-encode-region)
54 ("x-uue" . uuencode-encode-region) 41 ("x-uue" . uuencode-encode-region)
55 ("x-gzip64" . gzip64-encode-region) 42 ("x-gzip64" . gzip64-encode-region)
56 ("7bit") 43 ("7bit")
57 ("8bit") 44 ("8bit")
58 ("binary") 45 ("binary")
59 ) 46 ))
60 "Alist of encoding vs. corresponding method to encode region.
61 Each element looks like (STRING . FUNCTION) or (STRING . nil).
62 STRING is content-transfer-encoding.
63 FUNCTION is region encoder and nil means not to encode.")
64 47
65 48 (autoload 'base64-decode-region "mel-b" nil t)
66 (autoload 'base64-decode-region 49 (autoload 'quoted-printable-decode-region "mel-q" nil t)
67 "mel-b" "Decode current region by base64." t) 50 (autoload 'uuencode-decode-region "mel-u" nil t)
68 (autoload 'quoted-printable-decode-region 51 (autoload 'gzip64-decode-region "mel-g" nil t)
69 "mel-q" "Decode current region by Quoted-Printable." t)
70 (autoload 'uuencode-decode-region
71 "mel-u" "Decode current region by unofficial uuencode format." t)
72 (autoload 'gzip64-decode-region
73 "mel-g" "Decode current region by unofficial x-gzip64 format." t)
74 52
75 (defvar mime-decoding-method-alist 53 (defvar mime-decoding-method-alist
76 '(("base64" . base64-decode-region) 54 '(("base64" . base64-decode-region)
77 ("quoted-printable" . quoted-printable-decode-region) 55 ("quoted-printable" . quoted-printable-decode-region)
78 ("x-uue" . uuencode-decode-region) 56 ("x-uue" . uuencode-decode-region)
79 ("x-uuencode" . uuencode-decode-region)
80 ("x-gzip64" . gzip64-decode-region) 57 ("x-gzip64" . gzip64-decode-region)
81 ) 58 ))
82 "Alist of encoding vs. corresponding method to decode region.
83 Each element looks like (STRING . FUNCTION).
84 STRING is content-transfer-encoding.
85 FUNCTION is region decoder.")
86 59
87 60 (defun mime-encode-region (beg end encoding)
88 (defun mime-encode-region (start end encoding) 61 "Encode region BEG to END of current buffer using ENCODING. [mel.el]"
89 "Encode region START to END of current buffer using ENCODING."
90 (interactive 62 (interactive
91 (list (region-beginning) (region-end) 63 (list (region-beginning) (region-end)
92 (completing-read "encoding: " 64 (completing-read "encoding: "
93 mime-encoding-method-alist 65 mime-encoding-method-alist
94 nil t "base64")) 66 nil t "base64"))
95 ) 67 )
96 (let ((f (cdr (assoc encoding mime-encoding-method-alist)))) 68 (let ((f (cdr (assoc encoding mime-encoding-method-alist))))
97 (if f 69 (if f
98 (funcall f start end) 70 (funcall f beg end)
99 ))) 71 )))
100 72
101 (defun mime-decode-region (start end encoding) 73 (defun mime-decode-region (beg end encoding)
102 "Decode region START to END of current buffer using ENCODING." 74 "Decode region BEG to END of current buffer using ENCODING. [mel.el]"
103 (interactive 75 (interactive
104 (list (region-beginning) (region-end) 76 (list (region-beginning) (region-end)
105 (completing-read "encoding: " 77 (completing-read "encoding: "
106 mime-decoding-method-alist 78 mime-decoding-method-alist
107 nil t "base64")) 79 nil t "base64"))
108 ) 80 )
109 (let ((f (cdr (assoc encoding mime-decoding-method-alist)))) 81 (let ((f (cdr (assoc encoding mime-decoding-method-alist))))
110 (if f 82 (if f
111 (funcall f start end) 83 (funcall f beg end)
112 ))) 84 )))
113 85
114 86
115 ;;; @ file 87 ;;; @ file
116 ;;; 88 ;;;
117 89
118 (autoload 'base64-insert-encoded-file 90 (autoload 'base64-insert-encoded-file "mel-b" nil t)
119 "mel-b" "Insert file encoded by base64." t) 91 (autoload 'quoted-printable-insert-encoded-file "mel-q" nil t)
120 (autoload 'quoted-printable-insert-encoded-file 92 (autoload 'uuencode-insert-encoded-file "mel-u" nil t)
121 "mel-q" "Insert file encoded by quoted-printable." t) 93 (autoload 'gzip64-insert-encoded-file "mel-g" nil t)
122 (autoload 'uuencode-insert-encoded-file
123 "mel-u" "Insert file encoded by unofficial uuencode format." t)
124 (autoload 'gzip64-insert-encoded-file
125 "mel-g" "Insert file encoded by unofficial gzip64 format." t)
126 94
127 (defvar mime-file-encoding-method-alist 95 (defvar mime-file-encoding-method-alist
128 '(("base64" . base64-insert-encoded-file) 96 '(("base64" . base64-insert-encoded-file)
129 ("quoted-printable" . quoted-printable-insert-encoded-file) 97 ("quoted-printable" . quoted-printable-insert-encoded-file)
130 ("x-uue" . uuencode-insert-encoded-file) 98 ("x-uue" . uuencode-insert-encoded-file)
131 ("x-gzip64" . gzip64-insert-encoded-file) 99 ("x-gzip64" . gzip64-insert-encoded-file)
132 ("7bit" . insert-binary-file-contents-literally) 100 ("7bit" . insert-binary-file-contents-literally)
133 ("8bit" . insert-binary-file-contents-literally) 101 ("8bit" . insert-binary-file-contents-literally)
134 ("binary" . insert-binary-file-contents-literally) 102 ("binary" . insert-binary-file-contents-literally)
135 ) 103 ))
136 "Alist of encoding vs. corresponding method to insert encoded file.
137 Each element looks like (STRING . FUNCTION).
138 STRING is content-transfer-encoding.
139 FUNCTION is function to insert encoded file.")
140 104
141 (defun mime-insert-encoded-file (filename encoding) 105 (defun mime-insert-encoded-file (filename encoding)
142 "Insert file FILENAME encoded by ENCODING format." 106 "Encode region BEG to END of current buffer using ENCODING. [mel.el]"
143 (interactive 107 (interactive
144 (list (read-file-name "Insert encoded file: ") 108 (list (read-file-name "Insert encoded file: ")
145 (completing-read "encoding: " 109 (completing-read "encoding: "
146 mime-encoding-method-alist 110 mime-encoding-method-alist
147 nil t "base64")) 111 nil t "base64"))