Add description about
[elisp/semi.git] / mime-parse.el
index 7f9e4da..213563c 100644 (file)
@@ -180,32 +180,39 @@ If is is not found, return DEFAULT-ENCODING."
 ;;; @ message parser
 ;;;
 
-(defsubst make-mime-entity (node-id header-start header-end
-                                   body-start body-end
-                                   content-type content-disposition
-                                   encoding children)
-  (vector node-id
-         header-start header-end body-start body-end
+(defsubst make-mime-entity (buffer
+                           node-id
+                           header-start header-end body-start body-end
+                           content-type content-disposition
+                           encoding children)
+  (vector buffer
+         node-id header-start header-end body-start body-end
          content-type content-disposition encoding children))
 
-(defsubst mime-entity-node-id (entity)             (aref entity 0))
-(defsubst mime-entity-header-start (entity)        (aref entity 1))
-(defsubst mime-entity-header-end (entity)          (aref entity 2))
-(defsubst mime-entity-body-start (entity)          (aref entity 3))
-(defsubst mime-entity-body-end (entity)            (aref entity 4))
-(defsubst mime-entity-content-type (entity)        (aref entity 5))
-(defsubst mime-entity-content-disposition (entity) (aref entity 6))
-(defsubst mime-entity-encoding (entity)            (aref entity 7))
-(defsubst mime-entity-children (entity)            (aref entity 8))
+(defsubst mime-entity-buffer (entity)              (aref entity 0))
+(defsubst mime-entity-node-id (entity)             (aref entity 1))
+(defsubst mime-entity-header-start (entity)        (aref entity 2))
+(defsubst mime-entity-header-end (entity)          (aref entity 3))
+(defsubst mime-entity-body-start (entity)          (aref entity 4))
+(defsubst mime-entity-body-end (entity)            (aref entity 5))
+(defsubst mime-entity-content-type (entity)        (aref entity 6))
+(defsubst mime-entity-content-disposition (entity) (aref entity 7))
+(defsubst mime-entity-encoding (entity)            (aref entity 8))
+(defsubst mime-entity-children (entity)            (aref entity 9))
+
+(defsubst mime-entity-number (entity)
+  (reverse (mime-entity-node-id entity)))
 
 (defalias 'mime-entity-point-min 'mime-entity-header-start)
 (defalias 'mime-entity-point-max 'mime-entity-body-end)
+
 (defsubst mime-entity-media-type (entity)
   (mime-content-type-primary-type (mime-entity-content-type entity)))
 (defsubst mime-entity-media-subtype (entity)
   (mime-content-type-subtype (mime-entity-content-type entity)))
 (defsubst mime-entity-parameters (entity)
   (mime-content-type-parameters (mime-entity-content-type entity)))
+
 (defsubst mime-entity-type/subtype (entity-info)
   (mime-type/subtype-string (mime-entity-media-type entity-info)
                            (mime-entity-media-subtype entity-info)))
@@ -227,12 +234,12 @@ If is is not found, return DEFAULT-ENCODING."
            (make-mime-content-type 'text 'plain)
            ))
         cb ce ret ncb children (i 0))
-    (goto-char body-end)
-    (if (re-search-backward close-delimiter nil t)
-       (setq body-end (match-beginning 0))
-      )
     (save-restriction
-      (narrow-to-region header-end body-end)
+      (goto-char body-end)
+      (narrow-to-region header-end
+                       (if (re-search-backward close-delimiter nil t)
+                           (match-beginning 0)
+                         body-end))
       (goto-char header-start)
       (re-search-forward rsep nil t)
       (setq cb (match-end 0))
@@ -255,9 +262,8 @@ If is is not found, return DEFAULT-ENCODING."
        )
       (setq children (cons ret children))
       )
-    (make-mime-entity node-id
-                     header-start header-end
-                     body-start body-end
+    (make-mime-entity (current-buffer) node-id
+                     header-start header-end body-start body-end
                      content-type content-disposition encoding
                      (nreverse children))
     ))
@@ -309,9 +315,8 @@ mime-{parse|read}-Content-Type."
                (memq (mime-content-type-subtype content-type)
                      '(rfc822 news)
                      ))
-           (make-mime-entity node-id
-                            header-start header-end
-                            body-start body-end
+           (make-mime-entity (current-buffer) node-id
+                            header-start header-end body-start body-end
                             content-type content-disposition encoding
                             (save-restriction
                               (narrow-to-region body-start body-end)
@@ -320,9 +325,8 @@ mime-{parse|read}-Content-Type."
                               ))
           )
          (t 
-           (make-mime-entity node-id
-                            header-start header-end
-                            body-start body-end
+           (make-mime-entity (current-buffer) node-id
+                            header-start header-end body-start body-end
                             content-type content-disposition encoding nil)
           ))
     ))