(mime-file-decoding-method-alist): New variable.
authormorioka <morioka>
Wed, 11 Mar 1998 16:51:15 +0000 (16:51 +0000)
committermorioka <morioka>
Wed, 11 Mar 1998 16:51:15 +0000 (16:51 +0000)
(mime-write-decoded-region): New function.

mel.el

diff --git a/mel.el b/mel.el
index 681be7b..c07e741 100644 (file)
--- a/mel.el
+++ b/mel.el
@@ -193,6 +193,21 @@ STRING is content-transfer-encoding.
 FUNCTION is function to insert encoded file.")
 
 ;;;###autoload
+(defvar mime-file-decoding-method-alist
+  '(("base64"           . base64-write-decoded-region)
+    ("quoted-printable" . quoted-printable-write-decoded-region)
+    ("x-uue"            . uuencode-write-decoded-region)
+    ("x-gzip64"         . gzip64-write-decoded-region)
+    ("7bit"            . write-region-as-binary)
+    ("8bit"            . write-region-as-binary)
+    ("binary"          . write-region-as-binary)
+    )
+  "Alist of encoding vs. corresponding method to write decoded region to file.
+Each element looks like (STRING . FUNCTION).
+STRING is content-transfer-encoding.
+FUNCTION is function to write decoded region to file.")
+
+;;;###autoload
 (defun mime-insert-encoded-file (filename encoding)
   "Insert file FILENAME encoded by ENCODING format."
   (interactive
@@ -206,6 +221,20 @@ FUNCTION is function to insert encoded file.")
        (funcall f filename)
       )))
 
+;;;###autoload
+(defun mime-write-decoded-region (start end filename encoding)
+  "Decode and write current region encoded by ENCODING into FILENAME.
+START and END are buffer positions."
+  (list (region-beginning) (region-end)
+       (read-file-name "Write decoded region to file: ")
+       (completing-read "encoding: "
+                        mime-file-decoding-method-alist
+                        nil t "base64"))
+  (let ((f (cdr (assoc encoding mime-file-decoding-method-alist))))
+    (if f
+       (funcall f start end filename)
+      )))
+
 
 ;;; @ end
 ;;;