Define a chord key in a specific mode

How do you define key-chord key only in a specific mode, for example, I want to bind a cider replica to a specific key only in clojure-modeor cider-mode. I can only find an example that activates a key all over the world.

Thank you for your 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)
+4
source share
1 answer

Defining specific mode 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 have to replace it cider-replwith the specific command you want to link. Note that a quote 'before the command name is required.

Generalization:

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

key-chord -special instructions

, clojure-mode -

(add-hook 'clojure-mode-hook 
          (lambda () (key-chord-define clojure-mode-map "gj" 'cider-jack-in)))

: ,

clojure-mode-map , , , define-key, .

Emacs, , ,

(package-initialize)

- .emacs ( , package-install). , define-key - .

define-key hook, clojure-mode:

(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)
+7

Source: https://habr.com/ru/post/1537839/


All Articles