Difference between define-key and evil-define-key
What is the difference between these two lines? (define-key evil-normal-state-map ",b" 'ido-switch-buffer) (evil-define-key 'normal ",b" 'ido-switch-buffer) I'm not subscribed to the list, so please CC me. Natan -- blog: http://natanyellin.com <http://natanyellin.com/>twitter: @aantn <http://twitter.com/aantn>
On 11 Oct 2011, Natan Yellin wrote:
What is the difference between these two lines?
(define-key evil-normal-state-map ",b" 'ido-switch-buffer) (evil-define-key 'normal ",b" 'ido-switch-buffer)
You use the first correct and second wrong. To cite the docstring (C-h f evil-define-key): ,---- | (evil-define-key STATE KEYMAP KEY DEF &rest BINDINGS) | | Create a STATE binding from KEY to DEF for KEYMAP. | STATE is one of `normal', `insert', `visual', `replace', | `operator', `motion' and `emacs'. The remaining arguments | are like those of `define-key'. For example: | | (evil-define-key 'normal foo-map "a" 'bar) | | This creates a binding from "a" to `bar' in Normal state, | which is active whenever `foo-map' is active. It is possible | to specify multiple bindings at once: | | (evil-define-key 'normal foo-map | "a" 'bar | "b" 'foo) | | See also `evil-declare-key'. `---- You miss the `KEYMAP'. To come back to the original question: `define-key' defines a key in a keymap `evil-define-key' defines a key in `state' whenever `keymap' is active. So the second in a correct form would be along (evil-define-key 'normal 'org-mode-map ",b" 'ido-switch-buffer) The functions are complementary (well you can emulate `evil-define-key' with `define-key' yourself, but you don't want to do that). Maybe you are interested in `evil-leader': https://github.com/cofi/evil-leader Michael
On 11 Oct 2011, Michael Markert wrote:
On 11 Oct 2011, Natan Yellin wrote:
What is the difference between these two lines?
(define-key evil-normal-state-map ",b" 'ido-switch-buffer) (evil-define-key 'normal ",b" 'ido-switch-buffer)
... So the second in a correct form would be along
(evil-define-key 'normal 'org-mode-map ",b" 'ido-switch-buffer)
Well almost. This one is correct (keymap mustn't be a symbol, but the keymap): (evil-define-key 'normal org-mode-map ",b" 'ido-switch-buffer) Sorry. Michael
Thank you, Michael! On Tue, Oct 11, 2011 at 8:52 PM, Michael Markert < [email protected]> wrote:
On 11 Oct 2011, Michael Markert wrote:
On 11 Oct 2011, Natan Yellin wrote:
What is the difference between these two lines?
(define-key evil-normal-state-map ",b" 'ido-switch-buffer) (evil-define-key 'normal ",b" 'ido-switch-buffer)
... So the second in a correct form would be along
(evil-define-key 'normal 'org-mode-map ",b" 'ido-switch-buffer)
Well almost. This one is correct (keymap mustn't be a symbol, but the keymap):
(evil-define-key 'normal org-mode-map ",b" 'ido-switch-buffer)
Sorry.
Michael
participants (2)
-
Michael Markert -
Natan Yellin