0

When I do C-c C-e h o the file opens in an Emacs buffer instead of my default browser which is odd because org-mode links do open in the browser as is the case when I preview a file from web-mode, so Emacs must know how to open the default windows program for html files.

I have tried to customize the org-file-apps variable as per an answer in this question. I put in the cygwin path of browser executable and org-mode now indeed opens the browser but the browser fails to open the file as Emacs gives it a cygwin path to the html file, and I don't know what magic I would have to insert to convert the file path to a windows one. In any case it should open the browser with default setting for this variable, which was default before I changed it.

Stefan
  • 26,154
  • 3
  • 46
  • 84
Shane
  • 101
  • 2

1 Answers1

0

Whilst I feel a bit sheepish about answering my own question I have found a solution. If you put something like this in you .emacs then the exported file will be opened by the Windows default browser. The program cygstart translates the URL or file path into a Windows equivalent one and opens the default program associated with the file extension. In the snippet bellow I have applied the fix for HTML and PDF file, others can be added as required. I suspect the intention is that org mode should do this by default as that's what it does on my Ubuntu system, but after taking a quick look at the Org Mode code, it seems like it is not handling the Cygwin case correctly. Maybe I will submit a fix one day!

(defun my-org-mode-hook ()
  (setq org-file-apps
    (quote
     ((auto-mode . emacs)
      ("\\.x?html?\\'" . "cygstart %s")
      ("\\.pdf\\'" . "cygstart %s")))))

(add-hook 'org-mode-hook  'my-org-mode-hook)
Shane
  • 101
  • 2