about summary refs log tree commit diff
path: root/exwm-input.el
diff options
context:
space:
mode:
authorChris Feng <chris.w.feng@gmail.com>2019-11-03T00·00+0000
committerChris Feng <chris.w.feng@gmail.com>2019-11-03T00·00+0000
commit3420cd24d107bf9a0396089bb00396e6ab35447e (patch)
tree53fc5a52c7f9f79192451761f1f7286f1dbc8186 /exwm-input.el
parent1772b984522c800b1ecd02a5f7fd2b44ce15f3de (diff)
Add support for accessing keymaps in char-mode
* exwm-input.el (exwm-input-invoke-factory): New macro for generating
new commands that invoke corresponding prefix keys.
Diffstat (limited to 'exwm-input.el')
-rw-r--r--exwm-input.el15
1 files changed, 15 insertions, 0 deletions
diff --git a/exwm-input.el b/exwm-input.el
index da242e9a6af9..4ba39f7ae482 100644
--- a/exwm-input.el
+++ b/exwm-input.el
@@ -1035,6 +1035,21 @@ where both ORIGINAL-KEY and SIMULATED-KEY are key sequences."
       (dolist (key keys)
         (exwm-input--fake-key key)))))
 
+;;;###autoload
+(defmacro exwm-input-invoke-factory (keys)
+  "Make a command that invokes KEYS when called.
+
+One use is to access the keymap bound to KEYS (as prefix keys) in char-mode."
+  (let* ((keys (kbd keys))
+         (description (key-description keys)))
+    `(defun ,(intern (concat "exwm-input--invoke--" description)) ()
+       ,(format "Invoke `%s'." description)
+       (interactive)
+       (mapc (lambda (key)
+               (exwm-input--cache-event key t)
+               (exwm-input--unread-event key))
+             ',(listify-key-sequence keys)))))
+
 (defun exwm-input--on-pre-command ()
   "Run in `pre-command-hook'."
   (unless (memq this-command exwm-input-pre-post-command-blacklist)