mu4e-view: tweak html generation

Use the message plist.
This commit is contained in:
Dirk-Jan C. Binnema
2026-07-07 18:59:16 +03:00
committed by Seth Ladygo
parent 1d1c1df4b3
commit dcc537c545
2 changed files with 29 additions and 17 deletions

View File

@ -31,6 +31,8 @@
;;; Code:
(require 'mu4e-vars)
(require 'mu4e-folders)
(require 'mu4e-message)
(require 'mu4e-contacts)
(require 'gnus-art)
(require 'crm)
@ -665,18 +667,23 @@ full-stop after the URL is not included.")
"</div>\n<p style=\"margin:0\"></p>\n"
"HTML fragment that closes the message-headers block.")
(defun mu4e--view-html-headers ()
"Create an HTML block for the message headers in the current buffer.
The current buffer is expected to contain the raw message."
(defun mu4e--view-html-headers (msg)
"Create an HTML block for the headers of message MSG."
(concat
mu4e--view-html-headers-html-pre
(mapconcat
(lambda (field)
(if-let* ((val (message-field-value field)))
(format "<b>%s:</b> %s<br>\n" (capitalize field)
(if-let* ((val (mu4e-message-field-raw msg field))
(val (pcase field
((or :from :to :cc)
(mapconcat #'mu4e-contact-full val ", "))
(:date (message-make-date val))
(_ val))))
(format "<b>%s:</b> %s<br>\n"
(capitalize (substring (symbol-name field) 1))
(mu4e--view-html-escape val))
""))
'("from" "to" "cc" "date" "subject") "")
'(:from :to :cc :date :subject) "")
mu4e--view-html-headers-html-post))
(defun mu4e--view-html-prepend-headers (html headers)

View File

@ -441,7 +441,7 @@ Prompting the user with PROMPT for the number."
Prompting the user with PROMPT for the numbers.
Default is to apply it to all URLs, [1..n], where n is the number
of urls. You can type multiple values separated by space, e.g. 1
of urls. You can type multiple values separated by space, e.g., 1
3-6 8 will visit urls 1,3,4,5,6 and 8.
Furthermore, there is a shortcut \"a\" which means all urls, but as
@ -613,7 +613,7 @@ part."
;; just continue if some of the decoding fails.
(ignore-errors (run-hooks 'gnus-article-decode-hook))
(let ((handles (mm-dissect-buffer t t))
(headers (unless skip-headers (mu4e--view-html-headers))))
(headers (unless skip-headers (mu4e--view-html-headers msg))))
(unwind-protect
(when-let* ((html (mu4e--view-extract-html handles)))
(when-let* ((cid-parts (mu4e--view-cid-parts handles)))
@ -1193,8 +1193,13 @@ multipart/alternative part to toggle; toggle again (or use
"Toggle between the HTML and plain-text alternatives.
Works for `multipart/alternative' messages by pressing the
corresponding Gnus selector button in the buffer. For other
messages, toggle between the normal rendering and an
shr-rendered html version of the message."
messages, toggle between the normal rendering and an shr-rendered
html version of the message.
If the message does not its own HTML version, a version is
concocted from the the text-version. This version is similar to
the version for external web-browsers, i.e., with a reduced,
fixed set of message headers."
(interactive)
(save-excursion
(let ((inhibit-read-only t))