From b524126503cbe6b297acf0dd88c8852343f52139 Mon Sep 17 00:00:00 2001 From: Alexander Rosenberg Date: Tue, 5 May 2026 15:51:06 -0700 Subject: [PATCH] Some changes to org-mu4e-compose --- elisp/org-mu4e-compose.el | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/elisp/org-mu4e-compose.el b/elisp/org-mu4e-compose.el index eeac2b0..ec3fb46 100644 --- a/elisp/org-mu4e-compose.el +++ b/elisp/org-mu4e-compose.el @@ -100,7 +100,20 @@ about this change." (buffer-string)))) (delete-region (car bounds) (cdr bounds)) (goto-char (car bounds)) - (insert content))))) + (let ((after-change-functions (remq 'jit-lock-after-change + 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) + (set-text-properties (point-min) (point-max) '(:fontified t)))))) (defun org-mu4e--htmlize-and-cleanup () "HTMLize and cleanup the visible portion of the buffer. @@ -112,7 +125,7 @@ This moves point, wrap it in `save-excursion' if that is a problem." (when (re-search-forward (rx (group (* "\n")) "\n" eos) nil t) (delete-region (match-beginning 1) (match-end 1))) - (font-lock-ensure) + (org-mu4e--textify-org-part) (org-mu4e--pretty-print-fontify-html-part)) (defvar-keymap org-mu4e--code-preview-mode-map @@ -505,9 +518,9 @@ This is derived from `org-mode', but it also essentially runs 'org-mu4e-send-and-exit) (add-to-list (make-local-variable 'mode-line-misc-info) '(:eval (if org-mu4e--html-message-p - "Text/HTML " - "Text Only ")))) -;;;###autoload(derived-mode-add-parents 'org-mu4e-compose-mode '(mu4e-compose-mode)) + "Org/HTML " + "Plain Text ")))) +;;;###autoload (derived-mode-add-parents 'org-mu4e-compose-mode '(mu4e-compose-mode)) ;;;###autoload