Mercurial > hg > xemacs-beta
comparison lisp/mel/mel.el @ 40:7e54bd776075 r19-15b103
Import from CVS: tag r19-15b103
author | cvs |
---|---|
date | Mon, 13 Aug 2007 08:54:25 +0200 |
parents | 49a24b4fd526 |
children | 131b0175ea99 |
comparison
equal
deleted
inserted
replaced
39:06f275776fba | 40:7e54bd776075 |
---|---|
1 ;;; mel.el : a MIME encoding/decoding library | 1 ;;; mel.el : a MIME encoding/decoding library |
2 | 2 |
3 ;; Copyright (C) 1995,1996 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1995,1996,1997 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.3 1996/12/29 00:14:58 steve Exp $ | 8 ;; Version: $Id: mel.el,v 1.4 1997/03/22 05:29:07 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 | |
30 ;;; @ region | 39 ;;; @ region |
31 ;;; | 40 ;;; |
32 | 41 |
33 (autoload 'base64-encode-region "mel-b" nil t) | 42 (autoload 'base64-encode-region |
34 (autoload 'quoted-printable-encode-region "mel-q" nil t) | 43 "mel-b" "Encode current region by base64." t) |
35 (autoload 'uuencode-encode-region "mel-u" nil t) | 44 (autoload 'quoted-printable-encode-region |
36 (autoload 'gzip64-encode-region "mel-g" nil t) | 45 "mel-q" "Encode current region by Quoted-Printable." 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) | |
37 | 50 |
38 (defvar mime-encoding-method-alist | 51 (defvar mime-encoding-method-alist |
39 '(("base64" . base64-encode-region) | 52 '(("base64" . base64-encode-region) |
40 ("quoted-printable" . quoted-printable-encode-region) | 53 ("quoted-printable" . quoted-printable-encode-region) |
41 ("x-uue" . uuencode-encode-region) | 54 ("x-uue" . uuencode-encode-region) |
45 ("binary") | 58 ("binary") |
46 ) | 59 ) |
47 "Alist of encoding vs. corresponding method to encode region. | 60 "Alist of encoding vs. corresponding method to encode region. |
48 Each element looks like (STRING . FUNCTION) or (STRING . nil). | 61 Each element looks like (STRING . FUNCTION) or (STRING . nil). |
49 STRING is content-transfer-encoding. | 62 STRING is content-transfer-encoding. |
50 FUNCTION is region encoder and nil means not to encode. [mel.el]") | 63 FUNCTION is region encoder and nil means not to encode.") |
51 | 64 |
52 | 65 |
53 (autoload 'base64-decode-region "mel-b" nil t) | 66 (autoload 'base64-decode-region |
54 (autoload 'quoted-printable-decode-region "mel-q" nil t) | 67 "mel-b" "Decode current region by base64." t) |
55 (autoload 'uuencode-decode-region "mel-u" nil t) | 68 (autoload 'quoted-printable-decode-region |
56 (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) | |
57 | 74 |
58 (defvar mime-decoding-method-alist | 75 (defvar mime-decoding-method-alist |
59 '(("base64" . base64-decode-region) | 76 '(("base64" . base64-decode-region) |
60 ("quoted-printable" . quoted-printable-decode-region) | 77 ("quoted-printable" . quoted-printable-decode-region) |
61 ("x-uue" . uuencode-decode-region) | 78 ("x-uue" . uuencode-decode-region) |
63 ("x-gzip64" . gzip64-decode-region) | 80 ("x-gzip64" . gzip64-decode-region) |
64 ) | 81 ) |
65 "Alist of encoding vs. corresponding method to decode region. | 82 "Alist of encoding vs. corresponding method to decode region. |
66 Each element looks like (STRING . FUNCTION). | 83 Each element looks like (STRING . FUNCTION). |
67 STRING is content-transfer-encoding. | 84 STRING is content-transfer-encoding. |
68 FUNCTION is region decoder. [mel.el]") | 85 FUNCTION is region decoder.") |
69 | 86 |
70 | 87 |
71 (defun mime-encode-region (beg end encoding) | 88 (defun mime-encode-region (start end encoding) |
72 "Encode region BEG to END of current buffer using ENCODING. [mel.el]" | 89 "Encode region START to END of current buffer using ENCODING." |
73 (interactive | 90 (interactive |
74 (list (region-beginning) (region-end) | 91 (list (region-beginning) (region-end) |
75 (completing-read "encoding: " | 92 (completing-read "encoding: " |
76 mime-encoding-method-alist | 93 mime-encoding-method-alist |
77 nil t "base64")) | 94 nil t "base64")) |
78 ) | 95 ) |
79 (let ((f (cdr (assoc encoding mime-encoding-method-alist)))) | 96 (let ((f (cdr (assoc encoding mime-encoding-method-alist)))) |
80 (if f | 97 (if f |
81 (funcall f beg end) | 98 (funcall f start end) |
82 ))) | 99 ))) |
83 | 100 |
84 (defun mime-decode-region (beg end encoding) | 101 (defun mime-decode-region (start end encoding) |
85 "Decode region BEG to END of current buffer using ENCODING. [mel.el]" | 102 "Decode region START to END of current buffer using ENCODING." |
86 (interactive | 103 (interactive |
87 (list (region-beginning) (region-end) | 104 (list (region-beginning) (region-end) |
88 (completing-read "encoding: " | 105 (completing-read "encoding: " |
89 mime-decoding-method-alist | 106 mime-decoding-method-alist |
90 nil t "base64")) | 107 nil t "base64")) |
91 ) | 108 ) |
92 (let ((f (cdr (assoc encoding mime-decoding-method-alist)))) | 109 (let ((f (cdr (assoc encoding mime-decoding-method-alist)))) |
93 (if f | 110 (if f |
94 (funcall f beg end) | 111 (funcall f start end) |
95 ))) | 112 ))) |
96 | 113 |
97 | 114 |
98 ;;; @ file | 115 ;;; @ file |
99 ;;; | 116 ;;; |
100 | 117 |
101 (autoload 'base64-insert-encoded-file "mel-b" nil t) | 118 (autoload 'base64-insert-encoded-file |
102 (autoload 'quoted-printable-insert-encoded-file "mel-q" nil t) | 119 "mel-b" "Insert file encoded by base64." t) |
103 (autoload 'uuencode-insert-encoded-file "mel-u" nil t) | 120 (autoload 'quoted-printable-insert-encoded-file |
104 (autoload 'gzip64-insert-encoded-file "mel-g" nil t) | 121 "mel-q" "Insert file encoded by quoted-printable." 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) | |
105 | 126 |
106 (defvar mime-file-encoding-method-alist | 127 (defvar mime-file-encoding-method-alist |
107 '(("base64" . base64-insert-encoded-file) | 128 '(("base64" . base64-insert-encoded-file) |
108 ("quoted-printable" . quoted-printable-insert-encoded-file) | 129 ("quoted-printable" . quoted-printable-insert-encoded-file) |
109 ("x-uue" . uuencode-insert-encoded-file) | 130 ("x-uue" . uuencode-insert-encoded-file) |
113 ("binary" . insert-binary-file-contents-literally) | 134 ("binary" . insert-binary-file-contents-literally) |
114 ) | 135 ) |
115 "Alist of encoding vs. corresponding method to insert encoded file. | 136 "Alist of encoding vs. corresponding method to insert encoded file. |
116 Each element looks like (STRING . FUNCTION). | 137 Each element looks like (STRING . FUNCTION). |
117 STRING is content-transfer-encoding. | 138 STRING is content-transfer-encoding. |
118 FUNCTION is function to insert encoded file. [mel.el]") | 139 FUNCTION is function to insert encoded file.") |
119 | |
120 | 140 |
121 (defun mime-insert-encoded-file (filename encoding) | 141 (defun mime-insert-encoded-file (filename encoding) |
122 "Encode region BEG to END of current buffer using ENCODING. [mel.el]" | 142 "Insert file FILENAME encoded by ENCODING format." |
123 (interactive | 143 (interactive |
124 (list (read-file-name "Insert encoded file: ") | 144 (list (read-file-name "Insert encoded file: ") |
125 (completing-read "encoding: " | 145 (completing-read "encoding: " |
126 mime-encoding-method-alist | 146 mime-encoding-method-alist |
127 nil t "base64")) | 147 nil t "base64")) |