From ada52dfe80a66ef38e7a6c97392241ca28390e04 Mon Sep 17 00:00:00 2001 From: djcb Date: Sat, 21 Apr 2012 09:31:39 +0300 Subject: [PATCH] * add example action to view messages as pdfs --- emacs/mu4e-utils.el | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/emacs/mu4e-utils.el b/emacs/mu4e-utils.el index 5f934d9e..e75a6908 100644 --- a/emacs/mu4e-utils.el +++ b/emacs/mu4e-utils.el @@ -341,8 +341,9 @@ processing takes part in the background, unless buf is non-nil." (lambda (proc msg) (let* ((status (process-status proc)) (code (process-exit-status proc)) - ;; sadly, fetchmail returns '1' when there is no mail; this is not really - ;; an error of course, but it's hard to distinguish from a genuine error + ;; sadly, fetchmail returns '1' when there is no mail; this is + ;; not really an error of course, but it's hard to distinguish + ;; from a genuine error (maybe-error (or (not (eq status 'exit)) (/= code 0)))) (message nil) ;; there may be an error, give the user up to 5 seconds to check @@ -413,6 +414,20 @@ of lines in the e-mail message." (shell-command-to-string (concat "wc -l < " (shell-quote-argument (plist-get msg :path)))))) + +(defun mu4e-show-as-pdf (msg) + "Demonstration function for `mu4e-view-actions'. Show attachment as PDF." + (unless (file-executable-p mu4e-msg2pdf) + (error "msg2pdf not found; please set `mu4e-msg2pdf'")) + (let* ((pdf + (shell-command-to-string + (concat mu4e-msg2pdf " " + (shell-quote-argument (plist-get msg :path))))) + (pdf (and pdf (substring pdf 0 -1)))) ;; chop \n + (unless (file-exists-p pdf) + (error "Failed to create PDF file")) + (find-file pdf))) + (defun mu4e-capture-message (msg) "Remember MSG; we can create a an attachment based on this msg with `mu4e-insert-captured-message-as-attachment'."