From: morioka Date: Tue, 7 Jul 1998 15:23:49 +0000 (+0000) Subject: (mm-arglist-to-arguments): New function. X-Git-Tag: chao-1_8-199811302358~14 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=da2d1a66ed3f0b16832400e6c1ec54efb3e8f60b;p=elisp%2Fflim.git (mm-arglist-to-arguments): New function. (mm-define-generic): New macro. (mime-entity-cooked-p): Use `mm-define-generic'. (mime-entity-point-min): Use `mm-define-generic'. (mime-insert-decoded-header): Use `mm-define-generic'. (mime-entity-content): Use `mm-define-generic'. (mime-write-entity-content): Use `mm-define-generic'. (mime-write-entity): Use `mm-define-generic'. (mime-write-entity-body): Use `mm-define-generic'. --- diff --git a/mime.el b/mime.el index 1b5888b..6348bc1 100644 --- a/mime.el +++ b/mime.el @@ -82,6 +82,30 @@ current-buffer, and return it.") entity args)) +(defsubst mm-arglist-to-arguments (arglist) + (let (dest) + (while arglist + (let ((arg (car arglist))) + (or (memq arg '(&optional &rest)) + (setq dest (cons arg dest))) + ) + (setq arglist (cdr arglist))) + (nreverse dest))) + +(defmacro mm-define-generic (name args &optional doc) + (if doc + `(defun ,(intern (format "mime-%s" name)) ,args + ,doc + (mime-entity-send ,(car args) ',name + ,@(mm-arglist-to-arguments (cdr args))) + ) + `(defun ,(intern (format "mime-%s" name)) ,args + (mime-entity-send ,(car args) ',name + ,@(mm-arglist-to-arguments (cdr args))) + ))) + +(put 'mm-define-generic 'lisp-indent-function 'defun) + (defun mime-open-entity (type location) "Open an entity and return it. TYPE is representation-type. @@ -89,9 +113,8 @@ LOCATION is location of entity. Specification of it is depended on representation-type." (funcall (mime-find-function 'open type) location)) -(defun mime-entity-cooked-p (entity) - "Return non-nil if contents of ENTITY has been already code-converted." - (mime-entity-send entity 'cooked-p)) +(mm-define-generic entity-cooked-p (entity) + "Return non-nil if contents of ENTITY has been already code-converted.") ;;; @ Entity as node of message @@ -147,11 +170,11 @@ ENTITY is used." (or (mime-entity-buffer-internal entity) (mime-entity-send entity 'entity-buffer))) -(defun mime-entity-point-min (entity) - (mime-entity-send entity 'point-min)) +(mm-define-generic entity-point-min (entity) + "Return the start point of ENTITY in the buffer which contains ENTITY.") -(defun mime-entity-point-max (entity) - (mime-entity-send entity 'point-max)) +(mm-define-generic entity-point-max (entity) + "Return the end point of ENTITY in the buffer which contains ENTITY.") (defun mime-entity-header-start (entity) (or (mime-entity-header-start-internal entity) @@ -257,11 +280,9 @@ ENTITY is used." entity (put-alist field-name field header)) field))))))) -(defun mime-insert-decoded-header (entity &optional invisible-fields +(mm-define-generic insert-decoded-header (entity &optional invisible-fields visible-fields) - "Insert before point a decoded header of ENTITY." - (mime-entity-send entity 'insert-decoded-header - invisible-fields visible-fields)) + "Insert before point a decoded header of ENTITY.") ;;; @ Entity Attributes @@ -304,21 +325,17 @@ ENTITY is used." ;;; @ Entity Content ;;; -(defun mime-entity-content (entity) - "Return content of ENTITY as byte sequence (string)." - (mime-entity-send entity 'get-content)) +(mm-define-generic entity-content (entity) + "Return content of ENTITY as byte sequence (string).") -(defun mime-write-entity-content (entity filename) - "Write content of ENTITY into FILENAME." - (mime-entity-send entity 'write-content filename)) +(mm-define-generic write-entity-content (entity filename) + "Write content of ENTITY into FILENAME.") -(defun mime-write-entity (entity filename) - "Write header and body of ENTITY into FILENAME." - (mime-entity-send entity 'write-with-header filename)) +(mm-define-generic write-entity (entity filename) + "Write header and body of ENTITY into FILENAME.") -(defun mime-write-entity-body (entity filename) - "Write body of ENTITY into FILENAME." - (mime-entity-send entity 'write-body filename)) +(mm-define-generic write-entity-body (entity filename) + "Write body of ENTITY into FILENAME.") ;;; @ end