Emacs: Set Default Browser

By Xah Lee. Date: . Last updated: .

When you click on a link or call find-file-at-point (alias ffap) when cursor is on a URL, emacs will call OS's default browser. 〔►see Emacs: Open File Path Under Cursor

You can tell emacs to use a specific browser (For example, Firefox, Google Chrome).

Here's how to set specific browser to open links. Put in your emacs init.

;; set specific browser to open links
(setq browse-url-browser-function 'browse-url-firefox)
(setq browse-url-browser-function 'browse-url-chromium) ; google's browser
(setq browse-url-browser-function 'eww-browse-url) ; emacs browser

You can also set up a regex list to open specific browser depending on URL.

;; use browser depending on url
  ("wikipedia\\.org" . browse-url-firefox)
  ("github" . browse-url-chromium)
  ("thefreedictionary\\.com" . eww-browse-url)
  ("." . browse-url-default-browser)

〔►see Emacs: Regex Tutorial

To see more browsers, call describe-variable then browse-url-browser-function, then click on the link to jump to the source code definition.

Linux: Set Default Browser

“Default Browser” depends on your operating system's settings.

Linux: Set Default App

Like it? Buy Xah Emacs Tutorial. Thanks.

or, buy something from Best Keyboard for Emacs