diff --git a/elisp/org-mu4e-compose.el b/elisp/org-mu4e-compose.el index ccf0f3f..c829487 100644 --- a/elisp/org-mu4e-compose.el +++ b/elisp/org-mu4e-compose.el @@ -131,16 +131,33 @@ The affected area is START to END in the current buffer." after-change-functions))) (insert content)))))) -(defun org-mu4e--textify-org-part () - "Replace the org part of the current buffer with plain text." - (when-let* ((bounds (org-mu4e--bounds-of-mime-part "text/plain"))) - (with-restriction (car bounds) (cdr bounds) - (let ((ascii-content (org-export-as 'ascii nil nil t)) - (after-change-functions (remq 'jit-lock-after-change - after-change-functions))) - (delete-region (point-min) (point-max)) - (insert ascii-content) - (put-text-property (point-min) (point-max) 'font-lock-face 'default))))) +(defun org-mu4e--textify-make-original-message-verbatim () + "Make the original message of a reply message verbatim." + (goto-char (point-max)) + (forward-line 0) + (while (looking-at (rx bol eol)) + (forward-line -1)) + (when (looking-at (rx bol "> ")) + (end-of-line) + (insert "\n#+END_VERSE") + (forward-line -1) + (while (looking-at (rx bol ">" (or " " eol))) + (forward-line -1)) + (end-of-line) + (insert "\n#+BEGIN_VERSE")) + + (defun org-mu4e--textify-org-part () + "Replace the org part of the current buffer with plain text." + (when-let* ((bounds (org-mu4e--bounds-of-mime-part "text/plain"))) + (with-restriction (car bounds) (cdr bounds) + (org-mu4e--textify-make-original-message-verbatim) + (let* ((org-ascii-quote-margin 0) + (ascii-content (org-export-as 'ascii nil nil t)) + (after-change-functions (remq 'jit-lock-after-change + after-change-functions))) + (delete-region (point-min) (point-max)) + (insert ascii-content) + (put-text-property (point-min) (point-max) 'font-lock-face 'default)))))) (defun org-mu4e--htmlize-and-cleanup () "HTMLize and cleanup the visible portion of the buffer.