Emacs: Set Default Browser

By Xah Lee. Date: . Last updated: .

When you click on a link or Alt+x find-file-at-point 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, Alt+x 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

If you have a question, put $5 at patreon and message me on xah discord.
Or support me by Buy Xah Emacs Tutorial

Emacs Tutorial

Emacs Init

Emacs Keys


ELisp Examples

ELisp Write Major Mode

Emacs Init

Init Basics


text editing