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

Attachment: pgpICpZURtCSx.pgp
Description: PGP signature

_______________________________________________
implementations-list mailing list
[email protected]
https://lists.ourproject.org/cgi-bin/mailman/listinfo/implementations-list

Reply via email to