Skip to content

Commit 2ee9d3b

Browse files
committed
Exit copy mode on normal key press and fix README
Normal letter keys (a-z etc.) now exit copy mode and forward the key to the terminal, so the user can seamlessly resume typing. Also fix README: - Copy mode keybinding was C-c C-k, actual binding is C-c C-t - Add missing keys to copy mode table: C-n/C-p, M-v/C-v, M-</M-> C-e, and document the new exit-on-keypress behavior
1 parent ba6f632 commit 2ee9d3b

2 files changed

Lines changed: 24 additions & 11 deletions

File tree

README.md

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ test "$INSIDE_EMACS" = 'ghostel'; and source "$EMACS_GHOSTEL_PATH/etc/ghostel.fi
8282
| `C-c C-z` | Send suspend (C-z) |
8383
| `C-c C-d` | Send EOF (C-d) |
8484
| `C-c C-\` | Send quit (C-\) |
85-
| `C-c C-k` | Enter copy mode |
85+
| `C-c C-t` | Enter copy mode |
8686
| `C-y` | Yank from kill ring (bracketed paste) |
8787
| `M-y` | Yank-pop (cycle through kill ring) |
8888
| `C-c C-y` | Paste from kill ring |
@@ -97,15 +97,20 @@ Keys listed in `ghostel-keymap-exceptions` (default: `C-c`, `C-x`, `C-u`,
9797

9898
### Copy mode
9999

100-
Enter with `C-c C-k`. Standard Emacs navigation works.
101-
102-
| Key | Action |
103-
|---------------|-------------------------|
104-
| `C-SPC` | Set mark |
105-
| `M-w` / `C-w` | Copy selection and exit |
106-
| `C-c C-n` | Jump to next prompt |
107-
| `C-c C-p` | Jump to previous prompt |
108-
| `q` | Exit without copying |
100+
Enter with `C-c C-t`. Standard Emacs navigation works.
101+
Normal letter keys exit copy mode and send the key to the terminal.
102+
103+
| Key | Action |
104+
|---------------|---------------------------------|
105+
| `C-SPC` | Set mark |
106+
| `M-w` / `C-w` | Copy selection and exit |
107+
| `C-n` / `C-p` | Move line (scrolls at edges) |
108+
| `M-v` / `C-v` | Scroll page up / down |
109+
| `M-<` / `M->` | Jump to top / bottom of buffer |
110+
| `C-c C-n` | Jump to next prompt |
111+
| `C-c C-p` | Jump to previous prompt |
112+
| `C-t` | Exit without copying |
113+
| `a``z` | Exit and send key to terminal |
109114

110115
Soft-wrapped newlines are automatically stripped from copied text.
111116

ghostel.el

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1011,7 +1011,8 @@ pasted using bracketed paste."
10111011

10121012
(defvar ghostel-copy-mode-map
10131013
(let ((map (make-sparse-keymap)))
1014-
(define-key map (kbd "q") #'ghostel-copy-mode-exit)
1014+
;; Normal letter keys exit copy mode and send the key to the terminal
1015+
(define-key map [remap self-insert-command] #'ghostel-copy-mode-exit-and-send)
10151016
(define-key map (kbd "C-c C-t") #'ghostel-copy-mode-exit)
10161017
(define-key map (kbd "M-w") #'ghostel-copy-mode-copy)
10171018
(define-key map (kbd "C-w") #'ghostel-copy-mode-copy)
@@ -1072,6 +1073,13 @@ Press \\`q' or \\[ghostel-copy-mode-exit] to exit without copying."
10721073
(ghostel--invalidate)
10731074
(message "Copy mode exited")))
10741075

1076+
(defun ghostel-copy-mode-exit-and-send ()
1077+
"Exit copy mode and send the key that triggered exit to the terminal."
1078+
(interactive)
1079+
(ghostel-copy-mode-exit)
1080+
(when ghostel--term
1081+
(ghostel--self-insert)))
1082+
10751083
(defun ghostel--filter-soft-wraps (text)
10761084
"Remove newlines from TEXT that were inserted by soft line wrapping.
10771085
These are newlines with the `ghostel-wrap' text property."

0 commit comments

Comments
 (0)