Fix org-mu4e-compose font locking

This commit is contained in:
2026-05-06 17:10:59 -07:00
parent 90fc8d0780
commit 31583c0fc0
+18 -1
View File
@@ -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.