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.
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
(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)
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
;;; @ 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