mu4e-view: tweak html generation
Use the message plist.
This commit is contained in:
@ -31,6 +31,8 @@
|
|||||||
;;; Code:
|
;;; Code:
|
||||||
(require 'mu4e-vars)
|
(require 'mu4e-vars)
|
||||||
(require 'mu4e-folders)
|
(require 'mu4e-folders)
|
||||||
|
(require 'mu4e-message)
|
||||||
|
(require 'mu4e-contacts)
|
||||||
(require 'gnus-art)
|
(require 'gnus-art)
|
||||||
(require 'crm)
|
(require 'crm)
|
||||||
|
|
||||||
@ -665,18 +667,23 @@ full-stop after the URL is not included.")
|
|||||||
"</div>\n<p style=\"margin:0\"></p>\n"
|
"</div>\n<p style=\"margin:0\"></p>\n"
|
||||||
"HTML fragment that closes the message-headers block.")
|
"HTML fragment that closes the message-headers block.")
|
||||||
|
|
||||||
(defun mu4e--view-html-headers ()
|
(defun mu4e--view-html-headers (msg)
|
||||||
"Create an HTML block for the message headers in the current buffer.
|
"Create an HTML block for the headers of message MSG."
|
||||||
The current buffer is expected to contain the raw message."
|
|
||||||
(concat
|
(concat
|
||||||
mu4e--view-html-headers-html-pre
|
mu4e--view-html-headers-html-pre
|
||||||
(mapconcat
|
(mapconcat
|
||||||
(lambda (field)
|
(lambda (field)
|
||||||
(if-let* ((val (message-field-value field)))
|
(if-let* ((val (mu4e-message-field-raw msg field))
|
||||||
(format "<b>%s:</b> %s<br>\n" (capitalize 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))
|
(mu4e--view-html-escape val))
|
||||||
""))
|
""))
|
||||||
'("from" "to" "cc" "date" "subject") "")
|
'(:from :to :cc :date :subject) "")
|
||||||
mu4e--view-html-headers-html-post))
|
mu4e--view-html-headers-html-post))
|
||||||
|
|
||||||
(defun mu4e--view-html-prepend-headers (html headers)
|
(defun mu4e--view-html-prepend-headers (html headers)
|
||||||
|
|||||||
@ -62,7 +62,7 @@ Otherwise, don't move to the next message."
|
|||||||
:group 'mu4e-view)
|
:group 'mu4e-view)
|
||||||
|
|
||||||
(defcustom mu4e-view-fields
|
(defcustom mu4e-view-fields
|
||||||
'(:from :to :cc :subject :flags :date
|
'(:from :to :cc :subject :flags :date
|
||||||
:maildir :mailing-list :tags :labels)
|
:maildir :mailing-list :tags :labels)
|
||||||
"Mu4e header fields to display in the message view buffer.
|
"Mu4e header fields to display in the message view buffer.
|
||||||
|
|
||||||
@ -441,7 +441,7 @@ Prompting the user with PROMPT for the number."
|
|||||||
Prompting the user with PROMPT for the numbers.
|
Prompting the user with PROMPT for the numbers.
|
||||||
|
|
||||||
Default is to apply it to all URLs, [1..n], where n is the number
|
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.
|
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
|
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.
|
;; just continue if some of the decoding fails.
|
||||||
(ignore-errors (run-hooks 'gnus-article-decode-hook))
|
(ignore-errors (run-hooks 'gnus-article-decode-hook))
|
||||||
(let ((handles (mm-dissect-buffer t t))
|
(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
|
(unwind-protect
|
||||||
(when-let* ((html (mu4e--view-extract-html handles)))
|
(when-let* ((html (mu4e--view-extract-html handles)))
|
||||||
(when-let* ((cid-parts (mu4e--view-cid-parts handles)))
|
(when-let* ((cid-parts (mu4e--view-cid-parts handles)))
|
||||||
@ -684,7 +684,7 @@ Uses the MIME handle alist populated by Gnus after rendering."
|
|||||||
|
|
||||||
(defun mu4e--view-render-buffer (msg)
|
(defun mu4e--view-render-buffer (msg)
|
||||||
"Render current buffer with MSG using Gnus' article mode.
|
"Render current buffer with MSG using Gnus' article mode.
|
||||||
The buffer must already contain the raw message. This function
|
The buffer must already contain the raw message. This function
|
||||||
decodes and displays it, sets up the original-article-buffer, and
|
decodes and displays it, sets up the original-article-buffer, and
|
||||||
activates URLs (in plain-text mode only)."
|
activates URLs (in plain-text mode only)."
|
||||||
(let* ((inhibit-read-only t)
|
(let* ((inhibit-read-only t)
|
||||||
@ -799,8 +799,8 @@ Note that for some messages, this can trigger high CPU load."
|
|||||||
"Insert mu4e headers for MSG into the current buffer at point.
|
"Insert mu4e headers for MSG into the current buffer at point.
|
||||||
RAW-HEADERS, when non-nil, is an alist of (FIELD . VALUE) strings
|
RAW-HEADERS, when non-nil, is an alist of (FIELD . VALUE) strings
|
||||||
for standard RFC headers (From, To, Cc, etc.) that should be
|
for standard RFC headers (From, To, Cc, etc.) that should be
|
||||||
rendered directly. When nil, those fields are left for Gnus to
|
rendered directly. When nil, those fields are left for Gnus to
|
||||||
render. After inserting, highlight the headers."
|
render. After inserting, highlight the headers."
|
||||||
(dolist (field mu4e-view-fields)
|
(dolist (field mu4e-view-fields)
|
||||||
(let ((fieldval (mu4e-message-field msg field)))
|
(let ((fieldval (mu4e-message-field msg field)))
|
||||||
(pcase field
|
(pcase field
|
||||||
@ -1062,9 +1062,9 @@ This is useful for advising some Gnus-functionality that does not work in mu4e."
|
|||||||
(define-key map "$" #'mu4e-show-log)
|
(define-key map "$" #'mu4e-show-log)
|
||||||
(define-key map "H" #'mu4e-display-manual)
|
(define-key map "H" #'mu4e-display-manual)
|
||||||
|
|
||||||
;; Make 0..9 shortcuts for digit-argument. Actually, none of the bound
|
;; Make 0..9 shortcuts for digit-argument. Actually, none of the bound
|
||||||
;; functions seem to use a prefix arg but those bindings existed because we
|
;; functions seem to use a prefix arg but those bindings existed because we
|
||||||
;; used to use `suppress-keymap'. And possibly users added their own
|
;; used to use `suppress-keymap'. And possibly users added their own
|
||||||
;; prefix arg consuming commands.
|
;; prefix arg consuming commands.
|
||||||
(dotimes (i 10)
|
(dotimes (i 10)
|
||||||
(define-key map (kbd (format "%d" i)) #'digit-argument))
|
(define-key map (kbd (format "%d" i)) #'digit-argument))
|
||||||
@ -1192,9 +1192,14 @@ multipart/alternative part to toggle; toggle again (or use
|
|||||||
(defun mu4e-view-toggle-html ()
|
(defun mu4e-view-toggle-html ()
|
||||||
"Toggle between the HTML and plain-text alternatives.
|
"Toggle between the HTML and plain-text alternatives.
|
||||||
Works for `multipart/alternative' messages by pressing the
|
Works for `multipart/alternative' messages by pressing the
|
||||||
corresponding Gnus selector button in the buffer. For other
|
corresponding Gnus selector button in the buffer. For other
|
||||||
messages, toggle between the normal rendering and an
|
messages, toggle between the normal rendering and an shr-rendered
|
||||||
shr-rendered html version of the message."
|
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)
|
(interactive)
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(let ((inhibit-read-only t))
|
(let ((inhibit-read-only t))
|
||||||
|
|||||||
Reference in New Issue
Block a user