about summary refs log tree commit diff
path: root/exwm-core.el
diff options
context:
space:
mode:
authorChris Feng <chris.w.feng@gmail.com>2018-02-20T13·57+0800
committerChris Feng <chris.w.feng@gmail.com>2018-02-20T13·57+0800
commit7d4c57a6abc6bc724beaffb9d4f91971f9a62426 (patch)
tree98053017cb97fd63827069692fcc1e0a1721917d /exwm-core.el
parent5c5729c0d4832a870a928d6d7cc2f990a7e8f649 (diff)
Add Customize interface for simulation keys
* exwm-input.el (exwm-input-simulation-keys): New user option for
setting simulation keys.
(exwm-input--init): Initialize simulation keys from this variable.

* exwm-input.el (exwm-input--simulation-prefix-keys)
(exwm-input--on-KeyPress-line-mode)
(exwm-input--update-simulation-prefix-keys)
(exwm-input-set-simulation-keys, exwm-input-set-local-simulation-keys)
(exwm-input-send-simulation-key): `exwm-input--simulation-keys' is now
a hash table storing both simulation keys and prefix keys.
(exwm-input--unset-simulation-keys): Clear the hash table.
(exwm-input--exit): Use `exwm-input--unset-simulation-keys'.
* exwm-core.el (exwm--kmacro-map, exwm-mode-menu): Adapt to the
change of `exwm-input--simulation-keys'.

* exwm-config.el (exwm-config-default): Update the example.
Diffstat (limited to 'exwm-core.el')
-rw-r--r--exwm-core.el31
1 files changed, 16 insertions, 15 deletions
diff --git a/exwm-core.el b/exwm-core.el
index 71498c9dc81f..41c3b5772495 100644
--- a/exwm-core.el
+++ b/exwm-core.el
@@ -45,7 +45,7 @@
 (defvar exwm--root nil "Root window.")
 
 (defvar exwm-input--global-prefix-keys)
-(defvar exwm-input--simulation-prefix-keys)
+(defvar exwm-input--simulation-keys)
 (defvar exwm-input-line-mode-passthrough)
 (defvar exwm-input-prefix-keys)
 (declare-function exwm-input--fake-key "exwm-input.el" (event))
@@ -189,7 +189,7 @@ least SECS seconds later."
               (active-minibuffer-window)
               (memq last-input-event exwm-input--global-prefix-keys)
               (memq last-input-event exwm-input-prefix-keys)
-              (memq last-input-event exwm-input--simulation-prefix-keys))
+              (gethash last-input-event exwm-input--simulation-keys))
           (set-transient-map (make-composed-keymap (list exwm-mode-map
                                                          global-map)))
           (push last-input-event unread-command-events))
@@ -229,19 +229,20 @@ least SECS seconds later."
     ;; This is merely a reference.
     ("Send simulation key" :filter
      (lambda (&rest _args)
-       (mapcar (lambda (i)
-                 (let ((keys (cdr i)))
-                   (if (vectorp keys)
-                       (setq keys (append keys))
-                     (unless (sequencep keys)
-                       (setq keys (list keys))))
-                   (vector (key-description keys)
-                           `(lambda ()
-                              (interactive)
-                              (dolist (key ',keys)
-                                (exwm-input--fake-key key)))
-                           :keys (key-description (car i)))))
-               exwm-input--simulation-keys)))
+       (let (result)
+         (maphash
+          (lambda (key value)
+            (when (sequencep key)
+              (setq result (append result
+                                   `([
+                                      ,(key-description value)
+                                      (lambda ()
+                                        (interactive)
+                                        (dolist (i ',value)
+                                          (exwm-input--fake-key i)))
+                                      :keys ,(key-description key)])))))
+          exwm-input--simulation-keys)
+         result)))
 
     ["Define global binding" exwm-input-set-key]