aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-05 09:55:41 -0500
committerCraig Jennings <c@cjennings.net>2026-06-05 09:55:41 -0500
commit81ececd67b23e42163c970edb4e9a4c0d824612e (patch)
tree66c6558000c8675ed63c8b0e2ae9518e383d581c /tests
parent854aa53a96476ccaae0c93bd9af0493ef8431e4b (diff)
downloaddotemacs-81ececd67b23e42163c970edb4e9a4c0d824612e.tar.gz
dotemacs-81ececd67b23e42163c970edb4e9a4c0d824612e.zip
fix(term): forward C-SPC and window-nav keys in ghostel buffers
Two keystrokes weren't reaching Emacs inside a ghostel terminal, both because of how ghostel routes keys in semi-char mode. C-SPC was the worse one. ghostel forwards the `C-@' event but not the distinct `C-SPC' event GUI Emacs produces, so C-Space fell through to the global `set-mark-command' and set an Emacs region in the terminal buffer. That region followed point as output streamed (a stuck "selection" Escape and C-g couldn't clear), and it meant tmux copy-mode's begin-selection never started, so M-w copied nothing. I bind C-SPC to cj/term-send-C-SPC, which forwards NUL like a terminal key. The C-M-arrows (buffer-move, window swap) were being forwarded to the terminal program the same way the F9 family was. I added the windmove S-arrows and buffer-move C-M-arrows to ghostel-keymap-exceptions and rebuilt the semi-char map. The S-arrows already reached Emacs by keymap precedence, but listing them makes the window-nav contract explicit rather than accidental. Regression tests cover all three: C-SPC bound to the forwarder, and the window-nav keys in the exceptions with the semi-char map no longer forwarding them.
Diffstat (limited to 'tests')
-rw-r--r--tests/test-term-tmux-history.el17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/test-term-tmux-history.el b/tests/test-term-tmux-history.el
index 49296b42..1bb7e73b 100644
--- a/tests/test-term-tmux-history.el
+++ b/tests/test-term-tmux-history.el
@@ -317,5 +317,22 @@ F12 toggle reach Emacs inside ghostel buffers."
(should-not (eq (keymap-lookup ghostel-semi-char-mode-map "<f12>")
'ghostel--send-event)))
+(ert-deftest test-term-window-nav-keys-in-keymap-exceptions ()
+ "Regression: windmove (S-arrows) and buffer-move (C-M-arrows) are in
+`ghostel-keymap-exceptions' so they reach Emacs from inside a ghostel buffer
+instead of being forwarded to the terminal program."
+ (dolist (key '("S-<up>" "S-<down>" "S-<left>" "S-<right>"
+ "C-M-<up>" "C-M-<down>" "C-M-<left>" "C-M-<right>"))
+ (should (member key ghostel-keymap-exceptions)))
+ (should-not (eq (keymap-lookup ghostel-semi-char-mode-map "C-M-<left>")
+ 'ghostel--send-event)))
+
+(ert-deftest test-term-c-spc-forwarded-not-set-mark ()
+ "Regression: C-SPC is forwarded to the terminal, not bound to the global
+`set-mark-command'. ghostel only forwards the `C-@' event, so without this an
+Emacs region gets stuck in the ghostel buffer and tmux copy-mode's
+begin-selection never starts."
+ (should (eq (keymap-lookup ghostel-mode-map "C-SPC") #'cj/term-send-C-SPC)))
+
(provide 'test-term-tmux-history)
;;; test-term-tmux-history.el ends here