Emacs-focused Web Browsing
I spend most of my computer life in Emacs, as many tasks work better. Sure apply caveats to that statement, but the mouse-less focus of Emacs is efficient. Clarification… I don’t hate the mouse, as much as changing between the mouse and the keyboard, so if I can do everything without a mouse, my efficiency improves. With that statement, let me talk about web browsing, which is traditionally mouse-oriented.
I use three different browsers:
- EWW for anything I can, as I can stay in Emacs where I probably am, and it is easier to read, scroll, copy, etc. Granted, this isn’t always possible, so…
- Chrome for work-related sites and their web applications
- Firefox for everything else (and this is the default browser application in my operating system)
R to view the contents without the poorly formatted header links of most sites, or
& to load it in a graphical browser.
I’m currently using Evil mode within Spacemacs, so extract some goodies from my EWW configuration. For instance, let’s use the Duck as the default search engine and whatnot:
(setq browse-url-browser-function 'eww-browse-url shr-use-colors nil shr-bullet "• " shr-folding-mode t eww-search-prefix "https://duckduckgo.com/html?q=" url-privacy-level '(email agent cookies lastloc))
I also bind a number of functions to the
, key so that
which-key can remind me, but really it works pretty well out of the box.
Going to Chrome
(defun osx-browse-url-forwork (url &optional new-window browser focus) "Open URL in Brave, Vivaldi, or whatever I'm running on OS X for my day job. The parameters, URL, NEW-WINDOW, and FOCUS are as documented in the function, `osx-browse-url'." (interactive (osx-browse-interactive-form)) (callf or browser "com.google.Chrome") ;; Choices: com.apple.Safari (osx-browse-url url new-window browser focus)) (defun osx-browse-url-personal (url &optional new-window browser focus) "Open URL in Firefox for my personal surfing. The parameters, URL, NEW-WINDOW, and FOCUS are as documented in the function, `osx-browse-url'." (interactive (osx-browse-interactive-form)) (callf or browser "org.mozilla.Firefox") (osx-browse-url url new-window browser focus))
Next, I can make a list of URLs that use a particular browser by changing the
browse-url-browser-function list of conses:
(setq ;; See: http://ergoemacs.org/emacs/emacs_set_default_browser.html browse-url-browser-function '(("docs\\.google\\.com" . osx-browse-url-forwork) ("bigpanda\\.io" . osx-browse-url-forwork) ("inday\\.io" . osx-browse-url-forwork) ;; ...snip... ("dndbeyond.com" . osx-browse-url-personal) ;; ...snip... ("." . eww-browse-url)))
Selecting a link in an org mode file or wherever, brings the most appropriate browser, and the default falls back to EWW.
What makes EWW especially good, is adding the ace-link feature from the Avy library. This allows me to type
o and have every link on the page clickable with one or two letters. See the Github for an animation if you aren’t familiar. I like it everywhere, including binding
I like it so much, I want that same feature in my graphical browsers.
Fixing Chrome and Firefox
In my mind, one failure of web browsers, is lack of a mouse-less workflow. However, people have been inventing a lot of extensions to address this. I’ve tried many, and currently using SurfingKeys as it seems pretty simple (or was at one point) and works the same for both Chrome and Firefox.
My one complaint is that the keybindings don’t match
o, but that is pretty to address. On the Settings menu item, click the Advanced button, and enter the following URL:
This simply contains something like this:
unmap('ob'); // I don't need the omnibar search feature, unmap('od'); // and I want to use the `o` key ... unmap('og'); unmap('oh'); unmap('oi'); unmap('om'); unmap('on'); unmap('ow'); unmap('ox'); unmap('oy'); map('o', 'f'); // Typical link jumping map('ao', 'af'); // Open link in a new, focused tab map('go', 'gf'); // Open link in a new, non-focused tab map('co', 'cf'); // Open multiple links... I don't use this
I will probably expand that to match more closely my Emacs keybindings.