How do I get key-chords to work with evil
and alternate input-methods?
I enabled Korean input by M-x set-input-method
and chose korean-hangul
, which I found from following the first few instructions from this Emacs Wiki.
I am using evil-mode
, which I really enjoy, but my custom "smash escape" function does not work. The function allows me to exit insert
state by quickly pressing jk
or kj
. Here are the functions:
;; Set 'kj' to exit insert mode
(define-key evil-insert-state-map "k" #'cofi/maybe-exit-kj)
(evil-define-command cofi/maybe-exit-kj ()
:repeat change
(interactive)
(let ((modified (buffer-modified-p)))
(insert "k")
(let ((evt (read-event (format "Insert %c to exit insert state" ?j)
nil 0.5)))
(cond
((null evt) (message ""))
((and (integerp evt) (char-equal evt ?j))
(delete-char -1)
(set-buffer-modified-p modified)
(push 'escape unread-command-events))
(t (setq unread-command-events (append unread-command-events
(list evt))))))))
(define-key evil-insert-state-map "j" #'cofi/maybe-exit-jk)
(evil-define-command cofi/maybe-exit-jk ()
:repeat change
(interactive)
(let ((modified (buffer-modified-p)))
(insert "j")
(let ((evt (read-event (format "Insert %c to exit insert state" ?k)
nil 0.5)))
(cond
((null evt) (message ""))
((and (integerp evt) (char-equal evt ?k))
(delete-char -1)
(set-buffer-modified-p modified)
(push 'escape unread-command-events))
(t (setq unread-command-events (append unread-command-events
(list evt))))))))
My attempt was to substitute j
and k
with the corresponding Korean characters. Here is my attempt at re-implementing the kj
smash escape, where the character ㅏ
is bound to k
and the character ㅓ
is bound to j
:
(define-key evil-insert-state-map "ㅏ" #'cofi/maybe-exit-ㅏㅓ)
;; Set 'ㅏㅓ' to exit insert mode
(evil-define-command cofi/maybe-exit-ㅏㅓ ()
:repeat change
(interactive)
(let ((modified (buffer-modified-p)))
(insert "ㅏ")
(let ((evt (read-event (format "Insert %c to exit insert state" ?ㅓ)
nil 0.5)))
(cond
((null evt) (message ""))
((and (integerp evt) (char-equal evt ?ㅓ))
(delete-char -1)
(set-buffer-modified-p modified)
(push 'escape unread-command-events))
(t (setq unread-command-events (append unread-command-events
(list evt))))))))
All I did was substitute j
and k
with ㅓ
and ㅏ
, respectively. Unfortunately, it does not work. Any suggestions on how to proceed?