           (goto-char (point-min))
           (keep-lines regexp))))
 
-    (defun modi/eww-back-dwim ()
-      "Call `eww-back-url' if the buffer is read only.
-Else perform the default backspace action."
-      (interactive)
-      (if buffer-read-only
-          (eww-back-url)
-        (delete-backward-char 1)))
-
     (defun modi/eww-browse-url-of-file ()
       "Browse the current file using `eww'."
       (interactive)


    (bind-keys
     :map eww-mode-map
      ("G"           . eww) ; Go to URL
      ("g"           . eww-reload) ; Reload
      ("h"           . eww-list-histories) ; View history
      ("r"           . eww-reload) ; Reload
      ("p"           . shr-previous-link)
      ("<backtab>"   . shr-previous-link) ; S-TAB Jump to previous link on the page
      ("n"           . shr-next-link)
      ("<tab>"       . shr-next-link)
      ("N"           . eww-next-url)
      ("P"           . eww-previous-url)
      ("<backspace>" . modi/eww-back-dwim)
      ("w"           . modi/eww-copy-url-dwim)
      ("\<"          . eww-back-url)
      ("\>"          . eww-forward-url)
      ("/"           . highlight-regexp)
      ("k"           . modi/eww-keep-lines))
    ;; Make the binding for `revert-buffer' do `eww-reload' in eww-mode
    (define-key eww-mode-map [remap revert-buffer] #'eww-reload)
    (>=e "25.0"
        (bind-key "R" #'eww-readable eww-mode-map)) ; hit `g' to revert to default view
    (bind-keys
     :map eww-text-map ; For single line text fields
      ("<backtab>"  . shr-previous-link) ; S-TAB Jump to previous link on the page

(provide 'setup-eww)

;; Default eww key bindings
;; |-----------+---------------------------------------------------------------------|
;; | Key       | Function                                                            |
;; |-----------+---------------------------------------------------------------------|
;; | &         | Browse the current URL with an external browser.                    |
;; | -         | Begin a negative numeric argument for the next command.             |
;; | 0 .. 9    | Part of the numeric argument for the next command.                  |
;; | C         | Display a buffer listing the current URL cookies, if there are any. |
;; | H         | List the eww-histories.                                             |
;; | F         | Toggle font between variable-width and fixed-width.                 |
;; | G         | Go to a URL                                                         |
;; | R         | Readable mode                                                       |
;; | S         | List eww buffers                                                    |
;; | d         | Download URL under point to `eww-download-directory'.               |
;; | g         | Reload the current page.                                            |
;; | q         | Quit WINDOW and bury its buffer.                                    |
;; | v         | `eww-view-source'                                                   |
;; | w         | `eww-copy-page-url'                                                 |
;; |-----------+---------------------------------------------------------------------|
;; | b         | Add the current page to the bookmarks.                              |
;; | B         | Display the bookmark list.                                          |
;; | M-n       | Visit the next bookmark                                             |
;; | M-p       | Visit the previous bookmark                                         |
;; |-----------+---------------------------------------------------------------------|
;; | t         | Go to the page marked `top'.                                        |
;; | u         | Go to the page marked `up'.                                         |
;; |-----------+---------------------------------------------------------------------|
;; | n         | Go to the page marked `next'.                                       |
;; | p         | Go to the page marked `previous'.                                   |
;; |-----------+---------------------------------------------------------------------|
;; | l         | Go to the previously displayed page.                                |
;; | r         | Go to the next displayed page.                                      |
;; |-----------+---------------------------------------------------------------------|
;; | TAB       | Move point to next link on the page.                                |
;; | S-TAB     | Move point to previous link on the page.                            |
;; |-----------+---------------------------------------------------------------------|
;; | SPC       | Scroll up                                                           |
;; | DEL/Bkspc | Scroll down                                                         |
;; | S-SPC     | Scroll down                                                         |
;; |-----------+---------------------------------------------------------------------|
