From 6769bf5954ca2bf221dfa9a41e2d47b24a135d79 Mon Sep 17 00:00:00 2001 From: akr Date: Fri, 9 Oct 1998 12:23:11 +0000 Subject: [PATCH] * Sync up to flim-1_10_2 from flim-1_10_0. * mime-def.el (mime-library-product): Bump up to FLAM-DOODLE 1.10.1. --- ChangeLog | 106 ++++++++++++++++++++++++++++++++ DOODLE-VERSION | 2 +- FLIM-ELS | 3 +- FLIM-VERSION | 6 +- Makefile | 2 +- mel-b-dl.el | 3 - mel-g.el | 27 +++++++-- mel-u.el | 34 +++++++++-- mel.el | 56 ++++------------- mime-def.el | 113 ++++++++++++++++++++++++++++------ mime-en.sgml | 181 ++++++++++++++++++++++++++++++++++++++----------------- mime-en.texi | 184 ++++++++++++++++++++++++++++++++++++++------------------ mime-ja.sgml | 179 ++++++++++++++++++++++++++++++++++++++---------------- mime-ja.texi | 180 +++++++++++++++++++++++++++++++++++++----------------- 14 files changed, 778 insertions(+), 298 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4dc2481..22b8735 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +1998-10-09 Tanaka Akira + + * Sync up to flim-1_10_2 from flim-1_10_0. + + * mime-def.el (mime-library-product): Bump up to FLAM-DOODLE + 1.10.1. + 1998-09-30 Tanaka Akira * Sync up with flim-1_10_0. @@ -1189,6 +1196,105 @@ * eword-decode.el: Copied from AKEMI branch of SEMI. +1998-10-08 MORIOKA Tomohiko + + * FLIM: Version 1.10.2 (Kintetsu-Miyazu) was released. + + * mime-def.el, mel.el, mel-b-dl.el: Move variable + `base64-dl-module' from mel-b-dl.el and mel.el to mime-def.el. + +1998-10-08 MORIOKA Tomohiko + + * mel.el (mel-ccl-module): New variable; use it to check mel-ccl + is available. + + * FLIM-ELS: Don't install mel-ccl for anything older than MULE + 2.3. + +1998-10-08 MORIOKA Tomohiko + + * mel-u.el: Use `mel-define-backend' to define "x-uue". + Define "x-uuencode" as a clone of "x-uue". + + * Move variable `mel-encoding-module-alist' from mel.el to + mime-def.el. + + * mel.el (mel-find-function): Use function + `mel-find-function-from-obarray'. + Use `mel-define-backend' to define "7bit", "8bit" and "binary"; + don't define methods of "8bit" and "binary"; inherit methods from + "7bit". + + * mime-def.el (mel-service-list): New variable. + (mel-define-service): New implementation. + (mel-find-function-from-obarray): New inline function. + (mel-copy-method): New inline function. + (mel-copy-backend): New inline function. + (mel-define-backend): New macro. + +1998-10-08 MORIOKA Tomohiko + + * mel-u.el: Define method functions of mel. + (mime-encode-region): Use `mel-define-method-function'; abolish + `uuencode-encode-region'. + (mime-decode-region): Use `mel-define-method-function'; abolish + `uuencode-decode-region'. + (mime-encode-string): New method. + (mime-decode-string): New method. + (mime-insert-encoded-file): Use `mel-define-method'; abolish + `uuencode-insert-encoded-file'. + (mime-write-decoded-region): Use `mel-define-method'; abolish + `uuencode-write-decoded-region'. + +1998-10-07 MORIOKA Tomohiko + + * mime-def.el (mel-define-service): Add DOC. + (mel-define-method): Add DOC. + (mel-define-method-function): Add DOC. + + * mime-en.sgml, mime-ja.sgml: Modify for FLIM 1.10. + + +1998-10-07 MORIOKA Tomohiko + + * FLIM: Version 1.10.1 (Miyamaki) was released. + +1998-10-06 MORIOKA Tomohiko + + * mel-g.el: Define method functions of mel. + (mime-encode-region): Use `mel-define-method-function'; abolish + `gzip64-encode-region'. + (mime-decode-region): Use `mel-define-method-function'; abolish + `gzip64-decode-region'. + (mime-encode-string): New method. + (mime-decode-string): New method. + (mime-insert-encoded-file): Use `mel-define-method'; abolish + `gzip64-insert-encoded-file'. + (mime-write-decoded-region): Use `mel-define-method'; abolish + `gzip64-write-decoded-region'. + + * mime-def.el (mime-library-product): New variable; abolish + `mime-library-version'. + (mime-product-name): New macro. + (mime-product-version): New macro. + (mime-product-code-name): New macro. + (mime-library-version): Renamed from + `mime-library-version-string'; use `mime-library-product', + `mime-product-name', `mime-product-version' and + `mime-product-code-name'. + + * mime-def.el (mm-define-backend): Add DOC. + (mm-define-method): Add DOC. + + * mel.el (mime-encoding-list): Modify DOC to add description about + optional argument SERVICE. + +1998-10-04 MORIOKA Tomohiko + + * mime-ja.sgml, mime-en.sgml (mm-backend module): Write + description of `mm-define-backend' and `mm-define-method'. + + 1998-09-29 MORIOKA Tomohiko * FLIM: Version 1.10.0 (K-Dòdo)-A was released. diff --git a/DOODLE-VERSION b/DOODLE-VERSION index e8770a7..f6dac3a 100644 --- a/DOODLE-VERSION +++ b/DOODLE-VERSION @@ -20,7 +20,7 @@ Order is not significant. 14 $B3A(B $B$+$-(B 10R6.5/10.0 FLAM-DOODLE 1.9.4 15 $B?<;Y;R(B $B$3$-$/$A$J$7(B 10YR7.5/8.0 FLAM-DOODLE 1.9.5 16 $B4;;R(B $B$3$&$8(B 7.5YR7.0/11.0 FLAM-DOODLE 1.10.0 - 17 $B5`MU(B $B$/$A$P(B 10YR7.5/10.0 + 17 $B5`MU(B $B$/$A$P(B 10YR7.5/10.0 FLAM-DOODLE 1.10.1 18 $B@VGrFK(B $B$"$+$7$m$D$k$P$_(B 5.0YR8.0/6.0 19 $B>.F&(B $B$"$:$-(B 2.5R3.5/5.0 20 $BIrF:Cc(B $B$($S$A$c(B 5.0R4.0/11.0 diff --git a/FLIM-ELS b/FLIM-ELS index 7c80cd5..bb5e91c 100644 --- a/FLIM-ELS +++ b/FLIM-ELS @@ -35,7 +35,8 @@ (setq flim-modules (cons 'mel-b-dl flim-modules)) ) -(if (featurep 'mule) +(if (and (featurep 'mule) + (not (and (boundp 'MULE) MULE))) (setq flim-modules (cons 'mel-ccl flim-modules)) ) diff --git a/FLIM-VERSION b/FLIM-VERSION index f865c35..11c4653 100644 --- a/FLIM-VERSION +++ b/FLIM-VERSION @@ -23,10 +23,10 @@ 1.9.1 Tonosh-Dò-A $(BIYLnAq(B 1.9.2 Shin-Tanabe $(B?7EDJU(B 1.10.0 K-Dòdo-A $(B6=8M(B ------ Miyamaki $(B;0;3LZ(B ------ Kintetsu-Miyazu $(B6aE45\DE(B +1.10.1 Miyamaki $(B;0;3LZ(B +1.10.2 Kintetsu-Miyazu $(B6aE45\DE(B ----- Komada $(B9}ED(B ------ Shin-H-Dòsono-A $(B?7=K1`(B +----- Shin-H-Dòsono-A $(B?7=K1`(B ; <=> JR $(BJRD.@~(B $(B=K1`(B ----- Kizugawadai $(BLZDE@nBf(B ----- Yamadagawa $(B;3ED@n(B ----- Takanohara $(B9b$N86(B diff --git a/Makefile b/Makefile index 9c7d9b3..e06536a 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ # PACKAGE = flim -VERSION = 1.10.0 +VERSION = 1.10.2 TAR = tar RM = /bin/rm -f diff --git a/mel-b-dl.el b/mel-b-dl.el index 1d3fb14..0f0f22e 100644 --- a/mel-b-dl.el +++ b/mel-b-dl.el @@ -28,9 +28,6 @@ (require 'mime-def) (eval-and-compile - (defvar base64-dl-module - (expand-file-name "base64.so" exec-directory)) - (defvar base64-dl-handle (and (file-exists-p base64-dl-module) (dynamic-link base64-dl-module))) diff --git a/mel-g.el b/mel-g.el index 73db30f..bc2c510 100644 --- a/mel-g.el +++ b/mel-g.el @@ -82,21 +82,40 @@ ) )) -(defalias 'gzip64-encode-region 'gzip64-external-encode-region) -(defalias 'gzip64-decode-region 'gzip64-external-decode-region) +(mel-define-method-function (mime-encode-region start end (nil "x-gzip64")) + 'gzip64-external-encode-region) +(mel-define-method-function (mime-decode-region start end (nil "x-gzip64")) + 'gzip64-external-decode-region) + + +;;; @ encoder/decoder for string +;;; + +(mel-define-method mime-encode-string (string (nil "x-gzip64")) + (with-temp-buffer + (insert string) + (gzip64-external-encode-region (point-min)(point-max)) + (buffer-string))) + +(mel-define-method mime-decode-string (string (nil "x-gzip64")) + (with-temp-buffer + (insert string) + (gzip64-external-decode-region (point-min)(point-max)) + (buffer-string))) ;;; @ encoder/decoder for file ;;; -(defun gzip64-insert-encoded-file (filename) +(mel-define-method mime-insert-encoded-file (filename (nil "x-gzip64")) (interactive (list (read-file-name "Insert encoded file: "))) (apply (function call-process) (car gzip64-external-encoder) filename t nil (cdr gzip64-external-encoder)) ) -(defun gzip64-write-decoded-region (start end filename) +(mel-define-method mime-write-decoded-region (start end filename + (nil "x-gzip64")) "Decode and write current region encoded by gzip64 into FILENAME. START and END are buffer positions." (interactive diff --git a/mel-u.el b/mel-u.el index d004d60..5a756aa 100644 --- a/mel-u.el +++ b/mel-u.el @@ -6,7 +6,7 @@ ;; 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 @@ -29,6 +29,9 @@ (require 'mime-def) +(mel-define-backend "x-uue") + + ;;; @ variables ;;; @@ -93,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 ;;; -(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'." @@ -109,7 +130,8 @@ variable `uuencode-external-encoder'." (file-name-nondirectory filename)) ) -(defun uuencode-write-decoded-region (start end filename) +(mel-define-method mime-write-decoded-region (start end filename + (nil "x-gzip64")) "Decode and write current region encoded by uuencode into FILENAME. START and END are buffer positions." (interactive @@ -140,4 +162,6 @@ START and END are buffer positions." (provide 'mel-u) +(mel-define-backend "x-uuencode" ("x-uue")) + ;;; mel-u.el ends here diff --git a/mel.el b/mel.el index 16bc0e0..9495b46 100644 --- a/mel.el +++ b/mel.el @@ -34,10 +34,10 @@ :group 'mime :type '(repeat string)) -(defvar mel-encoding-module-alist nil) - (defun mime-encoding-list (&optional service) - "Return list of Content-Transfer-Encoding." + "Return list of Content-Transfer-Encoding. +If SERVICE is specified, it returns available list of +Content-Transfer-Encoding for it." (if service (let (dest) (mapatoms (lambda (sym) @@ -72,36 +72,23 @@ ))) (defsubst mel-find-function (service encoding) - (let* ((oba (symbol-value (intern (format "%s-obarray" service)))) - (f (intern-soft encoding oba))) - (or f - (let ((rest (cdr (assoc encoding mel-encoding-module-alist)))) - (while (and rest - (progn - (require (car rest)) - (null (setq f (intern-soft encoding oba))) - )) - (setq rest (cdr rest)) - ) - f)))) + (mel-find-function-from-obarray + (symbol-value (intern (format "%s-obarray" service))) encoding)) ;;; @ setting for modules ;;; -(defvar base64-dl-module - (and (fboundp 'dynamic-link) - (let ((path (expand-file-name "base64.so" exec-directory))) - (and (file-exists-p path) - path)))) - +(defvar mel-ccl-module + (and (featurep 'mule) + (module-installed-p 'mel-ccl))) (mel-use-module 'mel-b '("base64" "B")) (mel-use-module 'mel-q '("quoted-printable" "Q")) (mel-use-module 'mel-g '("x-gzip64")) (mel-use-module 'mel-u '("x-uue" "x-uuencode")) -(if (featurep 'mule) +(if mel-ccl-module (mel-use-module 'mel-ccl '("base64" "quoted-printable" "B" "Q")) ) @@ -109,6 +96,7 @@ (mel-use-module 'mel-b-dl '("base64" "B")) ) +(mel-define-backend "7bit") (mel-define-method-function (mime-encode-string string (nil "7bit")) 'identity) (mel-define-method-function (mime-decode-string string (nil "7bit")) @@ -121,29 +109,9 @@ start end filename (nil "7bit")) 'write-region-as-binary) -(mel-define-method-function (mime-encode-string string (nil "8bit")) - 'identity) -(mel-define-method-function (mime-decode-string string (nil "8bit")) - 'identity) -(mel-define-method mime-encode-region (start end (nil "8bit"))) -(mel-define-method mime-decode-region (start end (nil "8bit"))) -(mel-define-method-function (mime-insert-encoded-file filename (nil "8bit")) - 'insert-file-contents-as-binary) -(mel-define-method-function (mime-write-decoded-region - start end filename (nil "8bit")) - 'write-region-as-binary) +(mel-define-backend "8bit" ("7bit")) -(mel-define-method-function (mime-encode-string string (nil "binary")) - 'identity) -(mel-define-method-function (mime-decode-string string (nil "binary")) - 'identity) -(mel-define-method mime-encode-region (start end (nil "binary"))) -(mel-define-method mime-decode-region (start end (nil "binary"))) -(mel-define-method-function (mime-insert-encoded-file filename (nil "binary")) - 'insert-file-contents-as-binary) -(mel-define-method-function (mime-write-decoded-region - start end filename (nil "binary")) - 'write-region-as-binary) +(mel-define-backend "binary" ("8bit")) ;;; @ region diff --git a/mime-def.el b/mime-def.el index c870f25..4a69a34 100644 --- a/mime-def.el +++ b/mime-def.el @@ -24,15 +24,24 @@ ;;; Code: -(defconst mime-library-version - '("FLAM-DOODLE" "$B4;;R(B 7.5YR7.0/11.0" 1 10 0) - "Implementation name, version name and numbers of MIME-library package.") +(defconst mime-library-product ["FLAM-DOODLE" (1 10 1) "µàÍÕ 10YR7.5/10.0"] + "Product name, version number and code name of MIME-library package.") + +(defmacro mime-product-name (product) + `(aref ,product 0)) + +(defmacro mime-product-version (product) + `(aref ,product 1)) -(defconst mime-library-version-string - `,(concat (car mime-library-version) " " +(defmacro mime-product-code-name (product) + `(aref ,product 2)) + +(defconst mime-library-version + (eval-when-compile + (concat (mime-product-name mime-library-product) " " (mapconcat #'number-to-string - (cddr mime-library-version) ".") - " - \"" (cadr mime-library-version) "\"")) + (mime-product-version mime-library-product) ".") + " - \"" (mime-product-code-name mime-library-product) "\""))) ;;; @ variables @@ -309,6 +318,9 @@ message/rfc822, `mime-entity' structures of them are included in (defvar mime-entity-implementation-alist nil) (defmacro mm-define-backend (type &optional parents) + "Define TYPE as a mm-backend. +If PARENTS is specified, TYPE inherits PARENTS. +Each parent must be backend name (symbol)." (if parents `(let ((rest ',(reverse parents))) (while rest @@ -321,6 +333,11 @@ message/rfc822, `mime-entity' structures of them are included in )))) (defmacro mm-define-method (name args &rest body) + "Define NAME as a method function of (nth 1 (car ARGS)) backend. + +ARGS is like an argument list of lambda, but (car ARGS) must be +specialized parameter. (car (car ARGS)) is name of variable and (nth +1 (car ARGS)) is name of backend." (let* ((specializer (car args)) (class (nth 1 specializer)) (self (car specializer))) @@ -355,21 +372,72 @@ message/rfc822, `mime-entity' structures of them are included in ;;; @ for mel-backend ;;; +(defvar mel-service-list nil) + (defmacro mel-define-service (name &optional args &rest rest) - (if args - `(progn - (defvar ,(intern (format "%s-obarray" name)) (make-vector 1 nil)) - (defun ,name ,args - ,@rest - (funcall (mel-find-function ',name ,(car (last args))) - ,@(mm-arglist-to-arguments (butlast args))) - )) - `(defvar ,(intern (format "%s-obarray" name)) (make-vector 1 nil)) - )) + "Define NAME as a service for Content-Transfer-Encodings. +If ARGS is specified, NAME is defined as a generic function for the +service." + `(progn + (add-to-list 'mel-service-list ',name) + (defvar ,(intern (format "%s-obarray" name)) (make-vector 1 nil)) + ,@(if args + `((defun ,name ,args + ,@rest + (funcall (mel-find-function ',name ,(car (last args))) + ,@(mm-arglist-to-arguments (butlast args))) + ))) + )) (put 'mel-define-service 'lisp-indent-function 'defun) + +(defvar mel-encoding-module-alist nil) + +(defsubst mel-find-function-from-obarray (ob-array encoding) + (let* ((f (intern-soft encoding ob-array))) + (or f + (let ((rest (cdr (assoc encoding mel-encoding-module-alist)))) + (while (and rest + (progn + (require (car rest)) + (null (setq f (intern-soft encoding ob-array))) + )) + (setq rest (cdr rest)) + ) + f)))) + +(defsubst mel-copy-method (service src-backend dst-backend) + (let* ((oa (symbol-value (intern (format "%s-obarray" service)))) + (f (mel-find-function-from-obarray oa src-backend)) + sym) + (when f + (setq sym (intern dst-backend oa)) + (or (fboundp sym) + (fset sym (symbol-function f)) + )))) + +(defsubst mel-copy-backend (src-backend dst-backend) + (let ((services mel-service-list)) + (while services + (mel-copy-method (car services) src-backend dst-backend) + (setq services (cdr services))))) + +(defmacro mel-define-backend (type &optional parents) + "Define TYPE as a mel-backend. +If PARENTS is specified, TYPE inherits PARENTS. +Each parent must be backend name (string)." + (cons 'progn + (mapcar (lambda (parent) + `(mel-copy-backend ,parent ,type) + ) + parents))) + (defmacro mel-define-method (name args &rest body) + "Define NAME as a method function of (nth 1 (car (last ARGS))) backend. +ARGS is like an argument list of lambda, but (car (last ARGS)) must be +specialized parameter. (car (car (last ARGS))) is name of variable +and (nth 1 (car (last ARGS))) is name of backend (encoding)." (let* ((specializer (car (last args))) (class (nth 1 specializer))) `(progn @@ -381,6 +449,11 @@ message/rfc822, `mime-entity' structures of them are included in (put 'mel-define-method 'lisp-indent-function 'defun) (defmacro mel-define-method-function (spec function) + "Set SPEC's function definition to FUNCTION. +First element of SPEC is service. +Rest of ARGS is like an argument list of lambda, but (car (last ARGS)) +must be specialized parameter. (car (car (last ARGS))) is name of +variable and (nth 1 (car (last ARGS))) is name of backend (encoding)." (let* ((name (car spec)) (args (cdr spec)) (specializer (car (last args))) @@ -401,6 +474,12 @@ message/rfc822, `mime-entity' structures of them are included in (intern ,class ,(intern (format "%s-obarray" name)))) ))) +(defvar base64-dl-module + (and (fboundp 'dynamic-link) + (let ((path (expand-file-name "base64.so" exec-directory))) + (and (file-exists-p path) + path)))) + ;;; @ end ;;; diff --git a/mime-en.sgml b/mime-en.sgml index ed4b19f..1aeb63c 100644 --- a/mime-en.sgml +++ b/mime-en.sgml @@ -1,6 +1,6 @@ -FLIM 1.9 Manual about MIME Features +<title>FLIM 1.10 Manual about MIME Features <author>MORIOKA Tomohiko <mail>morioka@jaist.ac.jp</mail> <date>1998/07/01 @@ -393,12 +393,42 @@ return the result. </defun> -<h3> How to make mm-backend +<h3> Definition of mm-backend <node> mm-backend module <p> -(It is not written yet, sorry. (^_^;) +<defmacro name="mm-define-backend"> +<args> type +<opts> parents <p> -(Please read mm*.el) +Define <var>type</var> as a mm-backend. +<p> +If <var>PARENTS</var> is specified, <var>type</var> inherits parents. +Each parent must be representation-type. +<p> +Example: +<p> +<lisp> +(mm-define-backend chao (generic)) +</lisp> +</defmacro> + +<defmacro name="mm-define-method"> +<args> name args <rest> body +<p> +Define <var>name</var> as a method function of (nth 1 (car +<var>args</var>)) backend. +<p> +<var>args</var> is like an argument list of lambda, but (car +<var>args</var>) must be specialized parameter. (car (car +<var>args</var>)) is name of variable and (nth 1 (car +<var>args</var>)) is name of backend (representation-type). +<p> +Example: +<p> +<lisp> +(mm-define-method entity-cooked-p ((entity chao)) nil) +</lisp> +</defmacro> <h1> Information of Content-Type field @@ -636,8 +666,8 @@ Content-Transfer-Encoding $BMs$,B8:_$7$J$$>l9g$O(B </defun> -<h2> Region encoding/decoding -<node> Region encoder/decoder +<h2> Encoder/decoder +<node> encoder/decoder <p> <defun name="mime-encode-region"> <args> start end encoding @@ -653,49 +683,14 @@ Decode region <var>start</var> to <var>end</var> of current buffer using <var>encoding</var>. </defun> -<defvar name="mime-encoding-method-alist"> -<p> -Alist of encoding vs. corresponding method to encode region. -<p> -Each element looks like <code>(STRING . FUNCTION)</code> or -<code>(STRING . nil)</code>. <var>string</var> is -content-transfer-encoding. <code>function</code> is region encoder -and <code>nil</code> means not to encode. -</defvar> -<defvar name="mime-decoding-method-alist"> -<p> -Alist of encoding vs. corresponding method to decode region. -<p> -Each element looks like <code>(STRING . FUNCTION)</code> or -<code>(STRING . nil)</code>. <var>string</var> is -content-transfer-encoding. <code>function</code> is region decoder -and <code>nil</code> means not to decode. -</defvar> - - -<h2> String encoding/decoding -<node> String encoder/decoder -<p> <defun name="mime-decode-string"> <args> string encoding <p> <var>string</var> $B$r(B <var>encoding</var> $B$H$7$FI|9f$7$?7k2L$rJV$7$^$9!#(B </defun> -<defvar name="mime-string-decoding-method-alist"> -<p> -Alist of encoding vs. corresponding method to decode string. -<p> -Each element looks like <code>(STRING . FUNCTION)</code>. -STRING is content-transfer-encoding. -FUNCTION is string decoder. -</defvar> - -<h2> File encoding/decoding -<node> File encoder/decoder -<p> <defun name="mime-insert-encoded-file"> <args> filename encoding <p> @@ -711,24 +706,102 @@ Decode and write current region encoded by <var>encoding</var> into <var>start</var> and <var>end</var> are buffer positions. </defun> -<defvar name="mime-file-encoding-method-alist"> + +<h2> Other utilities +<node> Encoding information <p> -Alist of encoding vs. corresponding method to insert encoded file. +<defun name="mime-encoding-list"> + <opts> SERVICE <p> -Each element looks like <code>(STRING . FUNCTION)</code>. STRING is -content-transfer-encoding. FUNCTION is function to insert encoded -file. -</defvar> +Return list of Content-Transfer-Encoding. +<p> +If <var>service</var> is specified, it returns available list of +Content-Transfer-Encoding for it. +</defun> -<defvar name="mime-file-decoding-method-alist"> +<defun name="mime-encoding-alist"> + <opts> SERVICE <p> -Alist of encoding vs. corresponding method to write decoded region to -file. +Return table of Content-Transfer-Encoding for completion. <p> -Each element looks like <code>(STRING . FUNCTION)</code>. STRING is -content-transfer-encoding. FUNCTION is function to write decoded -region to file. -</defvar> +If <var>service</var> is specified, it returns available list of +Content-Transfer-Encoding for it. +</defun> + + +<h2> How to write encoder/decoder module +<node> mel-backend +<p> +<defmacro name="mel-define-method"> +<args> name args <rest> body +<p> +Define <var>name</var> as a method function of (nth 1 (car (last +<var>args</var>))) backend. +<p> +<var>args</var> is like an argument list of lambda, but (car (last +<var>args</var>)) must be specialized parameter. (car (car (last +<var>args</var>))) is name of variable and (nth 1 (car (last +<var>args</var>))) is name of backend (encoding). +<p> +Example: +<p> +<lisp> +(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 + (list (region-beginning) (region-end) + (read-file-name "Write decoded region to file: "))) + (let ((str (buffer-substring start end))) + (with-temp-buffer + (insert (decode-base64-string str)) + (write-region-as-binary (point-min) (point-max) filename) + ))) +</lisp> +</defmacro> + +<defmacro name="mel-define-method-function"> +<args> spec function +<p> +Set <var>spec</var>'s function definition to <var>function</var>. +<p> +First element of <var>spec</var> is service. +<p> +Rest of <var>args</var> is like an argument list of lambda, but (car +(last <var>args</var>)) must be specialized parameter. (car (car +(last <var>args</var>))) is name of variable and (nth 1 (car (last +<var>args</var>))) is name of backend (encoding). +<p> +Example: +<p> +<lisp> +(mel-define-method-function (mime-encode-string string (nil "base64")) + 'encode-base64-string) +</lisp> +</defmacro> + + +<h2> How to add encoding/decoding service +<node> generic function for mel-backend +<p> +<defmacro name="mel-define-service"> +<args> name +<opts> args doc-string +<p> +Define <var>name</var> as a service for Content-Transfer-Encodings. +<p> +If <var>args</var> is specified, <var>name</var> is defined as a +generic function for the service. +<p> +Example: +<p> +<lisp> +(mel-define-service encoded-text-encode-string (string encoding) + "Encode STRING as encoded-text using ENCODING. +ENCODING must be string.") +</lisp> +</defmacro> <h1> Network representation of header diff --git a/mime-en.texi b/mime-en.texi index f3bbf8a..1f28037 100644 --- a/mime-en.texi +++ b/mime-en.texi @@ -1,13 +1,13 @@ \input texinfo.tex @setfilename mime-en.info -@settitle{FLIM 1.9 Manual about MIME Features} +@settitle{FLIM 1.10 Manual about MIME Features} @titlepage -@title FLIM 1.9 Manual about MIME Features +@title FLIM 1.10 Manual about MIME Features @author MORIOKA Tomohiko <morioka@@jaist.ac.jp> @subtitle 1998/07/01 @end titlepage @node Top, Introduction, (dir), (dir) -@top FLIM 1.9 Manual about MIME Features +@top FLIM 1.10 Manual about MIME Features @ifinfo @@ -414,7 +414,7 @@ when its entity is created at first. @menu * Request for entity:: Message-passing for entity -* mm-backend module:: How to make mm-backend +* mm-backend module:: Definition of mm-backend @end menu @node Request for entity, mm-backend module, mm-backend, mm-backend @@ -431,11 +431,40 @@ result.@refill @node mm-backend module, , Request for entity, mm-backend -@subsection How to make mm-backend +@subsection Definition of mm-backend -(It is not written yet, sorry. (^_^;)@refill +@defmac mm-define-backend type &optional parents + +Define @var{type} as a mm-backend.@refill + +If @var{PARENTS} is specified, @var{type} inherits parents. Each parent +must be representation-type.@refill + +Example:@refill + +@lisp +(mm-define-backend chao (generic)) +@end lisp +@end defmac + + +@defmac mm-define-method name args &rest body + +Define @var{name} as a method function of (nth 1 (car @var{args})) +backend.@refill + +@var{args} is like an argument list of lambda, but (car @var{args}) must +be specialized parameter. (car (car @var{args})) is name of variable +and (nth 1 (car @var{args})) is name of backend +(representation-type).@refill + +Example:@refill + +@lisp +(mm-define-method entity-cooked-p ((entity chao)) nil) +@end lisp +@end defmac -(Please read mm*.el) @node Content-Type, Content-Disposition, Entity, Top @@ -694,12 +723,13 @@ Content-Transfer-Encoding. @menu * Content-Transfer-Encoding parser:: Parser -* Region encoder/decoder:: Region encoding/decoding -* String encoder/decoder:: String encoding/decoding -* File encoder/decoder:: File encoding/decoding +* encoder/decoder:: Encoder/decoder +* Encoding information:: Other utilities +* mel-backend:: How to write encoder/decoder module +* generic function for mel-backend:: How to add encoding/decoding service @end menu -@node Content-Transfer-Encoding parser, Region encoder/decoder, Content-Transfer-Encoding, Content-Transfer-Encoding +@node Content-Transfer-Encoding parser, encoder/decoder, Content-Transfer-Encoding, Content-Transfer-Encoding @section Parser @defun mime-parse-Content-Transfer-Encoding string @@ -719,8 +749,8 @@ Content-Transfer-Encoding $BMs$,B8:_$7$J$$>l9g$O(B@var{default-encoding} $B$r -@node Region encoder/decoder, String encoder/decoder, Content-Transfer-Encoding parser, Content-Transfer-Encoding -@section Region encoding/decoding +@node encoder/decoder, Encoding information, Content-Transfer-Encoding parser, Content-Transfer-Encoding +@section Encoder/decoder @defun mime-encode-region start end encoding @@ -736,83 +766,123 @@ Decode region @var{start} to @var{end} of current buffer using @end defun -@defvar mime-encoding-method-alist - -Alist of encoding vs. corresponding method to encode region.@refill -Each element looks like @code{(STRING . FUNCTION)} or @code{(STRING -. nil)}. @var{string} is content-transfer-encoding. @code{function} is -region encoder and @code{nil} means not to encode. -@end defvar +@defun mime-decode-string string encoding +@var{string} $B$r(B @var{encoding} $B$H$7$FI|9f$7$?7k2L$rJV$7$^$9!#(B +@end defun -@defvar mime-decoding-method-alist -Alist of encoding vs. corresponding method to decode region.@refill -Each element looks like @code{(STRING . FUNCTION)} or @code{(STRING -. nil)}. @var{string} is content-transfer-encoding. @code{function} is -region decoder and @code{nil} means not to decode. -@end defvar +@defun mime-insert-encoded-file filename encoding +Insert file @var{FILENAME} encoded by @var{ENCODING} format. +@end defun -@node String encoder/decoder, File encoder/decoder, Region encoder/decoder, Content-Transfer-Encoding -@section String encoding/decoding +@defun mime-write-decoded-region start end filename encoding -@defun mime-decode-string string encoding +Decode and write current region encoded by @var{encoding} into +@var{filename}.@refill -@var{string} $B$r(B @var{encoding} $B$H$7$FI|9f$7$?7k2L$rJV$7$^$9!#(B +@var{start} and @var{end} are buffer positions. @end defun -@defvar mime-string-decoding-method-alist -Alist of encoding vs. corresponding method to decode string.@refill +@node Encoding information, mel-backend, encoder/decoder, Content-Transfer-Encoding +@section Other utilities -Each element looks like @code{(STRING . FUNCTION)}. STRING is -content-transfer-encoding. FUNCTION is string decoder. -@end defvar +@defun mime-encoding-list &optional SERVICE +Return list of Content-Transfer-Encoding.@refill +If @var{service} is specified, it returns available list of +Content-Transfer-Encoding for it. +@end defun -@node File encoder/decoder, , String encoder/decoder, Content-Transfer-Encoding -@section File encoding/decoding -@defun mime-insert-encoded-file filename encoding +@defun mime-encoding-alist &optional SERVICE -Insert file @var{FILENAME} encoded by @var{ENCODING} format. +Return table of Content-Transfer-Encoding for completion.@refill + +If @var{service} is specified, it returns available list of +Content-Transfer-Encoding for it. @end defun -@defun mime-write-decoded-region start end filename encoding -Decode and write current region encoded by @var{encoding} into -@var{filename}.@refill +@node mel-backend, generic function for mel-backend, Encoding information, Content-Transfer-Encoding +@section How to write encoder/decoder module -@var{start} and @var{end} are buffer positions. -@end defun +@defmac mel-define-method name args &rest body +Define @var{name} as a method function of (nth 1 (car (last +@var{args}))) backend.@refill -@defvar mime-file-encoding-method-alist +@var{args} is like an argument list of lambda, but (car (last +@var{args})) must be specialized parameter. (car (car (last +@var{args}))) is name of variable and (nth 1 (car (last @var{args}))) is +name of backend (encoding).@refill -Alist of encoding vs. corresponding method to insert encoded -file.@refill +Example:@refill -Each element looks like @code{(STRING . FUNCTION)}. STRING is -content-transfer-encoding. FUNCTION is function to insert encoded file. -@end defvar +@lisp +(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 + (list (region-beginning) (region-end) + (read-file-name "Write decoded region to file: "))) + (let ((str (buffer-substring start end))) + (with-temp-buffer + (insert (decode-base64-string str)) + (write-region-as-binary (point-min) (point-max) filename) + ))) +@end lisp +@end defmac -@defvar mime-file-decoding-method-alist +@defmac mel-define-method-function spec function -Alist of encoding vs. corresponding method to write decoded region to -file.@refill +Set @var{spec}'s function definition to @var{function}.@refill -Each element looks like @code{(STRING . FUNCTION)}. STRING is -content-transfer-encoding. FUNCTION is function to write decoded region -to file. -@end defvar +First element of @var{spec} is service.@refill + +Rest of @var{args} is like an argument list of lambda, but (car (last +@var{args})) must be specialized parameter. (car (car (last +@var{args}))) is name of variable and (nth 1 (car (last @var{args}))) is +name of backend (encoding).@refill + +Example:@refill + +@lisp +(mel-define-method-function (mime-encode-string string (nil "base64")) + 'encode-base64-string) +@end lisp +@end defmac + + + +@node generic function for mel-backend, , mel-backend, Content-Transfer-Encoding +@section How to add encoding/decoding service + +@defmac mel-define-service name &optional args doc-string + +Define @var{name} as a service for Content-Transfer-Encodings.@refill + +If @var{args} is specified, @var{name} is defined as a generic function +for the service.@refill + +Example:@refill + +@lisp +(mel-define-service encoded-text-encode-string (string encoding) + "Encode STRING as encoded-text using ENCODING. +ENCODING must be string.") +@end lisp +@end defmac diff --git a/mime-ja.sgml b/mime-ja.sgml index 8240d6b..50d67d3 100644 --- a/mime-ja.sgml +++ b/mime-ja.sgml @@ -1,6 +1,6 @@ <!doctype sinfo system> <head> -<title>FLIM 1.9 MIME $B5!G=@bL@=q(B +<title>FLIM 1.10 MIME $B5!G=@bL@=q(B <author>$B<i2,(B $BCNI'(B <mail>morioka@jaist.ac.jp</mail> <date>1998/07/01 @@ -396,9 +396,39 @@ representation-type $B$NL>A0$N@hF,$K(B <code>mm</code> $B$rIU$1$?$b$N$K$J$C$F <h3> mm-backend $B$N:n$jJ}(B <node> mm-backend module <p> -$B!J$9$_$^$;$s!#$=$N$&$A=q$-$^$9(B (^_^;$B!K(B +<defmacro name="mm-define-backend"> +<args> type +<opts> parents <p> -$B!J$H$j$"$($:!"(Bmm*.el $B$r;29M$K$7$F$/$@$5$$!K(B +Define <var>type</var> as a mm-backend. +<p> +If <var>PARENTS</var> is specified, <var>type</var> inherits parents. +Each parent must be representation-type. +<p> +Example: +<p> +<lisp> +(mm-define-backend chao (generic)) +</lisp> +</defmacro> + +<defmacro name="mm-define-method"> +<args> name args <rest> body +<p> +Define <var>name</var> as a method function of (nth 1 (car +<var>args</var>)) backend. +<p> +<var>args</var> is like an argument list of lambda, but (car +<var>args</var>) must be specialized parameter. (car (car +<var>args</var>)) is name of variable and (nth 1 (car +<var>args</var>)) is name of backend (representation-type). +<p> +Example: +<p> +<lisp> +(mm-define-method entity-cooked-p ((entity chao)) nil) +</lisp> +</defmacro> <h1> Content-Type $BMs$N>pJs(B @@ -632,8 +662,8 @@ Content-Transfer-Encoding $BMs$,B8:_$7$J$$>l9g$O(B </defun> -<h2> $BNN0h$NId9f2=!&I|9f2=(B -<node> Region encoder/decoder +<h2> $BId9f2=!&I|9f2=(B +<node> encoder/decoder <p> <defun name="mime-encode-region"> <args> start end encoding @@ -649,49 +679,14 @@ Decode region <var>start</var> to <var>end</var> of current buffer using <var>encoding</var>. </defun> -<defvar name="mime-encoding-method-alist"> -<p> -Alist of encoding vs. corresponding method to encode region. -<p> -Each element looks like <code>(STRING . FUNCTION)</code> or -<code>(STRING . nil)</code>. <var>string</var> is -content-transfer-encoding. <code>function</code> is region encoder -and <code>nil</code> means not to encode. -</defvar> -<defvar name="mime-decoding-method-alist"> -<p> -Alist of encoding vs. corresponding method to decode region. -<p> -Each element looks like <code>(STRING . FUNCTION)</code> or -<code>(STRING . nil)</code>. <var>string</var> is -content-transfer-encoding. <code>function</code> is region decoder -and <code>nil</code> means not to decode. -</defvar> - - -<h2> $BJ8;zNs$NId9f2=!&I|9f2=(B -<node> String encoder/decoder -<p> <defun name="mime-decode-string"> <args> string encoding <p> <var>string</var> $B$r(B <var>encoding</var> $B$H$7$FI|9f$7$?7k2L$rJV$7$^$9!#(B </defun> -<defvar name="mime-string-decoding-method-alist"> -<p> -Alist of encoding vs. corresponding method to decode string. -<p> -Each element looks like <code>(STRING . FUNCTION)</code>. -STRING is content-transfer-encoding. -FUNCTION is string decoder. -</defvar> - -<h2> File $B$NId9f2=!&I|9f2=(B -<node> File encoder/decoder -<p> <defun name="mime-insert-encoded-file"> <args> filename encoding <p> @@ -707,24 +702,102 @@ Decode and write current region encoded by <var>encoding</var> into <var>start</var> and <var>end</var> are buffer positions. </defun> -<defvar name="mime-file-encoding-method-alist"> + +<h2> Other utilities +<node> Encoding information <p> -Alist of encoding vs. corresponding method to insert encoded file. +<defun name="mime-encoding-list"> + <opts> SERVICE <p> -Each element looks like <code>(STRING . FUNCTION)</code>. STRING is -content-transfer-encoding. FUNCTION is function to insert encoded -file. -</defvar> +Return list of Content-Transfer-Encoding. +<p> +If <var>service</var> is specified, it returns available list of +Content-Transfer-Encoding for it. +</defun> -<defvar name="mime-file-decoding-method-alist"> +<defun name="mime-encoding-alist"> + <opts> SERVICE <p> -Alist of encoding vs. corresponding method to write decoded region to -file. +Return table of Content-Transfer-Encoding for completion. <p> -Each element looks like <code>(STRING . FUNCTION)</code>. STRING is -content-transfer-encoding. FUNCTION is function to write decoded -region to file. -</defvar> +If <var>service</var> is specified, it returns available list of +Content-Transfer-Encoding for it. +</defun> + + +<h2> How to write encoder/decoder module +<node> mel-backend +<p> +<defmacro name="mel-define-method"> +<args> name args <rest> body +<p> +Define <var>name</var> as a method function of (nth 1 (car (last +<var>args</var>))) backend. +<p> +<var>args</var> is like an argument list of lambda, but (car (last +<var>args</var>)) must be specialized parameter. (car (car (last +<var>args</var>))) is name of variable and (nth 1 (car (last +<var>args</var>))) is name of backend (encoding). +<p> +Example: +<p> +<lisp> +(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 + (list (region-beginning) (region-end) + (read-file-name "Write decoded region to file: "))) + (let ((str (buffer-substring start end))) + (with-temp-buffer + (insert (decode-base64-string str)) + (write-region-as-binary (point-min) (point-max) filename) + ))) +</lisp> +</defmacro> + +<defmacro name="mel-define-method-function"> +<args> spec function +<p> +Set <var>spec</var>'s function definition to <var>function</var>. +<p> +First element of <var>spec</var> is service. +<p> +Rest of <var>args</var> is like an argument list of lambda, but (car +(last <var>args</var>)) must be specialized parameter. (car (car +(last <var>args</var>))) is name of variable and (nth 1 (car (last +<var>args</var>))) is name of backend (encoding). +<p> +Example: +<p> +<lisp> +(mel-define-method-function (mime-encode-string string (nil "base64")) + 'encode-base64-string) +</lisp> +</defmacro> + + +<h2> How to add encoding/decoding service +<node> generic function for mel-backend +<p> +<defmacro name="mel-define-service"> +<args> name +<opts> args doc-string +<p> +Define <var>name</var> as a service for Content-Transfer-Encodings. +<p> +If <var>args</var> is specified, <var>name</var> is defined as a +generic function for the service. +<p> +Example: +<p> +<lisp> +(mel-define-service encoded-text-encode-string (string encoding) + "Encode STRING as encoded-text using ENCODING. +ENCODING must be string.") +</lisp> +</defmacro> <h1> Header $B$N(B network $BI=8=(B diff --git a/mime-ja.texi b/mime-ja.texi index c2df06a..4c77393 100644 --- a/mime-ja.texi +++ b/mime-ja.texi @@ -1,13 +1,13 @@ \input texinfo.tex @setfilename mime-ja.info -@settitle{FLIM 1.9 MIME $B5!G=@bL@=q(B} +@settitle{FLIM 1.10 MIME $B5!G=@bL@=q(B} @titlepage -@title FLIM 1.9 MIME $B5!G=@bL@=q(B +@title FLIM 1.10 MIME $B5!G=@bL@=q(B @author $B<i2,(B $BCNI'(B <morioka@@jaist.ac.jp> @subtitle 1998/07/01 @end titlepage @node Top, Introduction, (dir), (dir) -@top FLIM 1.9 MIME $B5!G=@bL@=q(B +@top FLIM 1.10 MIME $B5!G=@bL@=q(B @ifinfo @@ -433,9 +433,38 @@ representation-type $B$NL>A0$N@hF,$K(B @code{mm} $B$rIU$1$?$b$N$K$J$C$F(B @node mm-backend module, , Request for entity, mm-backend @subsection mm-backend $B$N:n$jJ}(B -$B!J$9$_$^$;$s!#$=$N$&$A=q$-$^$9(B (^_^;$B!K(B@refill +@defmac mm-define-backend type &optional parents + +Define @var{type} as a mm-backend.@refill + +If @var{PARENTS} is specified, @var{type} inherits parents. Each parent +must be representation-type.@refill + +Example:@refill + +@lisp +(mm-define-backend chao (generic)) +@end lisp +@end defmac + + +@defmac mm-define-method name args &rest body + +Define @var{name} as a method function of (nth 1 (car @var{args})) +backend.@refill + +@var{args} is like an argument list of lambda, but (car @var{args}) must +be specialized parameter. (car (car @var{args})) is name of variable +and (nth 1 (car @var{args})) is name of backend +(representation-type).@refill + +Example:@refill + +@lisp +(mm-define-method entity-cooked-p ((entity chao)) nil) +@end lisp +@end defmac -$B!J$H$j$"$($:!"(Bmm*.el $B$r;29M$K$7$F$/$@$5$$!K(B @node Content-Type, Content-Disposition, Entity, Top @@ -692,12 +721,13 @@ FLIM $B$G$O(B Content-Transfer-Encoding $BMs$r9=J82r@O$9$k4X?t$rDs6!$7$^$9!#$ @menu * Content-Transfer-Encoding parser:: Content-Transfer-Encoding $BMs$N2r@O4o(B -* Region encoder/decoder:: $BNN0h$NId9f2=!&I|9f2=(B -* String encoder/decoder:: $BJ8;zNs$NId9f2=!&I|9f2=(B -* File encoder/decoder:: File $B$NId9f2=!&I|9f2=(B +* encoder/decoder:: $BId9f2=!&I|9f2=(B +* Encoding information:: Other utilities +* mel-backend:: How to write encoder/decoder module +* generic function for mel-backend:: How to add encoding/decoding service @end menu -@node Content-Transfer-Encoding parser, Region encoder/decoder, Content-Transfer-Encoding, Content-Transfer-Encoding +@node Content-Transfer-Encoding parser, encoder/decoder, Content-Transfer-Encoding, Content-Transfer-Encoding @section Content-Transfer-Encoding $BMs$N2r@O4o(B @defun mime-parse-Content-Transfer-Encoding string @@ -717,8 +747,8 @@ Content-Transfer-Encoding $BMs$,B8:_$7$J$$>l9g$O(B@var{default-encoding} $B$r -@node Region encoder/decoder, String encoder/decoder, Content-Transfer-Encoding parser, Content-Transfer-Encoding -@section $BNN0h$NId9f2=!&I|9f2=(B +@node encoder/decoder, Encoding information, Content-Transfer-Encoding parser, Content-Transfer-Encoding +@section $BId9f2=!&I|9f2=(B @defun mime-encode-region start end encoding @@ -734,83 +764,123 @@ Decode region @var{start} to @var{end} of current buffer using @end defun -@defvar mime-encoding-method-alist - -Alist of encoding vs. corresponding method to encode region.@refill -Each element looks like @code{(STRING . FUNCTION)} or @code{(STRING -. nil)}. @var{string} is content-transfer-encoding. @code{function} is -region encoder and @code{nil} means not to encode. -@end defvar +@defun mime-decode-string string encoding +@var{string} $B$r(B @var{encoding} $B$H$7$FI|9f$7$?7k2L$rJV$7$^$9!#(B +@end defun -@defvar mime-decoding-method-alist -Alist of encoding vs. corresponding method to decode region.@refill -Each element looks like @code{(STRING . FUNCTION)} or @code{(STRING -. nil)}. @var{string} is content-transfer-encoding. @code{function} is -region decoder and @code{nil} means not to decode. -@end defvar +@defun mime-insert-encoded-file filename encoding +Insert file @var{FILENAME} encoded by @var{ENCODING} format. +@end defun -@node String encoder/decoder, File encoder/decoder, Region encoder/decoder, Content-Transfer-Encoding -@section $BJ8;zNs$NId9f2=!&I|9f2=(B +@defun mime-write-decoded-region start end filename encoding -@defun mime-decode-string string encoding +Decode and write current region encoded by @var{encoding} into +@var{filename}.@refill -@var{string} $B$r(B @var{encoding} $B$H$7$FI|9f$7$?7k2L$rJV$7$^$9!#(B +@var{start} and @var{end} are buffer positions. @end defun -@defvar mime-string-decoding-method-alist -Alist of encoding vs. corresponding method to decode string.@refill +@node Encoding information, mel-backend, encoder/decoder, Content-Transfer-Encoding +@section Other utilities -Each element looks like @code{(STRING . FUNCTION)}. STRING is -content-transfer-encoding. FUNCTION is string decoder. -@end defvar +@defun mime-encoding-list &optional SERVICE +Return list of Content-Transfer-Encoding.@refill +If @var{service} is specified, it returns available list of +Content-Transfer-Encoding for it. +@end defun -@node File encoder/decoder, , String encoder/decoder, Content-Transfer-Encoding -@section File $B$NId9f2=!&I|9f2=(B -@defun mime-insert-encoded-file filename encoding +@defun mime-encoding-alist &optional SERVICE -Insert file @var{FILENAME} encoded by @var{ENCODING} format. +Return table of Content-Transfer-Encoding for completion.@refill + +If @var{service} is specified, it returns available list of +Content-Transfer-Encoding for it. @end defun -@defun mime-write-decoded-region start end filename encoding -Decode and write current region encoded by @var{encoding} into -@var{filename}.@refill +@node mel-backend, generic function for mel-backend, Encoding information, Content-Transfer-Encoding +@section How to write encoder/decoder module -@var{start} and @var{end} are buffer positions. -@end defun +@defmac mel-define-method name args &rest body +Define @var{name} as a method function of (nth 1 (car (last +@var{args}))) backend.@refill -@defvar mime-file-encoding-method-alist +@var{args} is like an argument list of lambda, but (car (last +@var{args})) must be specialized parameter. (car (car (last +@var{args}))) is name of variable and (nth 1 (car (last @var{args}))) is +name of backend (encoding).@refill -Alist of encoding vs. corresponding method to insert encoded -file.@refill +Example:@refill -Each element looks like @code{(STRING . FUNCTION)}. STRING is -content-transfer-encoding. FUNCTION is function to insert encoded file. -@end defvar +@lisp +(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 + (list (region-beginning) (region-end) + (read-file-name "Write decoded region to file: "))) + (let ((str (buffer-substring start end))) + (with-temp-buffer + (insert (decode-base64-string str)) + (write-region-as-binary (point-min) (point-max) filename) + ))) +@end lisp +@end defmac -@defvar mime-file-decoding-method-alist +@defmac mel-define-method-function spec function -Alist of encoding vs. corresponding method to write decoded region to -file.@refill +Set @var{spec}'s function definition to @var{function}.@refill -Each element looks like @code{(STRING . FUNCTION)}. STRING is -content-transfer-encoding. FUNCTION is function to write decoded region -to file. -@end defvar +First element of @var{spec} is service.@refill + +Rest of @var{args} is like an argument list of lambda, but (car (last +@var{args})) must be specialized parameter. (car (car (last +@var{args}))) is name of variable and (nth 1 (car (last @var{args}))) is +name of backend (encoding).@refill + +Example:@refill + +@lisp +(mel-define-method-function (mime-encode-string string (nil "base64")) + 'encode-base64-string) +@end lisp +@end defmac + + + +@node generic function for mel-backend, , mel-backend, Content-Transfer-Encoding +@section How to add encoding/decoding service + +@defmac mel-define-service name &optional args doc-string + +Define @var{name} as a service for Content-Transfer-Encodings.@refill + +If @var{args} is specified, @var{name} is defined as a generic function +for the service.@refill + +Example:@refill + +@lisp +(mel-define-service encoded-text-encode-string (string encoding) + "Encode STRING as encoded-text using ENCODING. +ENCODING must be string.") +@end lisp +@end defmac -- 1.7.10.4