evil-collection/evil-collection-eww.el

154 lines
4.5 KiB
EmacsLisp
Raw Normal View History

2017-12-13 14:34:51 +01:00
;;; evil-collection-eww.el --- Evil bindings for EWW -*- lexical-binding: t -*-
;; Copyright (C) 2017 Pierre Neidhardt
2018-08-27 10:41:51 +02:00
;; Author: Pierre Neidhardt <mail@ambrevar.xyz>
2017-12-13 14:34:51 +01:00
;; Maintainer: James Nguyen <james@jojojames.com>
2018-08-27 10:41:51 +02:00
;; Pierre Neidhardt <mail@ambrevar.xyz>
2018-03-02 02:22:38 +01:00
;; URL: https://github.com/emacs-evil/evil-collection
2017-12-13 14:34:51 +01:00
;; 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-collection)
2018-02-25 02:14:05 +01:00
(defvar evil-collection-eww-maps '(eww-mode-map
eww-history-mode-map
eww-buffers-mode-map
eww-bookmark-mode-map))
;;;###autoload
2017-12-13 14:34:51 +01:00
(defun evil-collection-eww-setup ()
"Set up `evil' bindings for `eww'."
(evil-collection-define-key 'normal 'eww-mode-map
2017-12-13 14:34:51 +01:00
"^" '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.
2017-12-13 14:34:51 +01:00
"&" 'eww-browse-with-external-browser
"gc" 'url-cookie-list
"zd" 'eww-toggle-paragraph-direction
"ze" 'eww-set-character-encoding
"zf" 'eww-toggle-fonts
2017-12-13 14:34:51 +01:00
"d" 'eww-download
"m" 'eww-add-bookmark
"R" 'eww-readable ; Default binding.
"r" 'eww-readable
2017-12-13 14:34:51 +01:00
2019-03-16 18:54:12 +01:00
"]]" 'eww-next-url
"[[" 'eww-previous-url
2017-12-13 14:34:51 +01:00
"gj" 'eww-next-url
"gk" 'eww-previous-url
;; open
(kbd "S-<return>") 'eww-browse-with-external-browser
"go" 'eww-browse-with-external-browser
"o" 'eww ; Like qutebrowser.
2017-12-13 14:34:51 +01:00
(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.
2017-12-13 14:34:51 +01:00
;; refresh
"gr" 'eww-reload
;; quit
"q" 'quit-window
"ZQ" 'quit-window
"ZZ" 'quit-window)
(evil-collection-define-key 'operator 'eww-mode-map
"u" '(menu-item
""
nil
:filter (lambda (&optional _)
(when (memq evil-this-operator
evil-collection-yank-operators)
2018-02-24 09:22:48 +01:00
(setq evil-inhibit-operator t)
#'eww-copy-page-url))))
(evil-collection-inhibit-insert-state 'eww-history-mode-map)
2018-02-22 17:36:44 +01:00
(evil-set-initial-state 'eww-history-mode 'normal)
(evil-collection-define-key 'normal 'eww-history-mode-map
2019-06-06 08:03:54 +02:00
(kbd "RET") 'eww-history-browse
2017-12-13 14:34:51 +01:00
;; refresh
"gr" 'revert-buffer
;; quit
"q" 'quit-window
"ZQ" 'quit-window
"ZZ" 'quit-window)
(evil-collection-inhibit-insert-state 'eww-buffers-mode-map)
2018-02-22 17:36:44 +01:00
(evil-set-initial-state 'eww-buffers-mode 'normal)
(evil-collection-define-key 'normal 'eww-buffers-mode-map
2017-12-13 14:34:51 +01:00
"D" 'eww-buffer-kill
2019-06-06 08:03:54 +02:00
(kbd "RET") 'eww-buffer-select
2019-03-16 18:54:12 +01:00
"]]" 'eww-buffer-show-next
"[[" 'eww-buffer-show-previous
2017-12-13 14:34:51 +01:00
"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-collection-inhibit-insert-state 'eww-bookmark-mode-map)
2018-02-22 17:36:44 +01:00
(evil-set-initial-state 'eww-bookmark-mode 'normal)
(evil-collection-define-key 'normal 'eww-bookmark-mode-map
2017-12-13 14:34:51 +01:00
"D" 'eww-bookmark-kill
"P" 'eww-bookmark-yank
2019-06-06 08:03:54 +02:00
(kbd "RET") 'eww-bookmark-browse
2017-12-13 14:34:51 +01:00
;; refresh
"gr" 'revert-buffer
;; quit
"q" 'quit-window
"ZQ" 'quit-window
"ZZ" 'quit-window)
(evil-collection-define-key 'operator 'eww-bookmark-mode-map
"u" '(menu-item
""
nil
:filter (lambda (&optional _)
(when (memq evil-this-operator
evil-collection-yank-operators)
2018-02-24 09:22:48 +01:00
(setq evil-inhibit-operator t)
#'eww-copy-page-url)))))
2017-12-13 14:34:51 +01:00
(provide 'evil-collection-eww)
;;; evil-collection-eww.el ends here