Fork me on GitHub

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.


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


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


ag: Thank you!!!!