Skip to content

Commit

Permalink
mu4e: always include message-id in mu4e-view-message-text
Browse files Browse the repository at this point in the history
Regardless of mu4e-view-headers; and ensure the message-id is in
<brackets>.
  • Loading branch information
djcb committed Nov 5, 2023
1 parent 556396b commit c76c410
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions mu4e/mu4e-view.el
Original file line number Diff line number Diff line change
Expand Up @@ -661,14 +661,17 @@ As a side-effect, a message that is being viewed loses its
(run-hooks 'mu4e-view-rendered-hook))))

(defun mu4e-view-message-text (msg &optional all-headers)
"Return the pristine MSG as a string.
"Return the rendered MSG as a string.
If ALL-HEADERS is non-nil, include all headers."
(with-temp-buffer
(insert-file-contents-literally
(mu4e-message-readable-path msg) nil nil nil t)
(let ((gnus-inhibit-mime-unbuttonizing nil)
(gnus-unbuttonized-mime-types '(".*/.*"))
(gnus-inhibit-hiding all-headers))
(gnus-inhibit-hiding all-headers)
(mu4e-view-fields mu4e-view-fields))
;; ensure we always include the message-id.
(cl-pushnew ':message-id mu4e-view-fields)
(mu4e--view-render-buffer msg)
(buffer-substring-no-properties (point-min) (point-max)))))

Expand Down Expand Up @@ -771,7 +774,7 @@ Note that for some messages, this can trigger high CPU load."
(mu4e-view-refresh))

(defun mu4e--view-gnus-display-mime (msg)
"Like `gnus-display-mime' but include mu4e headers to MSG."
"Like `gnus-display-mime', but include mu4e headers to MSG."
(lambda (&optional ihandles)
(gnus-display-mime ihandles)
(unless ihandles
Expand All @@ -782,8 +785,11 @@ Note that for some messages, this can trigger high CPU load."
(dolist (field mu4e-view-fields)
(let ((fieldval (mu4e-message-field msg field)))
(pcase field
((or ':path ':maildir :list ':user-agent ':message-id)
((or ':path ':maildir ':list)
(mu4e--view-gnus-insert-header field fieldval))
(':message-id
(when-let ((msgid (plist-get msg :message-id)))
(mu4e--view-gnus-insert-header field (format "<%s>" msgid))))
(':mailing-list
(let ((list (plist-get msg :list)))
(if list (mu4e-get-mailing-list-shortname list) "")))
Expand All @@ -796,8 +802,8 @@ Note that for some messages, this can trigger high CPU load."
(':size (mu4e--view-gnus-insert-header
field (mu4e-display-size fieldval)))
((or ':subject ':to ':from ':cc ':bcc ':from-or-to
':date :attachments ':signature
':decryption)) ; handled by Gnus
':user-agent ':date ':attachments
':signature ':decryption)) ;; handled by Gnus
(_
(mu4e--view-gnus-insert-header-custom msg field)))))
(let ((gnus-treatment-function-alist
Expand Down

0 comments on commit c76c410

Please sign in to comment.