(defconst bug-39884-orig-message "\ From: a b.ce To: c d.de Subject: Test --text follows this line-- Test <#mml type=message/rfc822 disposition=inline> <#multipart type=alternative> <#part type=text/plain charset=\"UTF-8\" disposition=inline nofile=yes> Some text. <#part type=text/html charset=\"UTF-8\" nofile=yes> Some more text. <#/multipart> <#/mml> ") (defconst bug-39884-correct-result "\ From: a b.ce To: c d.de Subject: Test MIME-Version: 1.0 Content-Type: multipart/mixed; boundary=\"=-=-=\" --text follows this line-- --=-=-= Content-Type: text/plain Test --=-=-= Content-Type: message/rfc822 Content-Disposition: inline --====-=-= Content-Disposition: inline MIME-Version: 1.0 Content-Type: multipart/alternative; boundary=\"====-=-=\" Some text. --====-=-= Content-Type: text/html; charset=utf-8 Some more text. --====-=-=-- --=-=-=-- ") (defconst 39884-incorrect-results-of-step-9 "\ From: a b.ce To: c d.de Subject: Test MIME-Version: 1.0 Content-Type: multipart/mixed; boundary=\"=-=-=\" --text follows this line-- --=-=-= Content-Type: multipart/alternative; boundary=\"====-=-=\" Content-Transfer-Encoding: base64 VGV4dAoK --=-=-= Content-Type: message/rfc822 Content-Disposition: inline --====-=-= Content-Disposition: inline MIME-Version: 1.0 Content-Type: multipart/alternative; boundary=\"====-=-=\" Some text. --====-=-= Content-Type: text/html; charset=utf-8 Some more text. --====-=-=-- --=-=-=-- ") ;; (defvar mml-text/plain-tag-literal-constant) ;; (defun check-setcdr (fun cell newcdr) ;; (when (eq cell mml-text/plain-tag-literal-constant) ;; (debug nil)) ;; (funcall fun cell newcdr)) ;; (advice-add 'setcdr :around #'check-setcdr) ;; (load-library "mml.el") ;; `setcdr' has an opcode, so must run from source to advise it. ;; 2. M-x message-mode (message-mode) (setq buffer-file-name nil) (setq buffer-auto-save-file-name nil) ;; 3. Clear scratch buffer, paste original message (erase-buffer) (insert bug-39884-orig-message) ;; 4. M-: (mml-to-mime) --> gives CORRECT result (goto-char (point-min)) (mml-to-mime) (cl-assert (equal (buffer-string) bug-39884-correct-result)) ;; 5. Clear scratch buffer, paste original message (erase-buffer) (insert bug-39884-orig-message) ;; 6. Insert a new line "<#secure method=pgpmime mode=sign>" at start of ;; message (after line "--text follows this line--"). This makes Emacs try ;; to sign the mail. (search-backward "--text follows this line--") (forward-line) (insert "<#secure method=pgpmime mode=sign>\n") ;; 7. M-: (mml-to-mime) --> throws (expected) signer name error (cl-assert (condition-case () (progn (goto-char (point-min)) (mml-to-mime) nil) (error t))) ;; 8. Clear scratch buffer, paste original message (erase-buffer) (insert bug-39884-orig-message) ;; 9. M-: (mml-to-mime) ;; --> broken result (first Content-Type after "text follows..." is ;; wrong) (goto-char (point-min)) (mml-to-mime)