From e1535b34f0dd8d725f41e8f01422d377b17ed144 Mon Sep 17 00:00:00 2001 From: morioka Date: Sat, 19 Sep 1998 18:03:58 +0000 Subject: [PATCH] Define method functions of mel. (mime-insert-encoded-file): Use `mel-define-method'; abolish `base64-insert-encoded-file'; don't use external encoder. (mime-write-decoded-region): Use `mel-define-method'; abolish `base64-write-decoded-region'; don't use external decoder. - Move `base64-encoded-length' to mel.el. --- mel-b.el | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/mel-b.el b/mel-b.el index ae5472a..deb54ff 100644 --- a/mel-b.el +++ b/mel-b.el @@ -284,7 +284,25 @@ metamail or XEmacs package)." (base64-internal-decode-string string))) -(defun base64-insert-encoded-file (filename) +(mel-define-method-function (mime-encode-string string (nil "base64")) + 'base64-encode-string) +(mel-define-method-function (mime-decode-string string (nil "base64")) + 'base64-decode-string) +(mel-define-method-function (mime-encode-region start end (nil "base64")) + 'base64-encode-region) +(mel-define-method-function (mime-decode-region start end (nil "base64")) + 'base64-decode-region) + +(mel-define-method-function (encoded-text-encode-string string (nil "B")) + 'base64-encode-string) + +(mel-define-method encoded-text-decode-string (string (nil "B")) + (if (and (string-match B-encoded-text-regexp string) + (string= string (match-string 0 string))) + (base64-decode-string string) + (error "Invalid encoded-text %s" string))) + +(mel-define-method mime-insert-encoded-file (filename (nil "base64")) "Encode contents of file FILENAME to base64, and insert the result. It calls external base64 encoder specified by `base64-external-encoder'. So you must install the program (maybe @@ -304,7 +322,8 @@ mmencode included in metamail or XEmacs package)." (insert "\n")) )) -(defun base64-write-decoded-region (start end filename) +(mel-define-method mime-write-decoded-region (start end filename + (nil "base64")) "Decode and write current region encoded by base64 into FILENAME. START and END are buffer positions." (interactive @@ -328,13 +347,6 @@ START and END are buffer positions." ;;; @ etc ;;; -(defun base64-encoded-length (string) - (let ((len (length string))) - (* (+ (/ len 3) - (if (= (mod len 3) 0) 0 1) - ) 4) - )) - (defun pack-sequence (seq size) "Split sequence SEQ into SIZE elements packs, and return list of packs. [mel-b; tl-seq function]" -- 1.7.10.4