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 /modules | |
| 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 'modules')
| -rw-r--r-- | modules/vterm-config.el | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/modules/vterm-config.el b/modules/vterm-config.el index 0817c3d95..70f5d60ad 100644 --- a/modules/vterm-config.el +++ b/modules/vterm-config.el @@ -215,6 +215,17 @@ because tmux never sees the events." (interactive) (cj/vterm--send-mouse-wheel 65)) +(defun cj/vterm-send-escape () + "Send the ESC byte to the program running in this vterm. + +`<escape>' is bound globally to `keyboard-escape-quit' (see +`modules/keybindings.el'), so without this override Emacs swallows +the key before it can reach the pty. Forwarding it here lets tmux +copy-mode cancel, vi-mode exits, and any other in-terminal program +that relies on Escape see the key." + (interactive) + (vterm-send-string "\e")) + (use-package vterm :defer .5 :commands (vterm vterm-other-window) @@ -255,7 +266,8 @@ ai-vterm.el is loaded." ("<wheel-up>" . cj/vterm-mouse-wheel-up) ("<wheel-down>" . cj/vterm-mouse-wheel-down) ("<mouse-4>" . cj/vterm-mouse-wheel-up) - ("<mouse-5>" . cj/vterm-mouse-wheel-down)) + ("<mouse-5>" . cj/vterm-mouse-wheel-down) + ("<escape>" . cj/vterm-send-escape)) :custom (vterm-kill-buffer-on-exit t) (vterm-max-scrollback 100000) |
