aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-18 17:00:08 -0400
committerCraig Jennings <c@cjennings.net>2026-05-18 17:00:08 -0400
commit55fb9102c70dc272d4267aec30eed4860f3abdf5 (patch)
treedf2f80a85eb42b17d8770545440523e331266a20 /modules
parenta537ef1155bff9aa269a6e7d6d30aa9a378f552b (diff)
downloaddotemacs-55fb9102c70dc272d4267aec30eed4860f3abdf5.tar.gz
dotemacs-55fb9102c70dc272d4267aec30eed4860f3abdf5.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.el14
1 files changed, 13 insertions, 1 deletions
diff --git a/modules/vterm-config.el b/modules/vterm-config.el
index 0817c3d9..70f5d60a 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)