EOS: Web Module
Table of Contents
(provide 'eos-web)
Web browsers, EWW and Firefox
Ewwwwww…
Wait, no, I mean the Emacs web browser built in to 24.4+
We can browse to anything that looks like a URL with C-x m
.
(global-set-key (kbd "C-x m") 'browse-url-at-point)
I use EWW as my default browser in Emacs; certain things, I need to jump out of
EWW and in to a real browser with javascript; which I can do if I just hit &
or O
– it'll drop me in to a firefox session without a hassle.
There are certain sites that, despite my best abilities, I cannot make work in EWW. For these, I launch Firefox directly, instead of hitting a silly man in the middle.
(use-package eww :defer t :init (setq browse-url-browser-function '((".*google.*maps.*" . browse-url-generic) ;; Github goes to firefox, but not gist ("http.*\/\/github.com" . browse-url-generic) ("groups.google.com" . browse-url-generic) ("docs.google.com" . browse-url-generic) ("melpa.org" . browse-url-generic) ("build.*\.elastic.co" . browse-url-generic) (".*-ci\.elastic.co" . browse-url-generic) ("internal-ci\.elastic\.co" . browse-url-generic) ("zendesk\.com" . browse-url-generic) ("salesforce\.com" . browse-url-generic) ("stackoverflow\.com" . browse-url-generic) ("apache\.org\/jira" . browse-url-generic) ("thepoachedegg\.net" . browse-url-generic) ("zoom.us" . browse-url-generic) ("t.co" . browse-url-generic) ("twitter.com" . browse-url-generic) ("\/\/a.co" . browse-url-generic) ("youtube.com" . browse-url-generic) ("." . eww-browse-url))) (setq shr-external-browser 'browse-url-generic) (setq browse-url-generic-program (executable-find "firefox")) (add-hook 'eww-mode-hook #'toggle-word-wrap) (add-hook 'eww-mode-hook #'visual-line-mode) :config (use-package s :ensure t) (define-key eww-mode-map "o" 'eww) (define-key eww-mode-map "O" 'eww-browse-with-external-browser) (define-key eww-mode-map "j" 'next-line) (define-key eww-mode-map "k" 'previous-line) (use-package eww-lnum :ensure t :config (bind-key "f" #'eww-lnum-follow eww-mode-map) (bind-key "U" #'eww-lnum-universal eww-mode-map)))
Let's also add some code so we get vimperator/eww-lnum style link hints everywhere
(use-package link-hint :ensure t :bind ("C-c f" . link-hint-open-link))
Search backwards, prompting to open any URL found. This is
fantastic for ERC buffers. I bind this to C-c u
because I use it
a lot.
(defun browse-last-url-in-brower () (interactive) (save-excursion (ffap-next-url t t))) (global-set-key (kbd "C-c u") 'browse-last-url-in-brower)