1

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
  • 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 '20 at 18:10
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)
1
  • Thank you very much, works like a charm! – Määäxx Dec 8 '20 at 13:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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