;;;
-;;; $Id: mel-b.el,v 1.6 1995/08/05 00:30:53 morioka Exp $
+;;; $Id: mel-b.el,v 2.0 1995/10/25 02:40:49 morioka Exp $
;;;
;;; @ variables
(defun base64-external-encode-region (beg end)
(save-excursion
- (apply (function call-process-region)
- beg end (car base64-external-encoder)
- t t nil (cdr base64-external-encoder))
- ))
+ (let ((selective-display nil) ;Disable ^M to nl translation.
+ (mc-flag nil) ;Mule
+ (kanji-flag nil)) ;NEmacs
+ (apply (function call-process-region)
+ beg end (car base64-external-encoder)
+ t t nil (cdr base64-external-encoder))
+ )))
(defun base64-external-decode-region (beg end)
(save-excursion
- (apply (function call-process-region)
- beg end (car base64-external-decoder)
- t t nil (cdr base64-external-decoder))
- ))
+ (let ((selective-display nil) ;Disable ^M to nl translation.
+ (mc-flag nil) ;Mule
+ (kanji-flag nil)) ;NEmacs
+ (apply (function call-process-region)
+ beg end (car base64-external-decoder)
+ t t nil (cdr base64-external-decoder))
+ )))
(defun base64-encode-region (beg end)
(interactive "r")
;;;
-;;; $Id: mel-q.el,v 2.0 1995/09/11 11:33:47 morioka Exp $
+;;; $Id: mel-q.el,v 2.1 1995/10/25 05:00:54 morioka Exp $
;;;
;;; @ constants
(defun quoted-printable-external-encode-region (beg end)
(save-excursion
- (apply (function call-process-region)
- beg end (car quoted-printable-external-encoder)
- t t nil (cdr quoted-printable-external-encoder))
- ))
+ (let ((selective-display nil) ;Disable ^M to nl translation.
+ (mc-flag nil) ;Mule
+ (kanji-flag nil)) ;NEmacs
+ (apply (function call-process-region)
+ beg end (car quoted-printable-external-encoder)
+ t t nil (cdr quoted-printable-external-encoder))
+ )))
(defun quoted-printable-external-decode-region (beg end)
(save-excursion
- (apply (function call-process-region)
- beg end (car quoted-printable-external-decoder)
- t t nil (cdr quoted-printable-external-decoder))
- ))
+ (let ((selective-display nil) ;Disable ^M to nl translation.
+ (mc-flag nil) ;Mule
+ (kanji-flag nil)) ;NEmacs
+ (apply (function call-process-region)
+ beg end (car quoted-printable-external-decoder)
+ t t nil (cdr quoted-printable-external-decoder))
+ )))
(defun quoted-printable-encode-region (beg end)
(interactive "r")
--- /dev/null
+;;;
+;;; $Id: mel-u.el,v 2.0 1995/10/30 06:01:29 morioka Exp $
+;;;
+
+;;; @ variables
+;;;
+
+(defvar uuencode-external-encoder '("uuencode" "-")
+ "*list of uuencode encoder program name and its arguments.")
+
+(defvar uuencode-external-decoder '("uudecode")
+ "*list of uuencode decoder program name and its arguments.")
+(list "sh" "-c" (format "(cd %s; uudecode)" mime/tmp-dir))
+
+(defvar mime/tmp-dir (or (getenv "TM_TMP_DIR") "/tmp/"))
+
+
+;;; @ external encoder
+;;;
+
+(cond ((boundp 'MULE)
+ (define-program-coding-system
+ nil (car uuencode-external-encoder) *noconv*)
+ (define-program-coding-system
+ nil (car uuencode-external-decoder) *noconv*)
+ )
+ ((boundp 'NEMACS)
+ (define-program-kanji-code
+ nil (car uuencode-external-encoder) 0)
+ (define-program-kanji-code
+ nil (car uuencode-external-decoder) 0)
+ ))
+
+(defun uuencode-external-encode-region (beg end)
+ (interactive "*r")
+ (save-excursion
+ (let ((selective-display nil) ;Disable ^M to nl translation.
+ (mc-flag nil) ;Mule
+ (kanji-flag nil)) ;NEmacs
+ (apply (function call-process-region)
+ beg end (car uuencode-external-encoder)
+ t t nil (cdr uuencode-external-encoder))
+ )))
+
+(defun uuencode-external-decode-region (beg end)
+ (interactive "*r")
+ (save-excursion
+ (let ((selective-display nil) ;Disable ^M to nl translation.
+ (mc-flag nil) ;Mule
+ (kanji-flag nil) ;NEmacs
+ (filename (save-excursion
+ (save-restriction
+ (narrow-to-region beg end)
+ (goto-char beg)
+ (if (re-search-forward "^begin [0-9]+ " nil t)
+ (if (looking-at ".+$")
+ (buffer-substring (match-beginning 0)
+ (match-end 0)
+ )
+ )))))
+ )
+ (if filename
+ (progn
+ (funcall (function call-process-region)
+ beg end "sh"
+ t t nil
+ "-c" (format "(cd %s; %s)"
+ mime/tmp-dir
+ (mapconcat (function identity)
+ uuencode-external-decoder
+ " ")
+ ))
+ (setq filename (expand-file-name filename mime/tmp-dir))
+ (let ((file-coding-system-for-read
+ (if (boundp 'MULE) *noconv*)) ; Mule
+ kanji-fileio-code) ; NEmacs
+ (insert-file-contents filename)
+ )
+ (delete-file filename)
+ ))
+ )))
+
+(defalias 'uuencode-encode-region 'uuencode-external-encode-region)
+(defalias 'uuencode-decode-region 'uuencode-external-decode-region)
+
+
+;;; @ end
+;;;
+
+(provide 'mel-u)
;;;
;;; by MORIOKA Tomohiko <morioka@jaist.ac.jp>, 1995/6/25
;;;
-;;; $Id: mel.el,v 1.4 1995/06/26 05:57:39 morioka Exp $
+;;; $Id: mel.el,v 3.1 1995/10/30 06:03:37 morioka Exp $
;;;
(autoload 'base64-encode-region "mel-b" nil t)
(autoload 'q-encoding-decode-string "mel-q")
(autoload 'q-encoding-encoded-length "mel-q")
+(autoload 'uuencode-encode-region "mel-u" nil t)
+(autoload 'uuencode-decode-region "mel-u" nil t)
+
+(defvar mime-encoding-method-alist
+ '(("base64" . base64-encode-region)
+ ("quoted-printable" . quoted-printable-encode-region)
+ ("x-uue" . uuencode-encode-region)
+ ))
+
+(defvar mime-decoding-method-alist
+ '(("base64" . base64-decode-region)
+ ("quoted-printable" . quoted-printable-decode-region)
+ ("x-uue" . uuencode-decode-region)
+ ))
+
+
+;;; @ region
+;;;
+
+(defun mime/encode-region (encoding beg end)
+ "Encode region BEG to END of current buffer using ENCODING. [mel.el]"
+ (interactive
+ (list (completing-read "encoding: "
+ mime-encoding-method-alist
+ nil t "base64")
+ (region-beginning) (region-end))
+ )
+ (let ((f (cdr (assoc encoding mime-encoding-method-alist))))
+ (if f
+ (funcall f beg end)
+ )))
+
+(defun mime/decode-region (encoding beg end)
+ "Decode region BEG to END of current buffer using ENCODING. [mel.el]"
+ (interactive
+ (list (completing-read "encoding: "
+ mime-decoding-method-alist
+ nil t "base64")
+ (region-beginning) (region-end))
+ )
+ (let ((f (cdr (assoc encoding mime-decoding-method-alist))))
+ (if f
+ (funcall f beg end)
+ )))
+
+(defalias 'mime-encode-region 'mime/encode-region)
+(defalias 'mime-decode-region 'mime/decode-region)
+
+
+;;; @ end
+;;;
+
(provide 'mel)