From: morioka Date: Sun, 11 Jan 1998 17:08:16 +0000 (+0000) Subject: mel of MEL 3.1. X-Git-Tag: mel-3_1 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=4bdf8987c74df1c947488eca0a92b8da25233458;p=elisp%2Fflim.git mel of MEL 3.1. --- diff --git a/mel-b.el b/mel-b.el index 5a0eda2..4fadcc3 100644 --- a/mel-b.el +++ b/mel-b.el @@ -1,5 +1,5 @@ ;;; -;;; $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 @@ -161,17 +161,23 @@ external decoder is called.") (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") diff --git a/mel-q.el b/mel-q.el index 6539033..a901440 100644 --- a/mel-q.el +++ b/mel-q.el @@ -1,5 +1,5 @@ ;;; -;;; $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 @@ -158,17 +158,23 @@ external decoder is called.") (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") diff --git a/mel-u.el b/mel-u.el new file mode 100644 index 0000000..d91c797 --- /dev/null +++ b/mel-u.el @@ -0,0 +1,90 @@ +;;; +;;; $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) diff --git a/mel.el b/mel.el index 8bc5da2..3a6982e 100644 --- a/mel.el +++ b/mel.el @@ -3,7 +3,7 @@ ;;; ;;; by MORIOKA Tomohiko , 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) @@ -22,4 +22,56 @@ (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)