aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-06 12:47:24 -0500
committerCraig Jennings <c@cjennings.net>2026-06-06 12:47:24 -0500
commit110644a48ad63353cfe19110248d3515b4537b58 (patch)
tree9afc7211f9321b5cfecfdd5a2328818f34792d11 /modules
parent0946c42f5caaf715786780b7be8205e6ac289d8a (diff)
downloaddotemacs-110644a48ad63353cfe19110248d3515b4537b58.tar.gz
dotemacs-110644a48ad63353cfe19110248d3515b4537b58.zip
fix(term): land copy-mode cursor at column 0
Entering copy-mode from C-; x c left the cursor at the live column, far right after a prompt, so scrolling up ran the cursor up the right edge instead of the left. In the tmux branch I append C-a after C-b [, which tmux's emacs copy-mode reads as start-of-line. It has to go after C-b [: before copy-mode is active, C-a would hit the shell's readline instead. In the non-tmux ghostel-copy-mode branch I call beginning-of-line after entering the view, for the same column-0 result. Both branches now run the cursor up the left edge. The non-tmux test asserts ghostel-copy-mode runs before beginning-of-line, since the move only repositions inside an active copy view. Its tracker variable is dwim-order, not calls, to avoid clashing with the variable the tmux mock macro binds.
Diffstat (limited to 'modules')
-rw-r--r--modules/term-config.el24
1 files changed, 16 insertions, 8 deletions
diff --git a/modules/term-config.el b/modules/term-config.el
index 7cd386dc..2daebe9b 100644
--- a/modules/term-config.el
+++ b/modules/term-config.el
@@ -29,10 +29,12 @@
;; Two ways to lift text out of a terminal, both with the same key story:
;; - C-; x c enters copy-mode via `cj/term-copy-mode-dwim'. When a tmux
;; client is attached (typical -- `cj/term-launch-tmux' auto-starts tmux),
-;; sends tmux's prefix C-b [ so the user lands in tmux's own copy-mode with
-;; the full pane history available. Without tmux, falls back to
+;; sends tmux's prefix C-b [ then C-a, so the user lands in tmux's own
+;; copy-mode with the full pane history and the cursor at column 0 (so
+;; scrolling up runs up the left, not the right). Without tmux, falls back to
;; `ghostel-copy-mode' (read-only standard-Emacs navigation over the
-;; scrollback; M-w copies and stays, q / C-g exit).
+;; scrollback; M-w copies and stays, q / C-g exit) and moves point to the
+;; start of the line for the same column-0 reason.
;; - C-; x h captures the current tmux pane's full history into a temporary
;; Emacs buffer.
;; In both copy surfaces, M-w copies the active region and stays open so several
@@ -190,13 +192,19 @@ cheap boolean predicate."
"Enter copy-mode using the engine appropriate to this terminal.
When tmux is attached, write tmux's default prefix sequence (C-b [) into the
-pty so the user lands in tmux's copy-mode with the full pane history. Without
-tmux, falls through to `ghostel-copy-mode', a read-only standard-Emacs view of
-the scrollback (M-w copies and stays, q / C-g exit)."
+pty so the user lands in tmux's copy-mode with the full pane history, then
+C-a to land the cursor at the start of the line. Without the trailing C-a
+the copy cursor inherits the live column (far right after a prompt) and
+scrolling up runs up the right edge; tmux's emacs copy-mode binds C-a to
+start-of-line, so column 0 makes it run up the left. Without tmux, falls
+through to `ghostel-copy-mode' (a read-only standard-Emacs view of the
+scrollback; M-w copies and stays, q / C-g exit), then moves point to the
+start of the line for the same column-0 reason."
(interactive)
(if (cj/term--in-tmux-p)
- (ghostel-send-string "\C-b[")
- (ghostel-copy-mode)))
+ (ghostel-send-string "\C-b[\C-a")
+ (ghostel-copy-mode)
+ (beginning-of-line)))
;; ----------------------------- ghostel package -------------------------------