Suppose, we have a link [[https://www.google.com/][Google]]. When I put the cursor at the link and run org-open-at-point, instead of opening https://www.google.com/ in browser it downloads the page to /var/tmp and opens the file in browser: file:///var/tmp/kdecache-user/krun/20635_0_. All the css and js are broken of course.

Can I make it open the direct link in browser? Or maybe, it's not Emacs, but KDE.

  • What's the "it" that downloads the page to /var/tmp?
    – NickD
    Apr 9, 2021 at 18:49
  • What happens if you say ESC ESC : (browse-url "https://www.google.com/") RET?
    – NickD
    Apr 9, 2021 at 18:56
  • @NickD "it" is the html page of google. It is downloaded into a file and then opened in Firefox.
    – user4035
    Apr 9, 2021 at 19:22
  • @NickD When I execute the command, I get the same thing: it is downloaded into a file and the file is opened in Firefox.
    – user4035
    Apr 9, 2021 at 19:23
  • @NickD Does it work correctly on your system?
    – user4035
    Apr 9, 2021 at 19:24

1 Answer 1


[This answer is meant as a tutorial introduction to how one would debug problems like the OP's, so it is more detailed than the "answer" which is just the setting of browse-url-browser-function below. But I have always found answers of the sort "Do this - problem solved" unsatisfactory: I like to understand what's going on. YMMV, in which case skip the long-winded explanations.]

org-open-at-point calls org-link-open which uses the variable org-link-parameters to look up the :follow property for the type of the link. In this case the type is https and the :follow property turns out to be an anonymous function that is set when the file ol.el[c] (l.1349 in my version of the file) is loaded:

;;;; "http", "https", "mailto", "ftp", and "news" link types
(dolist (scheme '("ftp" "http" "https" "mailto" "news"))
  (org-link-set-parameters scheme
               (lambda (url arg)
                 (browse-url (concat scheme ":" url) arg))))

The upshot is that this anonymous (lambda) function calls browse-url. It is unlikely that the problem as described is caused by any of the above, so we concentrate on browse-url.

Reading the doc string of browse-url (C-h f browse-url) uncovers the fact that it calls the function that is specified as the value of the variable browse-url-browser-function. After prodding the OP with a question, we find out that the OP's setting of that variable was browse-url-default-browser. Unfortunately for debugging purposes (remote debugging purposes, no less), that function pokes around all over the place until it finds something that it can use and then calls that something. So at that point, it was more expedient to suggest that the OP bypass that and set the browse-url-browser-function variable directly to the function corresponding to the desired browser:

(setq browse-url-browser-function #'browse-url-firefox)

Setting that in the init file did the trick for the OP. Other "direct to external browser" function available include browse-url-chrome and browse-url-mozilla.

The only remaining mystery is why the default browser function did what the OP described. From the description, it seems that the culprit is browse-url-kde. I have no way to test that, but a KDE user can confirm (or refute) that claim by evaluating the following (e.g. in the *scratch* buffer - paste the expression and type C-j after the closing paren):

(browse-url-kde "https://www.google.com")

If that does what the OP describes, it's arguably a bug in the browse-url-kde function and should probably be reported (M-x report-emacs-bug).

  • 1
    What an excellent answer, thank you! Mar 1, 2022 at 23:23
  • 1
    Glad you liked it! It's been a while but I think it was fun to write up as well :-)
    – NickD
    Mar 2, 2022 at 22:41
  • It's been a year, but I'm wondering if you might be able to recommend a method add another browser? There is no #'browse-url-librewolf function. I assume that it's not as simple as copying defun browse-url-firefox to your config.el and changing firefox to librewolf? Jul 20, 2023 at 18:24
  • It pretty much is: you'll also have to define a browse-url-librowolf-program variable and a browse-url-librewolf-arguments variable in analogy with the corresponding firefox variables - but that should be it. Besides, if you try it and it doesn't work, you know where to ask :-)
    – NickD
    Jul 20, 2023 at 18:42
  • Very excellent answer, Nick! It's appreciated!
    – ReneFroger
    Jan 28 at 10:01

Your Answer

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

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