0

Whenever I use org-store-link and org-insert-link for PDFs, it stores the link as file: type. This will open the link as an external PDF file with my OS PDF viewer.

Is there a way to set up org-store-link to use pdftools of docview as the default viewer for when storing links?

Thanks!

2 Answers 2

1

One solution would be to tell org to open pdf file: links with pdf-tools. Do this thusly:

(push '("\\.pdf\\'" . emacs) org-file-apps)
1

Another more indirect approach is to make sure that your ~/.mailcap file does what you want with PDF files:

...
application/pdf; emacsclient %s
...

and making sure that you have started the server in your emacs with M-x server-start.

It's indirect in that several things have to go "right", but they generally are "right" by default - unless you've changed them of course. The following is Linux-only (I have no idea how/whether MacOS and Windows handle mailcaps):

  • org-file-apps should include the entry ("\\.pdf\\'" . default)
  • org-file-apps-gnu should include the entry (system . mailcap)
  • ~/.mailcap should include the stanza above

The trouble of course is that debugging problems involves looking in three places instead of one. OTOH, if you want uniform treatment of PDF files, that's a central place to do it, so many programs that know about ~/.mailcap will open PDF files in Emacs; if you do the customization in org-file-apps only Org mode knows (or at least cares) about it, which, depending on one's point of view, may be considered either a limitation or a feature.

2
  • 1
    Thanks, NickD, I have accepted the other answer as it was easier for me to follow and implement as an Emacs beginner. Mar 10, 2022 at 7:10
  • 1
    I would have done the same.
    – NickD
    Mar 10, 2022 at 14:43

Your Answer

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

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