From d45720e98a56a7646e60dd7a098c7fcc0334f195 Mon Sep 17 00:00:00 2001 From: morioka Date: Sun, 11 Jan 1998 17:13:50 +0000 Subject: [PATCH] mel of MEL 3.2. --- mel-b.el | 106 +++++++++++++++++++++++++++++++++++++------------------------- mel-q.el | 56 +++++++++++++++++---------------- mel-u.el | 22 +++++-------- mel.el | 5 ++- 4 files changed, 105 insertions(+), 84 deletions(-) diff --git a/mel-b.el b/mel-b.el index 4fadcc3..e8fcaba 100644 --- a/mel-b.el +++ b/mel-b.el @@ -1,5 +1,5 @@ ;;; -;;; $Id: mel-b.el,v 2.0 1995/10/25 02:40:49 morioka Exp $ +;;; $Id: mel-b.el,v 3.0 1995/11/02 04:14:51 morioka Exp $ ;;; ;;; @ variables @@ -83,21 +83,41 @@ external decoder is called.") ;;; (defun base64-encode-string (string) - (let* ((es (mapconcat - (function - (lambda (pack) - (mapconcat (function char-to-string) - (apply (function base64-encode-chars) pack) - "") - )) - (pack-sequence string 3) - "")) - (m (mod (length es) 4)) - ) - (concat es (cond ((= m 3) "=") - ((= m 2) "==") - )) - )) + (let ((len (length string)) + (b 0)(e 57) + dest) + (while (< e len) + (setq dest + (concat dest + (mapconcat + (function + (lambda (pack) + (mapconcat (function char-to-string) + (apply (function base64-encode-chars) pack) + "") + )) + (pack-sequence (substring string b e) 3) + "") + "\n")) + (setq b e + e (+ e 57) + ) + ) + (let* ((es (mapconcat + (function + (lambda (pack) + (mapconcat (function char-to-string) + (apply (function base64-encode-chars) pack) + "") + )) + (pack-sequence (substring string b) 3) + "")) + (m (mod (length es) 4)) + ) + (concat dest es (cond ((= m 3) "=") + ((= m 2) "==") + )) + ))) (defun base64-decode-string (string) (mapconcat (function @@ -113,6 +133,19 @@ external decoder is called.") ;;; @ encode/decode base64 region ;;; +(defun base64-internal-encode-region (beg end) + (save-excursion + (save-restriction + (narrow-to-region beg end) + (let ((str (buffer-substring beg end))) + (delete-region beg end) + (insert (base64-encode-string str)) + ) + (or (bolp) + (insert "\n") + ) + ))) + (defun base64-internal-decode-region (beg end) (save-excursion (save-restriction @@ -126,26 +159,6 @@ external decoder is called.") (insert (base64-decode-string str)) )))) -(defun base64-internal-encode-region (beg end) - (save-excursion - (let* ((str (base64-encode-string (buffer-substring beg end))) - (len (length str)) - (i 0) - (j (if (>= len 76) - 76 - len)) - ) - (delete-region beg end) - (goto-char beg) - (while (< j len) - (insert (substring str i j)) - (insert "\n") - (setq i j) - (setq j (+ i 76)) - ) - (insert (substring str i)) - ))) - (cond ((boundp 'MULE) (define-program-coding-system nil (car base64-external-encoder) *noconv*) @@ -161,12 +174,21 @@ external decoder is called.") (defun base64-external-encode-region (beg end) (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 base64-external-encoder) - t t nil (cdr base64-external-encoder)) + (save-restriction + (narrow-to-region beg end) + (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)) + ) + ;; for OS/2 + ;; regularize line break code + (goto-char (point-min)) + (while (re-search-forward "\r$" nil t) + (replace-match "") + ) ))) (defun base64-external-decode-region (beg end) diff --git a/mel-q.el b/mel-q.el index a901440..36f2d2f 100644 --- a/mel-q.el +++ b/mel-q.el @@ -1,5 +1,5 @@ ;;; -;;; $Id: mel-q.el,v 2.1 1995/10/25 05:00:54 morioka Exp $ +;;; $Id: mel-q.el,v 3.0 1995/11/02 03:48:01 morioka Exp $ ;;; ;;; @ constants @@ -48,10 +48,13 @@ external decoder is called.") (let ((i 0)) (mapconcat (function (lambda (chr) - (cond ((or (< chr 32) (< 126 chr) (eq chr ?=)) + (cond ((eq chr ?\n) + (setq i 0) + "\n") + ((or (< chr 32) (< 126 chr) (eq chr ?=)) (if (>= i 73) (progn - (setq i 0) + (setq i 3) (concat "=\n" (quoted-printable-quote-char chr)) ) (progn @@ -60,7 +63,7 @@ external decoder is called.") ))) (t (if (>= i 75) (progn - (setq i 0) + (setq i 1) (concat "=\n" (char-to-string chr)) ) (progn @@ -105,23 +108,13 @@ external decoder is called.") (save-excursion (save-restriction (narrow-to-region beg end) - (goto-char (point-min)) - (catch 'tag - (let (b e str) - (while t - (beginning-of-line) (setq b (point)) - (end-of-line) (setq e (point)) - (if (< b e) - (progn - (setq str (buffer-substring b e)) - (delete-region b e) - (insert (quoted-printable-encode-string str)) - )) - (if (eobp) - (throw 'tag nil) - ) - (forward-char 1) - ))) + (let ((str (buffer-substring beg end))) + (delete-region beg end) + (insert (quoted-printable-encode-string str)) + ) + (or (bolp) + (insert "=\n") + ) ))) (defun quoted-printable-internal-decode-region (beg end) @@ -158,12 +151,21 @@ external decoder is called.") (defun quoted-printable-external-encode-region (beg end) (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 quoted-printable-external-encoder) - t t nil (cdr quoted-printable-external-encoder)) + (save-restriction + (narrow-to-region beg end) + (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)) + ) + ;; for OS/2 + ;; regularize line break code + (goto-char (point-min)) + (while (re-search-forward "\r$" nil t) + (replace-match "") + ) ))) (defun quoted-printable-external-decode-region (beg end) diff --git a/mel-u.el b/mel-u.el index d91c797..f2f6a50 100644 --- a/mel-u.el +++ b/mel-u.el @@ -1,18 +1,18 @@ ;;; -;;; $Id: mel-u.el,v 2.0 1995/10/30 06:01:29 morioka Exp $ +;;; $Id: mel-u.el,v 2.1 1995/11/01 06:03:14 morioka Exp $ ;;; ;;; @ variables ;;; +(defvar mime/tmp-dir (or (getenv "TM_TMP_DIR") "/tmp/")) + (defvar uuencode-external-encoder '("uuencode" "-") "*list of uuencode encoder program name and its arguments.") -(defvar uuencode-external-decoder '("uudecode") +(defvar uuencode-external-decoder + (list "sh" "-c" (format "(cd %s; uudecode)" mime/tmp-dir)) "*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 @@ -61,15 +61,9 @@ ) (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 - " ") - )) + (apply (function call-process-region) + beg end (car uuencode-external-decoder) + t t nil (cdr uuencode-external-decoder)) (setq filename (expand-file-name filename mime/tmp-dir)) (let ((file-coding-system-for-read (if (boundp 'MULE) *noconv*)) ; Mule diff --git a/mel.el b/mel.el index 3a6982e..6448f1f 100644 --- a/mel.el +++ b/mel.el @@ -3,7 +3,7 @@ ;;; ;;; by MORIOKA Tomohiko , 1995/6/25 ;;; -;;; $Id: mel.el,v 3.1 1995/10/30 06:03:37 morioka Exp $ +;;; $Id: mel.el,v 3.2 1995/11/02 04:19:47 morioka Exp $ ;;; (autoload 'base64-encode-region "mel-b" nil t) @@ -29,6 +29,9 @@ '(("base64" . base64-encode-region) ("quoted-printable" . quoted-printable-encode-region) ("x-uue" . uuencode-encode-region) + ("7bit") + ("8bit") + ("binary") )) (defvar mime-decoding-method-alist -- 1.7.10.4