From 841f6b7f85cd0f56be200a94fd494990987310e4 Mon Sep 17 00:00:00 2001 From: Lucien Cartier-Tilet Date: Fri, 26 Mar 2021 13:49:22 +0100 Subject: [PATCH] [Emacs] Give mu4e the ability to export mails to PDF again! --- org/config/emacs.org | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/org/config/emacs.org b/org/config/emacs.org index b1f6768..06f6f0e 100644 --- a/org/config/emacs.org +++ b/org/config/emacs.org @@ -4494,6 +4494,22 @@ signature to emails to the hook called when creating a new email. (add-hook 'mu4e-compose-mode-hook 'mml-secure-message-sign-pgpmime) #+END_SRC +mu4e used to be able to export emails to PDFs, but unfortunately this +possibility was discontinued. But we can (sort of) bring it back! +#+BEGIN_SRC emacs-lisp + (defun mu4e-action-open-as-pdf (msg) + "Export and open as PDF a mu4e `MSG'" + (let* ((date (mu4e-message-field msg :date)) + (infile (mu4e~write-body-to-html msg)) + (outfile (format-time-string "/tmp/%Y-%m-%d%H%M%S.pdf" date))) + (with-temp-buffer + (shell-command + (format "wkhtmltopdf %s %s" infile outfile) t)) + (find-file outfile))) + + (add-to-list 'mu4e-view-actions '("PDF view" . mu4e-action-open-as-pdf) t) +#+END_SRC + Lastly, some emails are better displayed in a browser than in Emacs. My Emacs build has the webkit browser enabled, so I’ll add an option to open with it emails.