Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

evil-collection: respect evil-overriding-maps #506

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions evil-collection.el
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ See https://github.com/emacs-evil/evil-collection/issues/60 for more details.")
(declare-function org-table-align "org-table.el" nil)

(defgroup evil-collection nil
"A set of keybindings for Evil mode"
"A set of keybindings for Evil mode."
:group 'evil)

(defcustom evil-collection-setup-minibuffer nil
Expand Down Expand Up @@ -422,7 +422,7 @@ means all states for `evil-define-key', return `nil'."
states)
evil-collection-state-denylist)))

(defun evil-collection-define-key (state map-sym &rest bindings)
(cl-defun evil-collection-define-key (state map-sym &rest bindings)
"Wrapper for `evil-define-key*' with additional features.
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
Expand All @@ -431,8 +431,23 @@ to filter keys on the basis of `evil-collection-key-whitelist' and
(declare (indent defun))
(let* ((whitelist (mapcar 'kbd evil-collection-key-whitelist))
(blacklist (mapcar 'kbd evil-collection-key-blacklist))
(overriding (assoc map-sym evil-overriding-maps))
(states-to-bind (evil-collection--filter-states state))
filtered-bindings)
;; We take account of `evil-overriding-maps' first, as it's defined in evil,
;; not evil-collection.
;;
;; `overriding' is non-nil, and cdr of `overriding' is nil, which means evil
;; shouldn't define any keybindings in that keymap.
;;
;; `overriding' is non-nil, and cdr of `overriding' is non-nil, which means
;; evil shouldn't define keybindings in that keymap in such state.
;;
;; `overriding' is nil, no constraints.
(when overriding
(if (null (cdr overriding))
(cl-return-from evil-collection-define-key)
(setq states-to-bind (seq-difference states-to-bind (list (cdr overriding))))))
(when (or states-to-bind (null state))
(while bindings
(let ((key (pop bindings))
Expand Down