Defining mode-specific key bindings
Here is an example of how to do this:
(define-key clojure-mode-map (kbd "C-c r") 'cider-repl)
... where of course you would have to replace cider-repl
with the specific command you want to bind. Note that the quote '
before the command name is required.
To generalize:
(define-key <mode-map> <key-binding> '<command>)
key-chord
-specific instructions
You need to change the line where you're trying to set up the clojure-mode
-specific key binding to
(add-hook 'clojure-mode-hook
(lambda () (key-chord-define clojure-mode-map "gj" 'cider-jack-in)))
Appendix: Making sure mode-maps are defined before modifying them
In order for modifications to clojure-mode-map
to work properly, you have to make sure it is defined when you call define-key
as described above.
If you are using the Emacs Package Manager, you are likely to have this line
(package-initialize)
somewhere in your .emacs
file (which takes care of loading packages installed via package-install
). Make sure you call define-key
somewhere below this line.
Alternatively you can add the call to define-key
to the hook that is run when clojure-mode
is enabled:
(defun clojure-set-up-key-bindings ()
(define-key clojure-mode-map (kbd "C-c r") 'cider-repl)
;; If necessary, add more calls to `define-key' here ...
)
(add-hook 'clojure-mode-hook 'clojure-set-up-key-bindings)