14

In org-mode I can define external links for example as

[[file+sys:path/to/document.pdf]]

The file document.pdf is then opened with an external pdf viewer. The org-mode documentation claims that this command "open[s] via OS, like double-click".

There is, however, a difference to "double-click", as I find that the system-specific default applications (for documents, websites, videos, etc.) are not respected in my setup; On Ubuntu 12.04 the default application for webpages was set to Firefox and only through org-mode local .html files are still openend with Chromium.

How do I configure org-mode to respect my default application settings?

7

Here are my settings:

(setq org-file-apps
      '((auto-mode . emacs)
        ("\\.x?html?\\'" . "firefox %s")
        ("\\.pdf\\'" . "evince \"%s\"")
        ("\\.pdf::\\([0-9]+\\)\\'" . "evince \"%s\" -p %1")
        ("\\.pdf.xoj" . "xournal %s")))
  • 2
    Helpful, although the question asks how to make org-mode respect the system defaults. This version would require us to set the defaults manually. – Dan Oct 30 '14 at 15:06
  • True, but the system defaults have a wide meaning. For instance I'm on Ubuntu, but I have to use ~/.mailcap to make Emacs use vlc, instead of Ubuntu's system defaults tools. – abo-abo Oct 30 '14 at 15:10
4

If you are using a Linux desktop environment, chances are that it is using xdg-utils. See this blog post.

Therefore, you may do this:

(setq org-file-apps
      '((auto-mode . emacs)
        ("\\.x?html?\\'" . "xdg-open %s")
        ("\\.pdf\\'" . "xdg-ope, \"%s\"")
        ("\\.pdf::\\([0-9]+\\)\\'" . "xdg-open \"%s\" -p %1")
        ("\\.pdf.xoj" . "xournal %s")))
0

There's a couple of utility vars defined in later versions of org-mode:

org-file-apps-defaults-gnu
org-file-apps-default-macosx
org-file-apps-default-windowsnt

that should set up reasonable defaults for those environments.

Use them like this:

(setq org-file-apps org-file-apps-defaults-macosx)

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.