with unknown encoding; `multipart': always send messages with more than
one charsets.")
+(defvar mml-generate-default-type "text/plain")
+
+(defvar mml-buffer-list nil)
+
+(defun mml-generate-new-buffer (name)
+ (let ((buf (generate-new-buffer name)))
+ (push buf mml-buffer-list)
+ buf))
+
+(defun mml-destroy-buffers ()
+ (let (kill-buffer-hook)
+ (mapcar 'kill-buffer mml-buffer-list)
+ (setq mml-buffer-list nil)))
+
(defun mml-parse ()
"Parse the current buffer as an MML document."
(goto-char (point-min))
(and use-ascii 'us-ascii)))
charset struct space newline paragraph)
(while (not (eobp))
+ (setq charset (mm-mime-charset (mm-charset-after)))
(cond
;; The charset remains the same.
- ((or (eq (setq charset (mm-mime-charset (mm-charset-after)))
- 'us-ascii)
- (and use-ascii (not charset))
- (eq charset current)))
+ ((eq charset 'us-ascii))
+ ((or (and use-ascii (not charset))
+ (eq charset current))
+ (setq space nil
+ newline nil
+ paragraph nil))
;; The initial charset was ascii.
((eq current 'us-ascii)
(setq current charset
(cond
((memq (following-char) '(? ?\t))
(setq space (1+ (point))))
- ((eq (following-char) ?\n)
- (setq newline (1+ (point))))
((and (eq (following-char) ?\n)
(not (bobp))
(eq (char-after (1- (point))) ?\n))
- (setq paragraph (point))))
+ (setq paragraph (point)))
+ ((eq (following-char) ?\n)
+ (setq newline (1+ (point)))))
(forward-char 1))
;; Do the final part.
(unless (= beg (point))
(cond
((eq (car cont) 'mml)
(let ((mml-boundary (funcall mml-boundary-function
- (incf mml-multipart-number))))
+ (incf mml-multipart-number)))
+ (mml-generate-default-type "text/plain"))
(mml-to-mime))
(let ((mm-7bit-chars (concat mm-7bit-chars "\x1b")))
;; ignore 0x1b, it is part of iso-2022-jp
(insert "\n"))
((eq (car cont) 'multipart)
(let* ((type (or (cdr (assq 'type cont)) "mixed"))
+ (mml-generate-default-type (if (equal type "digest")
+ "message/rfc822"
+ "text/plain"))
(handler (assoc type mml-generate-multipart-alist)))
(if handler
(funcall (cdr handler) cont)
(let ((mml-boundary (mml-compute-boundary cont)))
(insert (format "Content-Type: multipart/%s; boundary=\"%s\"\n"
type mml-boundary))
+ ;; Skip `multipart' and `type' elements.
(setq cont (cddr cont))
(while cont
(insert "\n--" mml-boundary "\n")
cont '(name access-type expiration size permission)))
(when (or charset
parameters
- (not (equal type "text/plain")))
+ (not (equal type mml-generate-default-type)))
(when (consp charset)
(error
"Can't encode a part with several charsets."))
(message-encode-message-body)
(save-restriction
(message-narrow-to-headers-or-head)
- (mail-encode-encoded-word-buffer)))
+ (let ((mail-parse-charset message-default-charset))
+ (mail-encode-encoded-word-buffer))))
(defun mml-insert-mime (handle &optional no-markup)
(let (textp buffer mmlp)
(unless (stringp (car handle))
(unless (setq textp (equal (mm-handle-media-supertype handle) "text"))
(save-excursion
- (set-buffer (setq buffer (generate-new-buffer " *mml*")))
+ (set-buffer (setq buffer (mml-generate-new-buffer " *mml*")))
(mm-insert-part handle)
(if (setq mmlp (equal (mm-handle-media-type handle)
"message/rfc822"))
(interactive "P")
(let ((buf (current-buffer))
(message-posting-charset (or (gnus-setup-posting-charset
- (message-fetch-field "Newsgroups"))
+ (save-restriction
+ (message-narrow-to-headers-or-head)
+ (message-fetch-field "Newsgroups")))
message-posting-charset)))
(switch-to-buffer (get-buffer-create
(concat (if raw "*Raw MIME preview of "