about summary refs log tree commit diff
path: root/exwm-input.el
diff options
context:
space:
mode:
authorSebastian Wålinder <s.walinder@gmail.com>2019-06-30T16·21+0200
committerChris Feng <chris.w.feng@gmail.com>2019-07-14T00·00+0000
commit0a3dde042a6ff671bd728bf1943fd3a743371161 (patch)
tree91f201c1d0f45d7622dece5c420db3fa42f7d144 /exwm-input.el
parentfe8ee3c5786bf8c1c69cef1b2ad6bb6b2d785a6d (diff)
Added option to have a key that ends exwm-input-send-next-key
* exwm-input.el (exwm-input-send-next-key): Accept an optional end key.
Diffstat (limited to 'exwm-input.el')
-rw-r--r--exwm-input.el14
1 files changed, 10 insertions, 4 deletions
diff --git a/exwm-input.el b/exwm-input.el
index 22c8002be6..351820ca7e 100644
--- a/exwm-input.el
+++ b/exwm-input.el
@@ -845,11 +845,11 @@ button event."
     (xcb:flush exwm--connection)))
 
 ;;;###autoload
-(cl-defun exwm-input-send-next-key (times)
+(cl-defun exwm-input-send-next-key (times &optional end-key)
   "Send next key to client window.
 
 EXWM will prompt for the key to send.  This command can be prefixed to send
-multiple keys."
+multiple keys.  If END-KEY is non-nil, stop sending keys if it's pressed."
   (interactive "p")
   (exwm--log)
   (unless (derived-mode-p 'exwm-mode)
@@ -861,11 +861,17 @@ multiple keys."
       (let ((exwm-input-line-mode-passthrough t))
         (catch 'break
           (while t
-            (setq key (read-key (format "Send key: %s (%d/%d)"
+            (setq key (read-key (format "Send key: %s (%d/%d) %s"
                                         (key-description keys)
-                                        (1+ i) times)))
+                                        (1+ i) times
+                                        (if end-key
+                                            (concat "To exit, press: "
+                                                    (key-description
+                                                     (list end-key)))
+                                          ""))))
             (unless (listp key) (throw 'break nil)))))
       (setq keys (vconcat keys (vector key)))
+      (when (eq key end-key) (cl-return-from exwm-input-send-next-key))
       (exwm-input--fake-key key))))
 
 (defun exwm-input--set-simulation-keys (simulation-keys &optional no-refresh)