blob: 22a3b8f37175354fc49fdfd7dc52322427e45b7a (
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
|
;;; evil-collection-emms.el --- Evil bindings for EMMS -*- 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, emms, 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 EMMS.
;;; Code:
(require 'emms nil t)
(require 'evil-collection)
(declare-function emms-with-inhibit-read-only-t "emms")
(declare-function emms-playlist-mode-correct-previous-yank "emms-playlist-mode")
(defvar emms-browser-mode-map)
(defvar emms-playlist-mode-map)
(defconst evil-collection-emms-maps '(emms-browser-mode-map
emms-playlist-mode-map
emms-metaplaylist-mode-map
emms-stream-mode-map))
(defun evil-collection-emms-playlist-mode-insert-newline-above ()
"Insert a newline above point."
(interactive)
(emms-with-inhibit-read-only-t
(evil-insert-newline-above)))
(defun evil-collection-emms-playlist-mode-insert-newline-below ()
"Insert a newline below point."
(interactive)
(emms-with-inhibit-read-only-t
(evil-insert-newline-below)))
(defun evil-collection-emms-playlist-mode-paste-before ()
"Pastes the latest yanked playlist items before the cursor position.
The return value is the yanked text."
(interactive)
(emms-with-inhibit-read-only-t
(goto-char (point-at-bol))
(yank)
(emms-playlist-mode-correct-previous-yank)
(evil-previous-line)
(evil-beginning-of-line)))
(defun evil-collection-emms-playlist-mode-paste-after ()
"Pastes the latest yanked playlist items behind point.
The return value is the yanked text."
(interactive)
(unless (eobp) (evil-next-line))
(evil-collection-emms-playlist-mode-paste-before))
(defun evil-collection-emms-browser-setup ()
"Set up `evil' bindings for `emms-browser'."
;; TODO: Why doesn't evil-set-initial-state work with emms-browser-mode?
(evil-collection-inhibit-insert-state 'emms-browser-mode-map)
(add-hook 'emms-browser-mode-hook 'evil-normal-state)
(evil-collection-define-key 'normal 'emms-browser-mode-map
;; playback controls
"x" 'emms-pause
"X" 'emms-stop
"r" 'emms-random
"<" 'emms-seek-backward
">" 'emms-seek-forward
(kbd "<return>") 'emms-browser-add-tracks
(kbd "C-<return>") 'emms-browser-add-tracks-and-play
;; volume controls
"+" 'emms-volume-raise
"=" 'emms-volume-raise
"-" 'emms-volume-lower
"u" 'emms-playlist-mode-undo
;; motion
"[" 'emms-browser-prev-non-track
"]" 'emms-browser-next-non-track
(kbd "C-k") 'emms-browser-prev-non-track
(kbd "C-j") 'emms-browser-next-non-track
"gk" 'emms-browser-prev-non-track
"gj" 'emms-browser-next-non-track
(kbd "<tab>") 'emms-browser-toggle-subitems-recursively
(kbd "<backtab>") 'emms-browser-toggle-subitems-recursively
"^" 'emms-browser-move-up-level
(kbd "SPC") 'emms-browser-toggle-subitems
"g1" 'emms-browser-collapse-all
"g2" 'emms-browser-expand-to-level-2
"g3" 'emms-browser-expand-to-level-3
"g4" 'emms-browser-expand-to-level-4
"g0" 'emms-browser-expand-all
"ga" 'emms-browse-by-artist
"gA" 'emms-browse-by-album
"gb" 'emms-browse-by-genre
"gy" 'emms-browse-by-year
"gc" 'emms-browse-by-composer
"gp" 'emms-browse-by-performer
"zm" 'emms-browser-collapse-all
"zr" 'emms-browser-expand-all
"zo" 'emms-browser-expand-one-level
;; TODO find a real replacement for zc
"zc" 'emms-browser-collapse-all
;; TODO find a way to integrate this with evil-collection-evil-search
"/" 'emms-isearch-buffer ; This shows hidden items during search.
"n" 'isearch-repeat-forward
"N" 'isearch-repeat-backward
;; filter
;; "" 'emms-browser-previous-filter ; TODO: What does this do?
;; "" 'emms-browser-next-filter
"s" (lookup-key emms-browser-mode-map (kbd "s"))
"g" (lookup-key emms-browser-mode-map (kbd "W")) ;; TODO: This overrides other "g-" prefixed keys.
"C" 'emms-browser-clear-playlist
"D" 'emms-browser-delete-files
"d" 'emms-browser-view-in-dired
"gd" 'emms-browser-view-in-dired)) ; "d" does the same, keep "gd" for consistency.
(defun evil-collection-emms-setup ()
"Set up `evil' bindings for `emms'."
(with-eval-after-load 'emms-browser
(evil-collection-emms-browser-setup))
(evil-set-initial-state 'emms-playlist-mode 'normal)
(evil-collection-define-key 'normal 'emms-playlist-mode-map
;; playback controls
"x" 'emms-pause
"X" 'emms-stop
"r" 'emms-random
"<" 'emms-seek-backward
">" 'emms-seek-forward
(kbd "C-j") 'emms-next
(kbd "C-k") 'emms-previous
"gj" 'emms-next
"gk" 'emms-previous
(kbd "<return>") 'emms-playlist-mode-play-smart
;; volume controls
"+" 'emms-volume-raise
"=" 'emms-volume-raise
"-" 'emms-volume-lower
"u" 'emms-playlist-mode-undo
;; motion
"gg" 'emms-playlist-mode-first
"G" 'emms-playlist-mode-last
"]" 'emms-playlist-mode-next
"[" 'emms-playlist-mode-previous
"D" 'emms-playlist-mode-kill-track ; emms-browser uses "D"
"C" 'emms-playlist-mode-clear
"O" 'evil-collection-emms-playlist-mode-insert-newline-above
"o" 'evil-collection-emms-playlist-mode-insert-newline-below
"P" 'evil-collection-emms-playlist-mode-paste-before
"p" 'evil-collection-emms-playlist-mode-paste-after
"u" 'emms-playlist-mode-undo
"ze" 'emms-tag-editor-edit
"R" 'emms-tag-editor-rename
"." 'emms-playlist-mode-center-current
"d" 'emms-playlist-mode-goto-dired-at-point
"gd" 'emms-playlist-mode-goto-dired-at-point ; "d" does the same, keep "gd" for consistency.
"zs" 'emms-show
"a" 'emms-playlist-mode-add-contents
"zp" 'emms-playlist-set-playlist-buffer
;; filter
"S" (lookup-key emms-playlist-mode-map (kbd "S"))
"s" (lookup-key emms-playlist-mode-map (kbd "/"))
;; "" 'emms-playlist-limit-to-all ; TODO: Test.
(kbd "M-y") 'emms-playlist-mode-yank-pop)
(evil-collection-define-key 'visual 'emms-playlist-mode-map
;; "d" 'emms-playlist-mode-kill
"D" 'emms-playlist-mode-kill)
(evil-collection-define-key 'normal 'emms-browser-search-mode-map
"q" 'emms-browser-kill-search)
(evil-set-initial-state 'emms-metaplaylist-mode 'normal)
(evil-collection-define-key 'normal 'emms-metaplaylist-mode-map
(kbd "<return>") 'emms-metaplaylist-mode-goto-current
(kbd "<space>") 'emms-metaplaylist-mode-set-active
"gr" 'emms-metaplaylist-mode-update
"C" 'emms-metaplaylist-mode-new-buffer
"." 'emms-metaplaylist-mode-center-current
"D" 'emms-metaplaylist-mode-kill-buffer
"q" 'kill-this-buffer)
(evil-set-initial-state 'emms-stream-mode 'normal)
(evil-collection-define-key 'normal 'emms-stream-mode-map
(kbd "<return>") 'emms-stream-play
"j" 'emms-stream-next-line
"k" 'emms-stream-previous-line
"y" 'emms-stream-yank-bookmark
"d" 'emms-stream-kill-bookmark
"c" 'emms-stream-edit-bookmark
"r" 'emms-stream-edit-bookmark
"i" 'emms-stream-info-bookmark
"s" 'emms-stream-save-bookmarks-file
"x" 'emms-stream-toggle-default-action
"q" 'emms-stream-quit))
(provide 'evil-collection-emms)
;;; evil-collection-emms.el ends here
|