about summary refs log tree commit diff
path: root/configs/shared/emacs/.emacs.d/elpa/evil-collection-20180720.526/evil-collection-elfeed.el
blob: 6da2e89e2efa813302788038b99d08389bf524d2 (plain) (blame)
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
;;; evil-collection-elfeed.el --- Evil bindings for elfeed -*- 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/emacs-evil/evil-collection
;; Version: 0.0.1
;; Package-Requires: ((emacs "25.1"))
;; Keywords: evil, elfeed, 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 elfeed.

;;; Code:
(require 'elfeed nil t)
(require 'evil-collection)

(defvar elfeed-search-mode-map)
(defvar elfeed-show-mode-map)

(defconst evil-collection-elfeed-maps '(elfeed-search-mode-map
                                        elfeed-show-mode-map))

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

  (evil-collection-inhibit-insert-state 'elfeed-search-mode-map)
  (evil-set-initial-state 'elfeed-search-mode 'normal)
  (evil-collection-define-key 'normal 'elfeed-search-mode-map
    ;; open
    (kbd "<return>") 'elfeed-search-show-entry
    (kbd "S-<return>") 'elfeed-search-browse-url
    "go" 'elfeed-search-browse-url

    "y" 'elfeed-search-yank

    (kbd "SPC") 'scroll-up-command
    (kbd "S-SPC") 'scroll-down-command

    ;; filter
    "s" 'elfeed-search-live-filter
    "S" 'elfeed-search-set-filter

    ;; refresh
    "gR" 'elfeed-search-fetch ; TODO: Which update function is more useful?
    "gr" 'elfeed-search-update--force

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

  (evil-collection-define-key '(normal visual) 'elfeed-search-mode-map
    "+" 'elfeed-search-tag-all
    "-" 'elfeed-search-untag-all
    "U" 'elfeed-search-tag-all-unread
    "u" 'elfeed-search-untag-all-unread)

  (evil-collection-inhibit-insert-state 'elfeed-show-mode-map)
  (evil-set-initial-state 'elfeed-show-mode 'normal)
  (evil-collection-define-key 'normal 'elfeed-show-mode-map
    (kbd "S-<return>") 'elfeed-show-visit
    "go" 'elfeed-show-visit

    (kbd "SPC") 'scroll-up-command
    (kbd "S-SPC") 'scroll-down-command

    ;; filter
    "s" 'elfeed-show-new-live-search

    "+" 'elfeed-show-tag
    "-" 'elfeed-show-untag

    "A" 'elfeed-show-add-enclosure-to-playlist
    "P" 'elfeed-show-play-enclosure
    "d" 'elfeed-show-save-enclosure

    "]" 'elfeed-show-next
    "[" 'elfeed-show-prev
    "gj" 'elfeed-show-next
    "gk" 'elfeed-show-prev
    (kbd "C-j") 'elfeed-show-next
    (kbd "C-k") 'elfeed-show-prev

    ;; refresh
    "gr" 'elfeed-show-refresh

    ;; quit
    "q" 'elfeed-kill-buffer
    "ZQ" 'elfeed-kill-buffer
    "ZZ" 'elfeed-kill-buffer)

  (evil-collection-define-key 'operator 'elfeed-show-mode-map
    ;; Like `eww'.
    "u" '(menu-item
          ""
          nil
          :filter (lambda (&optional _)
                    (when (memq evil-this-operator
                                evil-collection-yank-operators)
                      (setq evil-inhibit-operator t)
                      #'elfeed-show-yank)))))

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