From 3420cd24d107bf9a0396089bb00396e6ab35447e Mon Sep 17 00:00:00 2001 From: Chris Feng Date: Sun, 3 Nov 2019 00:00:00 +0000 Subject: [PATCH] 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. --- exwm-input.el | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/exwm-input.el b/exwm-input.el index da242e9a6..4ba39f7ae 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)