Most importantly, your first example binds "\C-b" in the CURRENT BUFFER for ALL MODES, while your second example binds "\C-b" for ALL BUFFERS in ONLY THE SPECIFIED MODE (sorry for the caps, don't mean to yell :P).
There are two other minor differences. First, evil-define-key stores keymaps in evil's auxiliary maps. From evil-core.el: ;; ... any Emacs mode may be assigned state bindings of its ;; own by passing the mode's keymap to the function `evil-define-key'. ;; These mode-specific bindings are ultimately stored in so-called ;; auxiliary keymaps, which are sandwiched between the local keymap ;; and the global keymap. This probably means that the different methods bind with different precedence, though I'm not going to delve into the cases where this actually matters. Second, evil-define-key can define keys in maps that haven't been defined yet (it sets up a hook to add them to the map once it is defined). On 9/17/14, Nikolai Weibull <[email protected]> wrote: > Hi! > > What's the preferred way of adding keys to a given mode's map? > > Is > > (define-key evil-motion-state-local-map "\C-b" > 'calendar-scroll-right-three-months) > > or > > (evil-define-key 'motion calendar-mode-map "\C-b" > 'calendar-scroll-right-three-months) > > preferable? > > (From an ease-of-use perspective, the second is better, as it allows > you to easily map more keys, but I'm wondering from a "the right way > to do it" perspective.) > > _______________________________________________ > implementations-list mailing list > [email protected] > https://lists.ourproject.org/cgi-bin/mailman/listinfo/implementations-list > _______________________________________________ implementations-list mailing list [email protected] https://lists.ourproject.org/cgi-bin/mailman/listinfo/implementations-list
