I recently discovered the Emacs Application Framework, which works quite nice for me. The only thing that's bothering me is, that I need to explicitly call eaf-open on a file, to open it with the framework. I tried to associate eaf with the file extension via (add-to-list 'auto-mode-alist '("\\.[pP][dD][fF]\\'" . eaf-mode)) but to no avail.

How can I tell Emacs that it should open PDF files with eaf?

  • 1
    I haven't tested this, but you could create a function that takes the name of the current file and call eaf-open with it. Then add this function in the hook of doc-view-mode.
    – darcamo
    Nov 11, 2020 at 18:10

1 Answer 1


You can modify the Emacs file association way by the following code.

(defun adviser-find-file (orig-fn file &rest args)
  (let ((fn (if (commandp 'eaf-open) 'eaf-open orig-fn)))
    (pcase (file-name-extension file)
      ("pdf"  (apply fn file nil))
      ("epub" (apply fn file nil))
      (_      (apply orig-fn file args)))))
(advice-add #'find-file :around #'adviser-find-file)
  • Thank you very much, works like a charm!
    – Määäxx
    Dec 8, 2020 at 13:43

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.