Search code examples
emacselispmu

mu4e how to change lookup directory fro mu4e-action-view-as-pdf function


I'm trying to get to work the view as pdf function in mu4e, and I guess that the problem is the lookup directory of the executable msg2pdf. From the function definition I see

(defvar mu4e-msg2pdf "/usr/bin/msg2pdf" "Path to the msg2pdf toy.")

(defun mu4e-action-view-as-pdf (msg)
  "Convert the message to pdf, then show it.
Works for the message view."
  (unless (file-executable-p mu4e-msg2pdf)
    (mu4e-error "msg2pdf not found; please set `mu4e-msg2pdf'"))
  (let* ((pdf
      (shell-command-to-string
        (concat mu4e-msg2pdf " "
          (shell-quote-argument (mu4e-message-field msg :path))
          " 2> /dev/null")))
     (pdf (and pdf (> (length pdf) 5)
        (substring pdf 0 -1)))) ;; chop \n
    (unless (and pdf (file-exists-p pdf))
      (mu4e-warn "Failed to create PDF file"))
    (find-file pdf)))

where I changed the (defvar mu4e-msg2pdf "/usr/bin/msg2pdf" "Path to the msg2pdf toy.") to match the path where msg2pdf is. The problem is that from the debugger I see

Debugger entered--returning value: nil
  file-executable-p("/build/buildd/maildir-utils-0.9.9.5/toys/msg2pdf/msg2pdf")
* #[(msg) "\305!\204\n ......
* mu4e-action-view-as-pdf((.....
  mu4e-view-action()
  call-interactively(mu4e-view-action nil nil)

that the lookup path is not what I specified. Since I tried to chage it in different ways and apparently mu4e is ignoring me, does anybody knows how can I set the correct lookup path?


Solution

  • You can set the the variable mu4e-msg2pf to the path of the executable msg2pdf by adding the following to your init file

    (setq mu4e-msg2pdf "/path/to/msg2pdf")