From 55fb9102c70dc272d4267aec30eed4860f3abdf5 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Mon, 18 May 2026 17:00:08 -0400 Subject: feat(vterm): forward to the pty in vterm-mode `' 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. --- modules/vterm-config.el | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'modules') 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. + +`' 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." ("" . cj/vterm-mouse-wheel-up) ("" . cj/vterm-mouse-wheel-down) ("" . cj/vterm-mouse-wheel-up) - ("" . cj/vterm-mouse-wheel-down)) + ("" . cj/vterm-mouse-wheel-down) + ("" . cj/vterm-send-escape)) :custom (vterm-kill-buffer-on-exit t) (vterm-max-scrollback 100000) -- cgit v1.2.3