emacs - Define key-chord key with specific mode -


how define key-chord key in specific mode, example want bind cider repl specific key in clojure-mode or cider-mode. can find example activates key globally.

thanks help.

edit:

(require 'evil) (require 'key-chord) (evil-mode 1)  (key-chord-mode 1) (key-chord-define evil-insert-state-map "jk" 'evil-normal-state) (key-chord-define-global "gt" 'other-window) (key-chord-define clojure-mode-hook "gj" 'cider-jack-in) ;; error : wrong type argument: keymapp, (rainbow-delimiters-mode)   (provide 'init-evil) 

defining mode-specific key bindings

here example of how this:

(define-key clojure-mode-map (kbd "c-c r") 'cider-repl) 

... of course have replace cider-repl specific command want bind. note quote ' before command name required.

to generalize:

(define-key <mode-map> <key-binding> '<command>) 

key-chord-specific instructions

you need change line you're trying set 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 defined before modifying them

in order modifications clojure-mode-map work properly, have make sure defined when call define-key described above.

if using emacs package manager, have line

(package-initialize) 

somewhere in .emacs file (which takes care of loading packages installed via package-install). make sure call define-key somewhere below line.

alternatively can add call define-key hook run when clojure-mode enabled:

(defun clojure-set-up-key-bindings ()   (define-key clojure-mode-map (kbd "c-c r") 'cider-repl)   ;; if necessary, add more calls `define-key' here ...   )  (add-hook 'clojure-mode-hook 'clojure-set-up-key-bindings) 

Comments

Popular posts from this blog

How to access named pipes using JavaScript in Firefox add-on? -

multithreading - OPAL (Open Phone Abstraction Library) Transport not terminated when reattaching thread? -

node.js - req param returns an empty array -