Emacs Init: Setup 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 opens Operating System's default browser. [see Emacs: Open File Path Under Cursor 🚀]

You can set emacs to use a Emacs: Eww Web Browser

Here's how to set specific browser to open links.

put this in your Emacs Init File:

;; set browser to emacs default
(setq browse-url-browser-function 'browse-url-default-browser)

;; set browser to emacs eww browser
(setq browse-url-browser-function 'eww-browse-url)

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

;; use diff browsers depending on url
   ("thefreedictionary\\.com" . eww-browse-url)
   ("." . browse-url-default-browser)))

[see Emacs: Regular Expression]

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.

Emacs, Web Browser