Search code examples
emacselisp

Disable openwith during execution of a mu4e function


Hi I'm using openwith to open pdf files in okular, the relevant lines are

(require 'openwith) ;open files with external program                                                                                                                                                                            

(setq openwith-associations '(("\\.pdf\\'" "okular" (file)))) ;use okular for pdf                                                                                                                                                
(openwith-mode t)

When I want to send out a message with mu4e though if there is attached a pdf, instead of completing the function message-send-and-exit, the pdf opens in okular and the message is never sent.

I was thinking of adding a hook the like

(add-hook 'message-send-and-exit (openwith-mode nil))

but I'm not a lisp expert and this doesn't solve the problem, probably I'm doing something wrong, anyone can give me a hint?


Solution

  • Openwith can interfere with attachments. Since mu4e reuses message mode, you can do the following to avoid the clash:

    ;; prevent <openwith> from interfering with mail attachments
    (require 'mm-util)
    (add-to-list 'mm-inhibit-file-name-handlers 'openwith-file-handler)