Fork me on GitHub
#spacemacs
<
2017-05-11
>
bfay21:05:42

Is there a way to bind a key to a function, but only for a specific mode? I know you can do this for shortcuts using leader keys; I used this to set my cider eval shortcut to , ,

(spacemacs/set-leader-keys-for-major-mode m
      "," 'cider-eval-sexp-at-point)
But now I’m thinking, “hey, I never use semicolon for anything, might as well eval with that.” I can globally define the key like this:
(define-key evil-normal-state-map (kbd ";") 'cider-eval-sexp-at-point)
And that totally works for me, but I was wondering if there’s a way to restrict it by mode.

bfay21:05:23

(PS: something eval’ing clojure with ; feels really good, trust me!)

ag22:05:46

@bfay (evil-define-key 'normal clojurescript-mode-map ";" 'launch-nukes)

bfay13:05:27

ag: Thank you!!!!