2017-11-07 11:04:12 +01:00
|
|
|
;;; evil-collection.el --- A set of keybindings for Evil mode -*- lexical-binding: t -*-
|
2017-11-05 17:05:46 +01:00
|
|
|
|
|
|
|
;; Copyright (C) 2017 James Nguyen
|
|
|
|
|
2017-11-07 11:04:12 +01:00
|
|
|
;; Author: James Nguyen <james@jojojames.com>
|
|
|
|
;; Pierre Neidhardt <ambrevar@gmail.com>
|
|
|
|
;; Maintainer: James Nguyen <james@jojojames.com>
|
|
|
|
;; Pierre Neidhardt <ambrevar@gmail.com>
|
2018-03-02 02:22:38 +01:00
|
|
|
;; URL: https://github.com/emacs-evil/evil-collection
|
2017-11-05 17:05:46 +01:00
|
|
|
;; Version: 0.0.1
|
2017-12-18 04:26:31 +01:00
|
|
|
;; Package-Requires: ((emacs "25.1") (cl-lib "0.5") (evil "1.2.13"))
|
2017-11-07 11:04:12 +01:00
|
|
|
;; Keywords: evil, tools
|
2017-11-05 17:05:46 +01:00
|
|
|
|
|
|
|
;; This program 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 of the License, or
|
|
|
|
;; (at your option) any later version.
|
|
|
|
|
|
|
|
;; This program 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.
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
|
|
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
;;; Commentary:
|
2017-11-06 15:12:40 +01:00
|
|
|
;; A set of keybindings for Evil mode.
|
|
|
|
;;
|
2017-12-07 12:20:36 +01:00
|
|
|
;; If you want to use Evil in the minibuffer, you'll have to enable it by
|
|
|
|
;; setting `evil-collection-setup-minibuffer' to t before loading this package.
|
2017-11-06 15:12:40 +01:00
|
|
|
;; This is so because many users find it confusing.
|
2018-06-11 08:18:54 +02:00
|
|
|
;; Some minibuffer-related packages such as Helm rely on this option.
|
2017-11-05 17:05:46 +01:00
|
|
|
|
|
|
|
;;; Code:
|
2018-06-08 19:19:45 +02:00
|
|
|
(eval-when-compile (require 'subr-x))
|
2017-12-18 04:26:31 +01:00
|
|
|
(require 'cl-lib)
|
2017-12-29 05:31:45 +01:00
|
|
|
(require 'evil)
|
2018-01-06 20:25:33 +01:00
|
|
|
|
2018-01-10 03:58:46 +01:00
|
|
|
(defvar evil-want-integration)
|
2018-01-06 20:25:33 +01:00
|
|
|
(if (featurep 'evil-integration)
|
2018-01-06 20:58:09 +01:00
|
|
|
(if evil-want-integration
|
2018-01-07 20:04:27 +01:00
|
|
|
(display-warning
|
|
|
|
'(evil-collection)
|
2018-01-15 10:52:53 +01:00
|
|
|
"Make sure to set `evil-want-integration' to nil before loading evil \
|
2018-01-07 20:04:27 +01:00
|
|
|
or evil-collection.")
|
|
|
|
(display-warning
|
|
|
|
'(evil-collection)
|
|
|
|
"`evil-want-integration' was set to nil but not before loading evil."))
|
2018-01-06 20:25:33 +01:00
|
|
|
(require 'evil-collection-integration))
|
2017-12-29 05:31:45 +01:00
|
|
|
|
2018-06-08 19:19:45 +02:00
|
|
|
(declare-function org-table-align "org-table.el" nil)
|
|
|
|
|
2017-12-06 17:06:27 +01:00
|
|
|
(defgroup evil-collection nil
|
|
|
|
"A set of keybindings for Evil mode"
|
|
|
|
:group 'evil)
|
|
|
|
|
2017-12-07 12:20:36 +01:00
|
|
|
(defcustom evil-collection-setup-minibuffer nil
|
2017-12-07 19:55:13 +01:00
|
|
|
"Whether to setup Evil bindings in the minibuffer."
|
2017-12-07 12:20:36 +01:00
|
|
|
:type 'boolean
|
|
|
|
:group 'evil-collection)
|
|
|
|
|
2017-12-06 17:06:27 +01:00
|
|
|
(defcustom evil-collection-mode-list
|
2018-02-19 04:36:28 +01:00
|
|
|
`(ace-jump-mode
|
|
|
|
ag
|
2017-11-27 08:47:23 +01:00
|
|
|
alchemist
|
2017-11-12 02:08:06 +01:00
|
|
|
anaconda-mode
|
2017-11-08 03:34:48 +01:00
|
|
|
arc-mode
|
2018-02-19 04:50:15 +01:00
|
|
|
avy
|
2017-11-06 15:12:40 +01:00
|
|
|
bookmark
|
2018-01-28 00:47:44 +01:00
|
|
|
(buff-menu "buff-menu")
|
2018-02-23 17:51:52 +01:00
|
|
|
calc
|
2017-11-06 15:12:40 +01:00
|
|
|
calendar
|
|
|
|
cider
|
2018-01-20 21:47:52 +01:00
|
|
|
cmake-mode
|
2017-11-12 20:16:09 +01:00
|
|
|
comint
|
2017-11-11 22:58:26 +01:00
|
|
|
company
|
2017-11-06 15:12:40 +01:00
|
|
|
compile
|
|
|
|
custom
|
2017-11-12 01:39:42 +01:00
|
|
|
cus-theme
|
2018-03-18 05:28:43 +01:00
|
|
|
daemons
|
2017-11-06 17:51:24 +01:00
|
|
|
debbugs
|
2017-11-07 11:33:23 +01:00
|
|
|
debug
|
2017-11-06 15:12:40 +01:00
|
|
|
diff-mode
|
|
|
|
dired
|
2017-11-07 07:17:14 +01:00
|
|
|
doc-view
|
2017-11-06 15:12:40 +01:00
|
|
|
edebug
|
2018-06-01 19:31:33 +02:00
|
|
|
ediff
|
2018-04-22 23:42:46 +02:00
|
|
|
eldoc
|
2017-11-06 17:52:14 +01:00
|
|
|
elfeed
|
2017-11-14 19:06:39 +01:00
|
|
|
elisp-mode
|
2017-11-09 05:44:06 +01:00
|
|
|
elisp-refs
|
2017-11-06 17:52:22 +01:00
|
|
|
emms
|
2018-02-01 16:54:26 +01:00
|
|
|
epa
|
2018-03-31 04:11:13 +02:00
|
|
|
ert
|
2017-11-06 15:12:40 +01:00
|
|
|
eshell
|
2017-11-29 04:14:43 +01:00
|
|
|
eval-sexp-fu
|
2018-01-13 20:11:20 +01:00
|
|
|
etags-select
|
2017-12-13 14:34:51 +01:00
|
|
|
eww
|
2017-11-06 15:12:40 +01:00
|
|
|
flycheck
|
2018-01-28 21:13:55 +01:00
|
|
|
free-keys
|
2017-11-28 08:28:47 +01:00
|
|
|
geiser
|
2017-11-06 15:12:40 +01:00
|
|
|
ggtags
|
2018-04-21 20:27:57 +02:00
|
|
|
git-timemachine
|
2018-01-19 23:42:01 +01:00
|
|
|
go-mode
|
2017-11-06 15:12:40 +01:00
|
|
|
help
|
2018-04-03 10:41:22 +02:00
|
|
|
guix
|
2017-11-06 17:52:31 +01:00
|
|
|
helm
|
2017-11-06 15:12:40 +01:00
|
|
|
ibuffer
|
|
|
|
image
|
2017-11-06 17:52:38 +01:00
|
|
|
image+
|
2017-12-24 19:40:26 +01:00
|
|
|
indium
|
2017-11-06 15:12:40 +01:00
|
|
|
info
|
|
|
|
ivy
|
2018-02-19 04:28:27 +01:00
|
|
|
js2-mode
|
2018-01-23 07:15:41 +01:00
|
|
|
log-view
|
2018-04-21 20:10:23 +02:00
|
|
|
lsp-ui-imenu
|
2018-01-06 18:48:43 +01:00
|
|
|
lua-mode
|
2017-12-24 19:30:45 +01:00
|
|
|
kotlin-mode
|
2017-11-06 15:12:40 +01:00
|
|
|
macrostep
|
|
|
|
man
|
2018-03-31 04:11:15 +02:00
|
|
|
magit
|
2017-12-07 12:20:36 +01:00
|
|
|
,@(when evil-collection-setup-minibuffer '(minibuffer))
|
2018-01-31 14:49:19 +01:00
|
|
|
neotree
|
2017-12-22 07:45:39 +01:00
|
|
|
notmuch
|
2018-01-14 20:30:26 +01:00
|
|
|
nov
|
2017-11-10 12:38:08 +01:00
|
|
|
;; occur is in replace.el which was built-in before Emacs 26.
|
|
|
|
(occur ,(if (<= emacs-major-version 25) "replace" 'replace))
|
2017-11-06 15:12:40 +01:00
|
|
|
outline
|
|
|
|
p4
|
|
|
|
(package-menu package)
|
2018-01-20 09:58:59 +01:00
|
|
|
paren
|
2017-11-06 15:12:40 +01:00
|
|
|
pass
|
2017-11-06 17:53:22 +01:00
|
|
|
(pdf pdf-view)
|
2018-01-20 09:37:48 +01:00
|
|
|
popup
|
2017-11-06 15:12:40 +01:00
|
|
|
proced
|
|
|
|
prodigy
|
|
|
|
profiler
|
2017-12-13 04:31:20 +01:00
|
|
|
python
|
2018-01-19 23:41:42 +01:00
|
|
|
quickrun
|
2017-12-24 20:09:25 +01:00
|
|
|
racer
|
2018-01-12 04:26:08 +01:00
|
|
|
realgud
|
2018-01-26 18:38:26 +01:00
|
|
|
reftex
|
2017-12-24 19:51:55 +01:00
|
|
|
rjsx-mode
|
2017-12-13 06:45:23 +01:00
|
|
|
robe
|
2017-12-13 04:45:45 +01:00
|
|
|
ruby-mode
|
2017-11-28 09:04:18 +01:00
|
|
|
rtags
|
2018-01-30 02:45:42 +01:00
|
|
|
simple
|
2017-11-06 15:12:40 +01:00
|
|
|
slime
|
|
|
|
(term term ansi-term multi-term)
|
2017-11-11 23:51:25 +01:00
|
|
|
tide
|
2017-11-06 17:53:33 +01:00
|
|
|
transmission
|
2017-12-24 19:51:45 +01:00
|
|
|
typescript-mode
|
2018-01-23 07:15:32 +01:00
|
|
|
vc-annotate
|
2018-02-15 13:08:41 +01:00
|
|
|
vdiff
|
2018-03-03 16:52:16 +01:00
|
|
|
view
|
2017-11-06 15:12:40 +01:00
|
|
|
vlf
|
2018-01-27 22:19:17 +01:00
|
|
|
which-key
|
2018-03-31 04:11:19 +02:00
|
|
|
wdired
|
2018-03-31 04:11:17 +02:00
|
|
|
wgrep
|
2017-11-06 15:12:40 +01:00
|
|
|
woman
|
2017-11-06 17:53:44 +01:00
|
|
|
xref
|
|
|
|
(ztree ztree-diff))
|
2017-11-06 15:12:40 +01:00
|
|
|
"The list of modes which will be evilified by `evil-collection-init'.
|
|
|
|
Elements are either target mode symbols or lists which `car' is the
|
|
|
|
mode symbol and `cdr' the packages to register.
|
|
|
|
|
|
|
|
By default, `minibuffer' is not included because many users find
|
2017-12-07 12:20:36 +01:00
|
|
|
this confusing. It will be included if
|
|
|
|
`evil-collection-setup-minibuffer' is set to t."
|
2017-12-06 17:06:27 +01:00
|
|
|
:type '(repeat (choice symbol sexp))
|
|
|
|
:group 'evil-collection)
|
2017-11-05 17:05:46 +01:00
|
|
|
|
2018-06-05 20:10:15 +02:00
|
|
|
(defcustom evil-collection-key-whitelist '()
|
2018-06-06 03:12:06 +02:00
|
|
|
"List of keys that may be used by Evil Collection.
|
2018-06-05 20:10:15 +02:00
|
|
|
This is a list of strings that are suitable for input to
|
2018-06-06 03:12:06 +02:00
|
|
|
`kbd'. If there are no keys in the list, the whitelist will be ignored."
|
2018-06-05 20:10:15 +02:00
|
|
|
:type '(repeat string)
|
|
|
|
:group 'evil-collection)
|
|
|
|
|
|
|
|
(defcustom evil-collection-key-blacklist '()
|
2018-06-06 03:12:06 +02:00
|
|
|
"List of keys that may not be used by Evil Collection.
|
2018-06-05 20:10:15 +02:00
|
|
|
This is a list of strings that are suitable for input to `kbd'."
|
|
|
|
:type '(repeat string)
|
|
|
|
:group 'evil-collection)
|
|
|
|
|
2018-06-06 03:56:18 +02:00
|
|
|
(defvar evil-collection--bindings-record (make-hash-table :test 'eq)
|
2018-06-06 03:12:06 +02:00
|
|
|
"Record of bindings currently made by Evil Collection. This is
|
2018-06-06 13:32:19 +02:00
|
|
|
a hash-table with the package symbol as a key. The associated
|
2018-06-06 20:34:45 +02:00
|
|
|
values are the package's bindings which are stored as a list of
|
|
|
|
the form ((STATE KEY BINDING)).")
|
2018-06-05 20:10:15 +02:00
|
|
|
|
2017-12-18 04:26:31 +01:00
|
|
|
(defvar evil-collection-setup-hook nil
|
|
|
|
"Hook run by `evil-collection-init' for each mode that is evilified.
|
|
|
|
This hook runs after all setup (including keybindings) for a mode has already
|
|
|
|
taken place. The arguments passed to functions for this hook are the name of the
|
|
|
|
mode and a list of keymap names (i.e. symbols, not actual keymaps) customized by
|
|
|
|
Evil Collection for that mode. More arguments may be added in the future, so
|
|
|
|
functions added to this hook should include a \"&rest _rest\" for forward
|
|
|
|
compatibility.")
|
|
|
|
|
2018-06-06 03:12:06 +02:00
|
|
|
(defvar evil-collection-describe-buffer "*evil-collection*"
|
|
|
|
"Name for Evil Collection buffer used to describe bindings.")
|
|
|
|
|
2018-06-06 13:32:19 +02:00
|
|
|
(defun evil-collection-define-key (state map-sym &rest bindings)
|
2018-06-05 20:10:15 +02:00
|
|
|
"Wrapper for `evil-define-key*' with additional features.
|
2018-06-06 20:34:45 +02:00
|
|
|
Unlike `evil-define-key*' MAP-SYM should be a quoted keymap other
|
|
|
|
than the unquoted keymap required for `evil-define-key*'. This
|
|
|
|
function adds the ability to filter keys on the basis of
|
|
|
|
`evil-collection-key-whitelist' and
|
|
|
|
`evil-collection-key-blacklist'. It also stores bindings in
|
2018-06-06 03:56:18 +02:00
|
|
|
`evil-collection--bindings-record'."
|
2018-06-05 20:10:15 +02:00
|
|
|
(declare (indent defun))
|
|
|
|
(let* ((whitelist (mapcar 'kbd evil-collection-key-whitelist))
|
|
|
|
(blacklist (mapcar 'kbd evil-collection-key-blacklist))
|
2018-06-06 20:34:45 +02:00
|
|
|
(record (gethash map-sym evil-collection--bindings-record))
|
2018-06-06 13:32:19 +02:00
|
|
|
filtered-bindings)
|
2018-06-05 20:10:15 +02:00
|
|
|
(while bindings
|
|
|
|
(let ((key (pop bindings))
|
|
|
|
(def (pop bindings)))
|
|
|
|
(when (or (and whitelist (member key whitelist))
|
|
|
|
(not (member key blacklist)))
|
2018-06-06 20:34:45 +02:00
|
|
|
(if (consp state)
|
|
|
|
(dolist (st state)
|
|
|
|
(push (list (if st st 'all) (key-description key) def)
|
|
|
|
record))
|
|
|
|
(push (list (if state state 'all) (key-description key) def)
|
|
|
|
record))
|
2018-06-06 13:32:19 +02:00
|
|
|
(push key filtered-bindings)
|
|
|
|
(push def filtered-bindings))))
|
2018-06-06 20:34:45 +02:00
|
|
|
(puthash map-sym record evil-collection--bindings-record)
|
2018-06-06 13:32:19 +02:00
|
|
|
(setq filtered-bindings (nreverse filtered-bindings))
|
|
|
|
(cond ((and (boundp map-sym) (keymapp (symbol-value map-sym)))
|
|
|
|
(apply #'evil-define-key*
|
|
|
|
state (symbol-value map-sym) filtered-bindings))
|
|
|
|
((boundp map-sym)
|
|
|
|
(user-error "evil-collection: %s is not a keymap" map-sym))
|
|
|
|
(t
|
|
|
|
(let* ((fname (format "evil-collection-define-key-in-%s" map-sym))
|
|
|
|
(fun (make-symbol fname)))
|
|
|
|
(fset fun `(lambda (&rest args)
|
|
|
|
(when (and (boundp ',map-sym) (keymapp ,map-sym))
|
|
|
|
(remove-hook 'after-load-functions #',fun)
|
|
|
|
(apply #'evil-define-key*
|
|
|
|
',state ,map-sym ',filtered-bindings))))
|
2018-06-06 20:34:45 +02:00
|
|
|
(add-hook 'after-load-functions fun t))))))
|
|
|
|
|
|
|
|
(defun evil-collection--binding-lessp (a b)
|
|
|
|
"Comparison function used to sort bindings of the form (state key def)."
|
|
|
|
(let ((a-state (symbol-name (nth 0 a)))
|
|
|
|
(b-state (symbol-name (nth 0 b)))
|
|
|
|
(a-key (nth 1 a))
|
|
|
|
(b-key (nth 1 b)))
|
|
|
|
(if (not (string= a-state b-state))
|
|
|
|
(string-lessp a-state b-state)
|
|
|
|
(string-lessp a-key b-key))))
|
2018-06-05 20:10:15 +02:00
|
|
|
|
2018-06-05 20:14:16 +02:00
|
|
|
(defun evil-collection-describe-all-bindings ()
|
2018-06-06 03:12:06 +02:00
|
|
|
"Print bindings made by Evil Collection to separate buffer."
|
2018-06-05 20:14:16 +02:00
|
|
|
(interactive)
|
2018-06-06 03:12:06 +02:00
|
|
|
(let ((buf (get-buffer-create evil-collection-describe-buffer)))
|
2018-06-05 20:14:16 +02:00
|
|
|
(switch-to-buffer-other-window buf)
|
|
|
|
(with-current-buffer buf
|
|
|
|
(erase-buffer)
|
|
|
|
(org-mode)
|
2018-06-06 20:34:45 +02:00
|
|
|
(dolist (keymap
|
|
|
|
(sort (hash-table-keys evil-collection--bindings-record)
|
|
|
|
(lambda (a b)
|
|
|
|
(string-lessp (symbol-name a)
|
|
|
|
(symbol-name b)))))
|
|
|
|
(insert "\n\n* " (symbol-name keymap) "\n")
|
|
|
|
(insert "
|
|
|
|
| State | Key | Definition |
|
|
|
|
|-------|-----|------------|
|
2018-06-05 20:14:16 +02:00
|
|
|
")
|
2018-06-06 20:34:45 +02:00
|
|
|
(cl-loop
|
|
|
|
for (state key def) in
|
|
|
|
(sort (gethash keymap evil-collection--bindings-record)
|
|
|
|
#'evil-collection--binding-lessp)
|
|
|
|
do
|
|
|
|
(when (and def (not (eq def 'ignore)))
|
|
|
|
(insert (format "| %s | %s | %S |\n"
|
|
|
|
state
|
|
|
|
(replace-regexp-in-string "|" "¦" key)
|
|
|
|
def))))
|
|
|
|
(org-table-align))
|
|
|
|
(goto-char (point-min)))))
|
2018-06-05 20:14:16 +02:00
|
|
|
|
2017-12-18 04:26:31 +01:00
|
|
|
(defun evil-collection--translate-key (state keymap-symbol
|
|
|
|
translations
|
|
|
|
destructive)
|
|
|
|
"Helper function for `evil-collection-translate-key'.
|
|
|
|
In the keymap corresponding to STATE and KEYMAP-SYMBOL, make the key
|
|
|
|
TRANSLATIONS. When DESTRUCTIVE is non-nil, make the TRANSLATIONS destructively
|
|
|
|
without creating/referencing a backup keymap."
|
|
|
|
(let* ((backup-keymap-symbol (intern (format "evil-collection-%s%s-backup-map"
|
|
|
|
keymap-symbol
|
|
|
|
(if state
|
|
|
|
(format "-%s-state" state)
|
|
|
|
""))))
|
|
|
|
(keymap (symbol-value keymap-symbol))
|
|
|
|
(lookup-keymap (if (and (not destructive)
|
|
|
|
(boundp backup-keymap-symbol))
|
|
|
|
(symbol-value backup-keymap-symbol)
|
|
|
|
(copy-keymap
|
|
|
|
(if state
|
|
|
|
(evil-get-auxiliary-keymap keymap state t t)
|
|
|
|
keymap))))
|
|
|
|
(maps (cl-loop for (key replacement) on translations by 'cddr
|
|
|
|
;; :destructive can be in TRANSLATIONS
|
|
|
|
unless (keywordp key)
|
|
|
|
collect key
|
|
|
|
and collect (when replacement
|
|
|
|
(lookup-key lookup-keymap replacement)))))
|
|
|
|
(unless (or destructive
|
|
|
|
(boundp backup-keymap-symbol))
|
|
|
|
(set backup-keymap-symbol lookup-keymap))
|
|
|
|
(apply #'evil-define-key* state keymap maps)))
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(cl-defun evil-collection-translate-key (states keymaps
|
|
|
|
&rest translations
|
|
|
|
&key destructive
|
|
|
|
&allow-other-keys)
|
|
|
|
"Translate keys in the keymap(s) corresponding to STATES and KEYMAPS.
|
|
|
|
STATES should be the name of an evil state, a list of states, or nil. KEYMAPS
|
|
|
|
should be a symbol corresponding to the keymap to make the translations in or a
|
|
|
|
list of keymap symbols. Like `evil-define-key', when a keymap does not exist,
|
|
|
|
the keybindings will be deferred until the keymap is defined, so
|
|
|
|
`with-eval-after-load' is not neccessary. TRANSLATIONS corresponds to a list of
|
|
|
|
key replacement pairs. For example, specifying \"a\" \"b\" will bind \"a\" to
|
|
|
|
\"b\"'s definition in the keymap. Specifying nil as a replacement will unbind a
|
|
|
|
key. If DESTRUCTIVE is nil, a backup of the keymap will be stored on the initial
|
|
|
|
invocation, and future invocations will always look up keys in the backup
|
|
|
|
keymap. When no TRANSLATIONS are given, this function will only create the
|
|
|
|
backup keymap without making any translations. On the other hand, if DESTRUCTIVE
|
|
|
|
is non-nil, the keymap will be destructively altered without creating a backup.
|
|
|
|
For example, calling this function multiple times with \"a\" \"b\" \"b\" \"a\"
|
|
|
|
would continue to swap and unswap the definitions of these keys. This means that
|
|
|
|
when DESTRUCTIVE is non-nil, all related swaps/cycles should be done in the same
|
|
|
|
invocation."
|
|
|
|
(declare (indent defun))
|
|
|
|
(unless (listp keymaps)
|
|
|
|
(setq keymaps (list keymaps)))
|
|
|
|
(unless (and (listp states)
|
|
|
|
(not (null states)))
|
|
|
|
(setq states (list states)))
|
|
|
|
(dolist (keymap-symbol keymaps)
|
|
|
|
(dolist (state states)
|
|
|
|
(evil-delay `(and (boundp ',keymap-symbol)
|
|
|
|
(keymapp ,keymap-symbol))
|
|
|
|
`(evil-collection--translate-key ',state ',keymap-symbol
|
|
|
|
',translations ,destructive)
|
|
|
|
'after-load-functions t nil
|
|
|
|
(symbol-name (cl-gensym (format "evil-collection-translate-key-in-%s"
|
|
|
|
keymap-symbol)))))))
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defmacro evil-collection-swap-key (states keymaps &rest args)
|
|
|
|
"Wrapper around `evil-collection-translate-key' for swapping keys.
|
|
|
|
STATES, KEYMAPS, and ARGS are passed to `evil-collection-translate-key'. ARGS
|
|
|
|
should consist of key swaps (e.g. \"a\" \"b\" is equivalent to \"a\" \"b\" \"b\"
|
|
|
|
\"a\" with `evil-collection-translate-key') and optionally keyword arguments for
|
|
|
|
`evil-collection-translate-key'."
|
|
|
|
(declare (indent defun))
|
|
|
|
(setq args (cl-loop for (key replacement) on args by 'cddr
|
|
|
|
collect key and collect replacement
|
|
|
|
and unless (keywordp key)
|
|
|
|
collect replacement and collect key))
|
|
|
|
`(evil-collection-translate-key ,states ,keymaps ,@args))
|
|
|
|
|
2017-11-14 17:54:02 +01:00
|
|
|
;;;###autoload
|
2018-04-14 23:17:40 +02:00
|
|
|
(defun evil-collection-init (&optional modes)
|
2017-11-06 15:12:40 +01:00
|
|
|
"Register the Evil bindings for all modes in `evil-collection-mode-list'.
|
2017-11-05 17:05:46 +01:00
|
|
|
|
2017-11-06 15:12:40 +01:00
|
|
|
Alternatively, you may register select bindings manually, for
|
|
|
|
instance:
|
|
|
|
|
|
|
|
(with-eval-after-load 'calendar
|
2017-12-07 02:41:09 +01:00
|
|
|
(require 'evil-collection-calendar)
|
2018-04-14 23:17:40 +02:00
|
|
|
(evil-collection-calendar-setup))
|
|
|
|
|
|
|
|
If MODES is specified (as either one mode or a list of modes), use those modes
|
|
|
|
instead of the modes in `evil-collection-mode-list'."
|
2017-11-05 17:05:46 +01:00
|
|
|
(interactive)
|
2018-04-14 23:17:40 +02:00
|
|
|
(if modes
|
|
|
|
(or (listp modes) (setq modes (list modes)))
|
|
|
|
(setq modes evil-collection-mode-list))
|
|
|
|
(dolist (mode modes)
|
2017-11-06 15:12:40 +01:00
|
|
|
(let ((m mode)
|
|
|
|
(reqs (list mode)))
|
|
|
|
(when (listp mode)
|
|
|
|
(setq m (car mode)
|
|
|
|
reqs (cdr mode)))
|
|
|
|
(dolist (req reqs)
|
|
|
|
(with-eval-after-load req
|
2017-12-07 02:41:09 +01:00
|
|
|
(require (intern (concat "evil-collection-" (symbol-name m))))
|
2017-12-18 04:26:31 +01:00
|
|
|
(funcall (intern (concat "evil-collection-" (symbol-name m)
|
|
|
|
"-setup")))
|
|
|
|
(let ((mode-keymaps
|
|
|
|
(ignore-errors
|
|
|
|
(symbol-value
|
|
|
|
(intern (format "evil-collection-%s-maps" m))))))
|
|
|
|
(run-hook-with-args 'evil-collection-setup-hook
|
|
|
|
m mode-keymaps)))))))
|
2017-11-05 17:05:46 +01:00
|
|
|
|
2018-02-15 13:08:41 +01:00
|
|
|
(defvar evil-collection-delete-operators '(evil-delete
|
|
|
|
evil-cp-delete
|
2018-02-19 10:36:26 +01:00
|
|
|
evil-sp-delete
|
2018-02-15 13:08:41 +01:00
|
|
|
lispyville-delete)
|
|
|
|
"List of delete operators.")
|
|
|
|
|
2018-02-23 18:31:31 +01:00
|
|
|
(defvar evil-collection-yank-operators '(evil-yank
|
|
|
|
evil-cp-yank
|
|
|
|
evil-sp-yank
|
|
|
|
lispyville-yank)
|
|
|
|
"List of yank operators.")
|
|
|
|
|
2017-11-05 17:05:46 +01:00
|
|
|
(provide 'evil-collection)
|
|
|
|
;;; evil-collection.el ends here
|