Function: rmail-digest-parse-mixed-mime

rmail-digest-parse-mixed-mime is a byte-compiled function defined in undigest.el.gz.

Signature

(rmail-digest-parse-mixed-mime)

Documentation

Like rmail-digest-parse-mime, but for multipart/mixed messages.

Source Code

;; Defined in /usr/src/emacs/lisp/mail/undigest.el.gz
(defun rmail-digest-parse-mixed-mime ()
  "Like `rmail-digest-parse-mime', but for multipart/mixed messages."
  (when-let* ((boundary (rmail-content-type-boundary "multipart/mixed")))
    (let ((global-sep (concat "\n--" boundary))
          (digest (concat "^Content-type: multipart/digest;"
                          "\\s-* boundary=\"?\\([^\";\n]+\\)[\";\n]"))
          result)
      (search-forward global-sep nil t)
      (while (not (or result (eobp)))
        ;; For each part, see if it is a multipart/digest.
        (let* ((limit (save-excursion (search-forward global-sep nil 'move)
                                      (point)))
               (beg (and (re-search-forward digest limit t)
                         (match-beginning 0)))
               digest-sep)
          (when (and beg
                     (setq digest-sep (concat "\n--" (match-string 1)))
                     ;; Search for 1st sep.
                     (search-forward digest-sep nil t))
            ;; Skip body part headers.
            (search-forward "\n\n" nil t)
            ;; Push the 1st message.
            (push (cons (copy-marker beg) (copy-marker (point-marker) t))
                  result)
            ;; Push the rest of the messages.
            (let ((start (make-marker))
                  done)
              (while (and (search-forward digest-sep limit 'move) (not done))
                (move-marker start (match-beginning 0))
                (and (looking-at "--$") (setq done t))
                (search-forward "\n\n")
                (push (cons (copy-marker start)
                            (copy-marker (point-marker) t))
                      result))))
          (goto-char limit)))
      (nreverse result))))