17

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?

4 Answers 4

9

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
  • 4
    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, 2014 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, 2014 at 15:10
6

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")))
1

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)
0

C-h describe-variable org-file-apps-macos

Copy default application settings, then add your own.

My Own config is (".png" . "open %s")

(setq org-file-apps-macos '((remote . emacs)
                            (system . "open %s")
                            ("ps.gz" . "gv %s")
                            ("eps.gz" . "gv %s")
                            ("dvi" . "xdvi %s")
                            ("fig" . "xfig %s")
                            (t . "open %s")
                            (".png" . "open %s")))

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.