From: morioka Date: Thu, 8 Oct 1998 07:17:25 +0000 (+0000) Subject: Sync up with flim-1_10_2. X-Git-Tag: flim-chao-1_11_2 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=d2f88db634f657856f4322a20c36433cbbe2357d;p=elisp%2Fflim.git Sync up with flim-1_10_2. --- diff --git a/ChangeLog b/ChangeLog index 15e372c..d238029 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,59 @@ +1998-10-08 MORIOKA Tomohiko + + * 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-06 MORIOKA Tomohiko * mel-g.el: Define method functions of mel. diff --git a/FLIM-ELS b/FLIM-ELS index 36683b8..380e5dc 100644 --- a/FLIM-ELS +++ b/FLIM-ELS @@ -15,7 +15,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 d9985d7..4346ba7 100644 --- a/FLIM-VERSION +++ b/FLIM-VERSION @@ -24,9 +24,9 @@ 1.9.2 Shin-Tanabe $(B?7EDJU(B 1.10.0 K-Dòdo-A $(B6=8M(B 1.10.1 Miyamaki $(B;0;3LZ(B ------ Kintetsu-Miyazu $(B6aE45\DE(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 @@ -62,3 +62,4 @@ 1.10.0 Marutamach $(B4]B@D.(B 1.11.0 Imadegawa $(B:#=P@n(B 1.11.1 Kuramaguchi $(B0HGO8}(B +1.11.2 Kita-Dòji-A $(BKLBgO)(B diff --git a/Makefile b/Makefile index 9e0da2a..60727b1 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ # PACKAGE = flim-chao -VERSION = 1.11.1 +VERSION = 1.11.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-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 e0a1339..1b13f0b 100644 --- a/mel.el +++ b/mel.el @@ -34,8 +34,6 @@ :group 'mime :type '(repeat string)) -(defvar mel-encoding-module-alist nil) - (defun mime-encoding-list (&optional service) "Return list of Content-Transfer-Encoding. If SERVICE is specified, it returns available list of @@ -74,36 +72,23 @@ Content-Transfer-Encoding for it." ))) (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")) ) @@ -111,6 +96,7 @@ Content-Transfer-Encoding for it." (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")) @@ -123,29 +109,9 @@ Content-Transfer-Encoding for it." 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 9b70f50..bb72e4d 100644 --- a/mime-def.el +++ b/mime-def.el @@ -24,7 +24,7 @@ ;;; Code: -(defconst mime-library-product ["Chao" (1 11 1) "Kuramaguchi"] +(defconst mime-library-product ["Chao" (1 11 2) "Kita.DŽòji"] "Product name, version number and code name of MIME-library package.") (defmacro mime-product-name (product) @@ -368,7 +368,7 @@ message/rfc822, `mime-entity' structures of them are included in (defvar mime-entity-implementation-alist nil) (defmacro mm-define-backend (type &optional parents) - "Define mm-backend TYPE. + "Define TYPE as a mm-backend. If PARENTS is specified, TYPE inherits PARENTS. Each parent must be backend name (symbol)." (if parents @@ -422,21 +422,72 @@ specialized parameter. (car (car ARGS)) is name of variable and (nth ;;; @ 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 @@ -448,6 +499,11 @@ specialized parameter. (car (car ARGS)) is name of variable and (nth (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))) @@ -468,6 +524,12 @@ specialized parameter. (car (car ARGS)) is name of variable and (nth (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 81a115b..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 @@ -666,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 @@ -683,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> @@ -741,25 +706,6 @@ 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"> -<p> -Alist of encoding vs. corresponding method to insert encoded file. -<p> -Each element looks like <code>(STRING . FUNCTION)</code>. STRING is -content-transfer-encoding. FUNCTION is function to insert encoded -file. -</defvar> - -<defvar name="mime-file-decoding-method-alist"> -<p> -Alist of encoding vs. corresponding method to write decoded region to -file. -<p> -Each element looks like <code>(STRING . FUNCTION)</code>. STRING is -content-transfer-encoding. FUNCTION is function to write decoded -region to file. -</defvar> - <h2> Other utilities <node> Encoding information @@ -783,6 +729,81 @@ 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 <node> encoded-word <p> diff --git a/mime-en.texi b/mime-en.texi index 3d94875..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 @@ -101,8 +101,7 @@ mime-entity.@refill If @var{buffer} is omitted, current buffer is used.@refill @var{type} is representation-type of created -mime-entity. (cf. @ref{mm-backend}) - Default value is @var{buffer}. +mime-entity. (cf. @ref{mm-backend}) Default value is @var{buffer}. @end defun @@ -724,13 +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 @@ -750,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 @@ -767,105 +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, Encoding information, 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 -@node Encoding information, , File encoder/decoder, Content-Transfer-Encoding -@section Other utilities +@lisp +(mel-define-method-function (mime-encode-string string (nil "base64")) + 'encode-base64-string) +@end lisp +@end defmac -@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 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 -@defun mime-encoding-alist &optional SERVICE +Define @var{name} as a service for Content-Transfer-Encodings.@refill -Return table of Content-Transfer-Encoding for completion.@refill +If @var{args} is specified, @var{name} is defined as a generic function +for the service.@refill -If @var{service} is specified, it returns available list of -Content-Transfer-Encoding for it. -@end defun +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 2a8e47f..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 @@ -662,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 @@ -679,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> @@ -737,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 e8e1ab6..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 @@ -721,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 @@ -746,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 @@ -763,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