1

I try to convert to pdf with this following code found on Emacs SE:

(defun mu4e-action-save-to-pdf (msg)
   (let* ((date (mu4e-message-field msg :date))
          (infile (mu4e~write-body-to-html msg))
          (outfile (format-time-string "%Y-%m-%d%H%M%S.pdf" date)))
     (with-temp-buffer
       (shell-command
         (format "wkhtmltopdf %s ~/Desktop/%s" infile outfile) t))))

(add-to-list 'mu4e-view-actions '("Save to PDF" . mu4e-action-save-to-pdf) t)

But when I launch the action it says:

void function mu4e-write-body-to-html

When I M-x mu4e-write<TAB> nothing exists. Can someone tell me how to fix that?

9
  • I edited your question but for future reference, you should have provided a link to where you found that code.
    – NickD
    Commented Oct 26, 2022 at 13:42
  • The function mu4e~write-body-to-html is defined in mu4e-view-old.el[c] and seems to be outdated. Note the tilde ~ in the name, which is a non-standard convention for names in Emacs. You can try M-x load-library RET mu4e-view-old to load the library (assuming it's in your load-path): that should resolve the error message you get, but whether that will actually work... I don't know but I somehow doubt it.
    – NickD
    Commented Oct 26, 2022 at 14:13
  • @jagrg can you take a look at this? You answered the linked question, so I figure you know more about mu4e than I do (which is not hard, since I know almost nothing about it). [I'm not sure whether the at-reference will work btw, but I thought it's worth trying]
    – NickD
    Commented Oct 26, 2022 at 14:24
  • And how can I find this library or at least the lisp code for that function ?
    – mcp
    Commented Oct 27, 2022 at 15:22
  • It should be in the same place as mu4e.el I think. Did M-x load-library RET mu4e-view-old not work?
    – NickD
    Commented Oct 27, 2022 at 15:32

1 Answer 1

0

If I recall, mu4e no longer uses its own built-in view mode, it relies on functions from Gnus. If that's correct, I suspect the file mu4e-view-old.el is no longer loaded automatically. You can load it via (require 'mu4e-view-old). That should make the function you want available.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.