* Sync up to flim-1_12_5 from flim-1_12_1.
[elisp/flim.git] / mel-u.el
index a2efb09..3328e56 100644 (file)
--- a/mel-u.el
+++ b/mel-u.el
@@ -6,7 +6,7 @@
 ;; Created: 1995/10/25
 ;; Keywords: uuencode
 
 ;; Created: 1995/10/25
 ;; Keywords: uuencode
 
-;; This file is part of MEL (MIME Encoding Library).
+;; This file is part of FLIM (Faithful Library about Internet Message).
 
 ;; This program is free software; you can redistribute it and/or
 ;; modify it under the terms of the GNU General Public License as
 
 ;; This program is free software; you can redistribute it and/or
 ;; modify it under the terms of the GNU General Public License as
 ;;; Code:
 
 (require 'emu)
 ;;; Code:
 
 (require 'emu)
-(require 'mel)
+(require 'mime-def)
+
+
+(mel-define-backend "x-uue")
 
 
 ;;; @ variables
 
 
 ;;; @ variables
@@ -35,8 +38,7 @@
 (defvar uuencode-external-encoder '("uuencode" "-")
   "*list of uuencode encoder program name and its arguments.")
 
 (defvar uuencode-external-encoder '("uuencode" "-")
   "*list of uuencode encoder program name and its arguments.")
 
-(defvar uuencode-external-decoder
-  (list "sh" "-c" (format "(cd %s; uudecode)" mime-temp-directory))
+(defvar uuencode-external-decoder '("sh" "-c" "uudecode")
   "*list of uuencode decoder program name and its arguments.")
 
 
   "*list of uuencode decoder program name and its arguments.")
 
 
@@ -75,13 +77,13 @@ variable `uuencode-external-decoder'."
                            (if (looking-at ".+$")
                                (buffer-substring (match-beginning 0)
                                                  (match-end 0))
                            (if (looking-at ".+$")
                                (buffer-substring (match-beginning 0)
                                                  (match-end 0))
-                             ))))))
+                             )))))
+         (default-directory temporary-file-directory))
       (if filename
          (as-binary-process
           (apply (function call-process-region)
                  start end (car uuencode-external-decoder)
                  t nil nil (cdr uuencode-external-decoder))
       (if filename
          (as-binary-process
           (apply (function call-process-region)
                  start end (car uuencode-external-decoder)
                  t nil nil (cdr uuencode-external-decoder))
-          (setq filename (expand-file-name filename mime-temp-directory))
           (as-binary-input-file (insert-file-contents filename))
           ;; The previous line causes the buffer to be made read-only, I
           ;; do not pretend to understand the control flow leading to this
           (as-binary-input-file (insert-file-contents filename))
           ;; The previous line causes the buffer to be made read-only, I
           ;; do not pretend to understand the control flow leading to this
@@ -94,14 +96,32 @@ variable `uuencode-external-decoder'."
           ))
       )))
 
           ))
       )))
 
-(defalias 'uuencode-encode-region 'uuencode-external-encode-region)
-(defalias 'uuencode-decode-region 'uuencode-external-decode-region)
+(mel-define-method-function (mime-encode-region start end (nil "x-uue"))
+                           'uuencode-external-encode-region)
+(mel-define-method-function (mime-decode-region start end (nil "x-uue"))
+                           'uuencode-external-decode-region)
+
+
+;;; @ encoder/decoder for string
+;;;
+
+(mel-define-method mime-encode-string (string (nil "x-uue"))
+  (with-temp-buffer
+    (insert string)
+    (uuencode-external-encode-region (point-min)(point-max))
+    (buffer-string)))
+
+(mel-define-method mime-decode-string (string (nil "x-uue"))
+  (with-temp-buffer
+    (insert string)
+    (uuencode-external-decode-region (point-min)(point-max))
+    (buffer-string)))
 
 
 ;;; @ uuencode encoder/decoder for file
 ;;;
 
 
 
 ;;; @ uuencode encoder/decoder for file
 ;;;
 
-(defun uuencode-insert-encoded-file (filename)
+(mel-define-method mime-insert-encoded-file (filename (nil "x-uue"))
   "Insert file encoded by unofficial uuencode format.
 This function uses external uuencode encoder which is specified by
 variable `uuencode-external-encoder'."
   "Insert file encoded by unofficial uuencode format.
 This function uses external uuencode encoder which is specified by
 variable `uuencode-external-encoder'."
@@ -110,7 +130,8 @@ variable `uuencode-external-encoder'."
                (file-name-nondirectory filename))
   )
 
                (file-name-nondirectory filename))
   )
 
-(defun uuencode-write-decoded-region (start end filename)
+(mel-define-method mime-write-decoded-region (start end filename
+                                                   (nil "x-uue"))
   "Decode and write current region encoded by uuencode into FILENAME.
 START and END are buffer positions."
   (interactive
   "Decode and write current region encoded by uuencode into FILENAME.
 START and END are buffer positions."
   (interactive
@@ -126,7 +147,7 @@ START and END are buffer positions."
                            (buffer-substring (match-beginning 0)
                                              (match-end 0))
                          )))))
                            (buffer-substring (match-beginning 0)
                                              (match-end 0))
                          )))))
-         (default-directory (or (getenv "TMP")(getenv "TEMP") "/tmp")))
+         (default-directory temporary-file-directory))
       (if file
          (as-binary-process
           (apply (function call-process-region)
       (if file
          (as-binary-process
           (apply (function call-process-region)
@@ -141,4 +162,6 @@ START and END are buffer positions."
 
 (provide 'mel-u)
 
 
 (provide 'mel-u)
 
+(mel-define-backend "x-uuencode" ("x-uue"))
+
 ;;; mel-u.el ends here
 ;;; mel-u.el ends here