diff options
author | Chris Feng <chris.w.feng@gmail.com> | 2016-06-17T10·45+0800 |
---|---|---|
committer | Chris Feng <chris.w.feng@gmail.com> | 2016-06-17T10·45+0800 |
commit | 4a1b177bceb7e47ea75ddf779bf609d563713ffe (patch) | |
tree | 42cee7ab3ff2d2b119c68df72058fa5af9ef05b1 | |
parent | 38332925d0d5655e98416afaa7869bbaddb360b8 (diff) |
Allow buffer-local simulation keys
* exwm-input.el (exwm-input-set-local-simulation-keys): New function for setting buffer-local simulation keys. (exwm-input--local-simulation-keys): New internal variable. (exwm-input--update-simulation-prefix-keys): Modify either `exwm-mode-map' or the local keymap accordingly.
-rw-r--r-- | exwm-input.el | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/exwm-input.el b/exwm-input.el index 4307a187a65e..e786f0defd5f 100644 --- a/exwm-input.el +++ b/exwm-input.el @@ -453,11 +453,16 @@ It's updated in several occasions, and only used by `exwm-input--set-focus'.") ;; (unless (listp last-input-event) ;not a key event ;; (exwm-input--fake-key last-input-event))) +(defvar exwm-input--local-simulation-keys nil + "Whether simulation keys are local.") + (defun exwm-input--update-simulation-prefix-keys () "Update the list of prefix keys of simulation keys." (setq exwm-input--simulation-prefix-keys nil) (dolist (i exwm-input--simulation-keys) - (define-key exwm-mode-map (car i) #'exwm-input-send-simulation-key) + (if exwm-input--local-simulation-keys + (local-set-key (car i) #'exwm-input-send-simulation-key) + (define-key exwm-mode-map (car i) #'exwm-input-send-simulation-key)) (cl-pushnew (elt (car i) 0) exwm-input--simulation-prefix-keys))) (defun exwm-input-set-simulation-keys (simulation-keys) @@ -469,6 +474,16 @@ SIMULATION-KEYS is an alist of the form (original-key . simulated-key)." (cl-pushnew `(,(vconcat (car i)) . ,(cdr i)) exwm-input--simulation-keys)) (exwm-input--update-simulation-prefix-keys)) +(defun exwm-input-set-local-simulation-keys (simulation-keys) + "Set buffer-local simulation keys. + +Its usage is the same with `exwm-input-set-simulation-keys'." + (make-local-variable 'exwm-input--simulation-keys) + (make-local-variable 'exwm-input--simulation-prefix-keys) + (use-local-map (copy-keymap exwm-mode-map)) + (let ((exwm-input--local-simulation-keys t)) + (exwm-input-set-simulation-keys simulation-keys))) + ;;;###autoload (defun exwm-input-send-simulation-key (times) "Fake a key event according to last input key sequence." |