Tweak how annalist records bindings in evil-collection-define-operator-key

This commit is contained in:
James Nguyen 2021-02-04 02:39:46 -08:00
parent 2c0a09b193
commit 458d6bd0f2
1 changed files with 10 additions and 4 deletions

View File

@ -359,7 +359,8 @@ binding in `annalist' as so."
(while bindings (while bindings
(let* ((key (pop bindings)) (let* ((key (pop bindings))
(key-with-prefix (concat prefix key)) (key-with-prefix (concat prefix key))
(def (def (pop bindings))
(def-with-menu-item
`(menu-item `(menu-item
"" ""
nil nil
@ -369,16 +370,21 @@ binding in `annalist' as so."
(eq evil-this-operator (key-binding ,remap)) (eq evil-this-operator (key-binding ,remap))
(memq evil-this-operator ,operators)) (memq evil-this-operator ,operators))
(setq evil-inhibit-operator t) (setq evil-inhibit-operator t)
',(pop bindings)))))) ',def)))))
(when (or (and whitelist (member key-with-prefix whitelist)) (when (or (and whitelist (member key-with-prefix whitelist))
(not (member key-with-prefix blacklist))) (not (member key-with-prefix blacklist)))
(annalist-record 'evil-collection 'keybindings (annalist-record 'evil-collection 'keybindings
(list map-sym 'operator key-with-prefix def) ;; Record the binding as if it was in 'normal mode
;; instead of 'operator mode as the user would be in
;; normal mode when triggering the operator.
(list map-sym 'normal key-with-prefix def)
:local (or (eq map-sym 'local) :local (or (eq map-sym 'local)
(local-variable-p map-sym))) (local-variable-p map-sym)))
;; Use the original key declared when actually setting the binding. ;; Use the original key declared when actually setting the binding.
(push key filtered-bindings) (push key filtered-bindings)
(push def filtered-bindings)))) ;; Use the definition attached to the menu-item when setting the
;; binding.
(push def-with-menu-item filtered-bindings))))
(setq filtered-bindings (nreverse filtered-bindings)) (setq filtered-bindings (nreverse filtered-bindings))
(evil-collection--define-key 'operator map-sym filtered-bindings))) (evil-collection--define-key 'operator map-sym filtered-bindings)))