diff options
| author | Craig Jennings <c@cjennings.net> | 2026-05-18 17:00:08 -0400 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-05-18 17:00:08 -0400 |
| commit | c4ce432bae65e98ea5e77106e0bab67b9e95ef75 (patch) | |
| tree | 7e30016b2264b54e75c8d4cec0230a892c869827 /tests | |
| parent | 2db92366b572fe4d92bdb2402fb7dfcdb3d94136 (diff) | |
| download | dotemacs-c4ce432bae65e98ea5e77106e0bab67b9e95ef75.tar.gz dotemacs-c4ce432bae65e98ea5e77106e0bab67b9e95ef75.zip | |
feat(vterm): forward <escape> to the pty in vterm-mode
`<escape>' is bound globally to `keyboard-escape-quit' in
modules/keybindings.el, so Emacs swallows the key before it can reach the
pty. Bind it in vterm-mode-map to cj/vterm-send-escape, which writes a
literal ESC byte via vterm-send-string. tmux's copy-mode `cancel' binding
then fires; vi-mode exits, fzf cancel, etc., also work as expected.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test-vterm-tmux-history.el | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/test-vterm-tmux-history.el b/tests/test-vterm-tmux-history.el index be6549050..88bd55934 100644 --- a/tests/test-vterm-tmux-history.el +++ b/tests/test-vterm-tmux-history.el @@ -352,6 +352,21 @@ its own copy-mode against the full pane history." (cj/vterm-mouse-wheel-down) (should (equal sent '("\e[<65;1;1M")))))) +(ert-deftest test-vterm-send-escape-writes-esc-byte () + "Normal: `cj/vterm-send-escape' forwards a literal ESC byte to the pty so +tmux copy-mode, vi-mode exits, etc., can see the key past Emacs's global +`<escape>' → `keyboard-escape-quit' binding." + (let ((sent nil)) + (cl-letf (((symbol-function 'vterm-send-string) + (lambda (s &optional _paste-p) (push s sent)))) + (cj/vterm-send-escape) + (should (equal sent '("\e")))))) + +(ert-deftest test-vterm-escape-binding-installed-on-vterm-mode-map () + "Normal: `<escape>' in `vterm-mode-map' routes through `cj/vterm-send-escape'." + (should (eq (keymap-lookup vterm-mode-map "<escape>") + #'cj/vterm-send-escape))) + (ert-deftest test-vterm-wheel-bindings-installed-on-vterm-mode-map () "Normal: wheel-up / wheel-down (and X11 mouse-4 / mouse-5) route to the forwarding commands so tmux can see them via `set -g mouse on'." |
