From 31583c0fc042ed053e7dbf5ad50771a939e80a15 Mon Sep 17 00:00:00 2001 From: Alexander Rosenberg Date: Wed, 6 May 2026 17:10:59 -0700 Subject: [PATCH] Fix org-mu4e-compose font locking --- elisp/org-mu4e-compose.el | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/elisp/org-mu4e-compose.el b/elisp/org-mu4e-compose.el index ec3fb46..df2c200 100644 --- a/elisp/org-mu4e-compose.el +++ b/elisp/org-mu4e-compose.el @@ -80,6 +80,22 @@ about this change." (setq end (match-beginning 0))) (cons (1+ start) end))))) +(defun org-mu4e--make-face-font-lock-face (start end) + "Copy the value of all `face' text properties to `font-lock-face'. +The affected area is START to END in the current buffer." + (with-restriction start end + (cl-do ((pos (point-min) (next-property-change pos)) + (begin (point-min)) + (face (or (get-text-property (point) 'face) + 'default))) + ((not pos) (put-text-property begin (point-max) 'font-lock-face face)) + (let ((new-face (or (get-text-property pos 'face) + 'default))) + (unless (equal face new-face) + (put-text-property begin pos 'font-lock-face face) + (setq face new-face + begin pos)))))) + (defun org-mu4e--pretty-print-fontify-html-part () "Pretty print and fontify the HTML part of the current buffer." (when-let* ((bounds (org-mu4e--bounds-of-mime-part "text/html")) @@ -97,6 +113,7 @@ about this change." (indent-region (point-min) (point-max))) (put-text-property (point-min) (point-max) 'fontified nil) (font-lock-ensure) + (org-mu4e--make-face-font-lock-face (point-min) (point-max)) (buffer-string)))) (delete-region (car bounds) (cdr bounds)) (goto-char (car bounds)) @@ -113,7 +130,7 @@ about this change." after-change-functions))) (delete-region (point-min) (point-max)) (insert ascii-content) - (set-text-properties (point-min) (point-max) '(:fontified t)))))) + (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.