diff options
author | Chris Feng <chris.w.feng@gmail.com> | 2018-01-14T15·48+0800 |
---|---|---|
committer | Chris Feng <chris.w.feng@gmail.com> | 2018-01-14T15·48+0800 |
commit | 6b4bfad87bdf8b4cf13cdfb211ae6c8c24c415ff (patch) | |
tree | 5b07095d056e83b80671b23e8693f7f10e6ea603 /exwm-input.el | |
parent | 895633fe61b4934f1328fa3e314a523023d3d1e4 (diff) |
Support key translation in line-mode
* exwm-input.el (exwm-input--translate): New function for translating keys according to `input-decode-map', `local-function-key-map' and `key-translation-map'. (exwm-input--cache-event): Use it.
Diffstat (limited to 'exwm-input.el')
-rw-r--r-- | exwm-input.el | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/exwm-input.el b/exwm-input.el index 38fd751affe1..54d0540e4646 100644 --- a/exwm-input.el +++ b/exwm-input.el @@ -471,10 +471,25 @@ This value should always be overwritten.") (defvar exwm-input--temp-line-mode nil "Non-nil indicates it's in temporary line-mode for char-mode.") +(cl-defun exwm-input--translate (key) + (let (translation) + (dolist (map (list input-decode-map + local-function-key-map + key-translation-map)) + (setq translation (lookup-key map key)) + (if (functionp translation) + (cl-return-from exwm-input--translate (funcall translation nil)) + (when (vectorp translation) + (cl-return-from exwm-input--translate translation))))) + key) + (defun exwm-input--cache-event (event) "Cache EVENT." (setq exwm-input--line-mode-cache (vconcat exwm-input--line-mode-cache (vector event))) + ;; Attempt to translate this key sequence. + (setq exwm-input--line-mode-cache + (exwm-input--translate exwm-input--line-mode-cache)) ;; When the key sequence is complete. (unless (keymapp (key-binding exwm-input--line-mode-cache)) (setq exwm-input--line-mode-cache nil) |