reddit / emacs

General.el: redirecting a Binding to a Map?

hjozwiak · 2022-12-17 22:20
Howdy, ​ Is it possible in general.el to redirect a key to a specific map? For example, when you load evil, and have speechd-el loaded, C-e gets rebound to evil-scroll-line-down. I've been reading the general.el docs and I haven't found what I am looking for, namely putting C-e back onto speechd-speak-mode map.
BypassingOverride · 2022-12-18 03:21
Hi there. You can bind keys to specific modes in general.el using :keymaps inside of a general-define-key. You can also use it under a definer created with general-create-definer if you wanted to only apply it to specific evil modes. There are some :keymaps uses in the [General Examples section of the github readme](https://github.com/noctuid/general.el#general-examples).
hjozwiak · 2022-12-19 16:16
I discovered my mistake; I had mistakenly quoted the speechd-speak-mode-map when I was doing the bindings. This made it think it was a command; removing the quote fixed the problem. For context: \`\`\` use-package evil :ensure t :custom (evil-want-integration t) (evil-want-c-i-jump nil) (evil-want-keybind nil) (evil-undo-system 'undo-tree) :preface (defun sonarmacs--evil-state-change-notify () (when (and evil-next-state evil-previous-state (not (eq evil-previous-state evil-next-state))) (speechd-say-text (format "Changing state from %s to %s." evil-previous-state evil-next-state) :priority 'important))) :hook ((evil-insert-state-exit evil-normal-state-exit evil-motion-state-exit evil-operator-state-exit evil-replace-state-exit evil-visual-state-exit evil-emacs-state-exit) . sonarmacs--evil-state-change-notify) :general (:states '(normal visual insert operator replace motion) speechd-speak-prefix speechd-speak-mode-map) (speechd-speak-mode-map "e" 'evil-scroll-line-down) :init (evil-mode)\`\`\`