summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Troestler <Christophe.Troestler@umons.ac.be>2019-04-20 12:14:44 +0200
committerChristophe Troestler <Christophe.Troestler@umons.ac.be>2019-04-20 12:19:21 +0200
commit2a8c57e56d4f6502ffd9b57605708157f1894260 (patch)
tree255d38375fecda53c46b9320632444b5eea2faf6
parentd7b21f1d8b0fb94ea754a5a2d68e44d3c970e37b (diff)
Do not repeat the "From" and "To" when converting to HTML
Before this commit the HTML was looking as From: From: email To: To: email
-rw-r--r--mu4e/mu4e-actions.el17
1 files changed, 15 insertions, 2 deletions
diff --git a/mu4e/mu4e-actions.el b/mu4e/mu4e-actions.el
index 9a63c32..8e4b245 100644
--- a/mu4e/mu4e-actions.el
+++ b/mu4e/mu4e-actions.el
@@ -71,6 +71,19 @@ Works for the message view."
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+(defun mu4e~action-header-to-html (msg field)
+ "Convert the FIELD of MSG to an HTML string."
+ (mapconcat
+ (lambda(c)
+ (let* ((name (when (car c)
+ (replace-regexp-in-string "[[:cntrl:]]" "" (car c))))
+ (email (when (cdr c)
+ (replace-regexp-in-string "[[:cntrl:]]" "" (cdr c))))
+ (short (or name email)) ;; name may be nil
+ (long (if name (format "%s <%s>" name email) email)))
+ (if mu4e-view-show-addresses long short)))
+ (mu4e-message-field msg field) ", "))
+
(defun mu4e~write-body-to-html (msg)
"Write MSG's body (either html or text) to a temporary file;
return the filename."
@@ -86,9 +99,9 @@ return the filename."
(with-temp-buffer
(insert "<head><meta charset=\"UTF-8\"></head>\n")
(insert (concat "<p><strong>From</strong>: "
- (mu4e~view-construct-contacts-header msg :from) "</br>"))
+ (mu4e~action-header-to-html msg :from) "</br>"))
(insert (concat "<strong>To</strong>: "
- (mu4e~view-construct-contacts-header msg :to) "</br>"))
+ (mu4e~action-header-to-html msg :to) "</br>"))
(insert (concat "<strong>Date</strong>: "
(format-time-string mu4e-view-date-format (mu4e-message-field msg :date)) "</br>"))
(insert (concat "<strong>Subject</strong>: " (mu4e-message-field msg :subject) "</p>"))