summaryrefslogtreecommitdiff
path: root/evil-collection-eww.el
blob: 8667e2deac52611fc032bdd8df4d89460e8bb776 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
;;; evil-collection-eww.el --- Evil bindings for EWW -*- lexical-binding: t -*-

;; Copyright (C) 2017 Pierre Neidhardt

;; Author: Pierre Neidhardt <ambrevar@gmail.com>
;; Maintainer: James Nguyen <james@jojojames.com>
;; Pierre Neidhardt <ambrevar@gmail.com>
;; URL: https://github.com/jojojames/evil-collection
;; Version: 0.0.1
;; Package-Requires: ((emacs "25.1"))
;; Keywords: evil, eww, tools

;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published
;; by the Free Software Foundation; either version 3, or (at your
;; option) any later version.
;;
;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.
;;
;; For a full copy of the GNU General Public License
;; see <http://www.gnu.org/licenses/>.

;;; Commentary:
;; Evil bindings for EWW.

;;; Code:
(require 'eww)
(require 'evil)

(defun evil-collection-eww-setup ()
  "Set up `evil' bindings for `eww'."

  (evil-define-key 'normal eww-mode-map
    "^" 'eww-up-url
    "u" 'eww-up-url
    "U" 'eww-top-url
    (kbd "<backspace>") 'eww-back-url
    "H" 'eww-back-url
    "L" 'eww-forward-url

    "gf" 'eww-view-source ; Like qutebrowser.

    "yu" 'eww-copy-page-url

    "&" 'eww-browse-with-external-browser
    "C" 'url-cookie-list
    "D" 'eww-toggle-paragraph-direction
    "X" 'eww-set-character-encoding
    "x" 'eww-toggle-fonts
    "d" 'eww-download
    "b" 'eww-add-bookmark

    "]" 'eww-next-url
    "[" 'eww-previous-url
    "gj" 'eww-next-url
    "gk" 'eww-previous-url

    ;; open
    (kbd "S-<return>") 'eww
    "go" 'eww

    (kbd "SPC") 'scroll-up-command
    (kbd "S-SPC") 'scroll-down-command
    (kbd "<tab>") 'shr-next-link
    (kbd "<backtab>") 'shr-previous-link

    ;; bookmarks
    "gb" 'eww-list-bookmarks

    "gh" 'eww-list-histories
    "gt" 'eww-list-buffers ; Like dwb, qutebrowser.


    ;; refresh
    "gr" 'eww-reload

    ;; quit
    "q" 'quit-window
    "ZQ" 'quit-window
    "ZZ" 'quit-window)

  (evil-set-initial-state 'eww-history-mode 'motion)
  (evil-define-key 'motion eww-history-mode-map
    (kbd "<return>") 'eww-history-browse
    ;; refresh
    "gr" 'revert-buffer
    ;; quit
    "q" 'quit-window
    "ZQ" 'quit-window
    "ZZ" 'quit-window)

  (evil-set-initial-state 'eww-buffers-mode 'motion)
  (evil-define-key 'motion eww-buffers-mode-map
    "D" 'eww-buffer-kill
    (kbd "<return>") 'eww-buffer-select
    "]" 'eww-buffer-show-next
    "[" 'eww-buffer-show-previous
    "gj" 'eww-buffer-show-next
    "gk" 'eww-buffer-show-previous
    ;; refresh
    "gr" 'revert-buffer
    ;; quit
    "q" 'quit-window
    "ZQ" 'quit-window
    "ZZ" 'quit-window)

  (evil-set-initial-state 'eww-bookmark-mode 'motion)
  (evil-define-key 'motion eww-bookmark-mode-map
    "D" 'eww-bookmark-kill
    (kbd "<return>") 'eww-bookmark-browse
    "yu" 'eww-bookmark-yank
    ;; refresh
    "gr" 'revert-buffer
    ;; quit
    "q" 'quit-window
    "ZQ" 'quit-window
    "ZZ" 'quit-window))

(provide 'evil-collection-eww)
;;; evil-collection-eww.el ends here