When I'm in the middle of inputting a Key Sequence, how may I get a data structure with the Key Sequence entered thus far from Elisp?
More details: I create Key Translations that are contingent on the Evil (Vim emulation) state. If in insert state, it's the idenity translation:
;; -*- lexical-binding: t -*- (defun make-conditional-key-translation (key-from key-to translate-keys-p) "Make a Key Translation such that if the translate-keys-p function returns true, key-from translates to key-to, else key-from translates to itself. translate-keys-p
takes no args. " (define-key key-translation-map key-from (lambda (prompt) (if (funcall translate-keys-p) key-to key-from)))) (defun my-translate-keys-p ()
"Returns whether conditional key translations should be active. See make-conditional-key-translation function. " (or (evil-motion-state-p) (evil-normal-state-p) (evil-visual-state-p))) (make-conditional-key-translation (kbd "g") (kbd "C-x") 'my-translate-keys-p)
This works well, but one inconvenience is that for bindings like this:
(define-key evil-motion-state-map "sg" 'my-func)
"sg" gets translated into "s C-x". If I have my-translate-keys-p return nil if not starting a Key Sequence, I will get the behavior I seek. I can do this if I can get the Key Sequence as the user has been entered at that time.