- (if (re-search-forward
- "<#\\(/\\)?\\(multipart\\|part\\|external\\)." nil t)
- (prog1
- (buffer-substring-no-properties beg (match-beginning 0))
- (if (or (not (match-beginning 1))
- (equal (match-string 2) "multipart"))
- (goto-char (match-beginning 0))
- (when (looking-at "[ \t]*\n")
- (forward-line 1))))
- (buffer-substring-no-properties beg (goto-char (point-max))))))
+ (if mml
+ (progn
+ (while (and (> count 0) (not (eobp)))
+ (if (re-search-forward "<#\\(/\\)?mml." nil t)
+ (setq count (+ count (if (match-beginning 1) -1 1)))
+ (goto-char (point-max))))
+ (buffer-substring-no-properties beg (if (> count 0)
+ (point)
+ (match-beginning 0))))
+ (if (re-search-forward
+ "<#\\(/\\)?\\(multipart\\|part\\|external\\|mml\\)." nil t)
+ (prog1
+ (buffer-substring-no-properties beg (match-beginning 0))
+ (if (or (not (match-beginning 1))
+ (equal (match-string 2) "multipart"))
+ (goto-char (match-beginning 0))
+ (when (looking-at "[ \t]*\n")
+ (forward-line 1))))
+ (buffer-substring-no-properties beg (goto-char (point-max)))))))