Emacs Init: Setup Default Browser

By Xah Lee. Date: . Last updated: .

Set URL to open in eww

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)

💡 TIP: useful when you click on a link or Alt+x find-file-at-point when cursor is on a URL. 〔see Emacs: Open File Path Under Cursor 🚀

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

Set browse URL handler

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

;; use diff browsers depending on url
(setq
 browse-url-handlers
 '(
   ("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