To eww or not to eww

Recent Emacs versions include a decent text based web browser called eww. There is a good example configuration here. I found that I like using eww for some things, but at other times I want to use a full GUI web browser (I like Firefox).

I set eww to be my default browser in Emacs with

(setq browse-url-browser-function 'eww-browse-url)

but then I create some wrapper functions for times when I want to use my system default browser (i.e. Firefox).

In mu4e emails, hitting g will now open a URL in eww, but with the following lines I can use G to open in Firefox:

;; open link in firefox rather than eww
(defun bjm/mu4e-view-go-to-url-gui ()
  "Wrapper for mu4e-view-go-to-url to use gui browser instead of eww"
  (let ((browse-url-browser-function 'browse-url-default-browser))
;; bind it
(define-key mu4e-view-mode-map (kbd "G") 'bjm/mu4e-view-go-to-url-gui)

In elfeed, hitting b opens an article in eww if that is set to be the default Emacs browser. With the following lines I can hit B to open an article in Firefox. Note that I had to resort to calling the Mac open command to open the URL with the system default browser. On linux systems the xdg-open command should do the same thing.

;; browse article in gui browser instead of eww
(defun bjm/elfeed-show-visit-gui ()
  "Wrapper for elfeed-show-visit to use gui browser instead of eww"
  (let ((browse-url-generic-program "/usr/bin/open"))
    (elfeed-show-visit t)))

(define-key elfeed-show-mode-map (kbd "B") 'bjm/elfeed-show-visit-gui)
  • Link to the example configuration is incorrect by ending with a newline character (%0A), I got a 404 error after clicking it.

  • Might be worth mentioning that you can bind browse-url-browser function to be a list which determins what browser opens by link name:

    (setq browse-url-browser function ‘((“.*youtube.*” . browse-url-firefox) (“.” . eww-browse-url)))

    Will open all youtube links in FF and everything else in eww, for example.

    • Thanks, this is mentioned in the configuration I linked to but is helpful to mention here as well.

  • Tom

    As a side note: I use this function to view html buffers with eww without saving etc:

    (defun eww-render-current-buffer ()
    “Render HTML in the current buffer with EWW”
    (eww-display-html ‘utf8 (buffer-name)))