Skip to content

Bind S-<insert> and remap yank to ghostel-yank#265

Merged
dakra merged 1 commit into
mainfrom
paste-binding-remap-yank
May 12, 2026
Merged

Bind S-<insert> and remap yank to ghostel-yank#265
dakra merged 1 commit into
mainfrom
paste-binding-remap-yank

Conversation

@dakra
Copy link
Copy Markdown
Owner

@dakra dakra commented May 11, 2026

Summary

  • Bind S-<insert> to ghostel-yank in semi-char and readonly modes — the conventional alternative paste shortcut in browsers, terminal emulators, and file managers.
  • Add <remap> <yank> to both maps so anything Emacs globally binds to yank (notably s-v on macOS, plus user rebinds) routes through ghostel-yank without a per-key entry. The darwin s-v special-case blocks in both maps are now redundant and removed.
  • C-y stays explicitly bound so user rebinds of yank's global key cannot break ghostel paste. Line mode keeps Emacs's regular yank (paste lands in the editable input region). Char mode is unchanged.

Closes #263.

Why S-<insert> needs an explicit binding (not just the remap)

ghostel--define-terminal-keys iterates <insert> × (S- C- M- C-S- M-S- C-M-) and binds every combo to ghostel--send-event. That's a direct binding in ghostel-semi-char-mode-map, and direct bindings win over the <remap> chain — remap only fires on the command that the literal-key lookup resolves to. s-v flows through the remap fine because the helper's modifier list excludes super. Readonly mode never calls the helper, so the remap is enough there.

Test plan

  • make -j4 all — 354 tests, 352 pass, 0 unexpected, 2 pre-existing skips (bash-completion availability).
  • New ert: ghostel-test-yank-remap-bindings covers the [remap yank] entries in semi-char/readonly, the absence of the remap in line/char modes, char mode's S-<insert> still going to ghostel--send-event, and end-to-end key-binding resolution of C-y/S-<insert>/s-v (darwin) in an active ghostel buffer.
  • Fresh emacs --batch confirms C-y, S-<insert>, and s-v all resolve to ghostel-yank in semi-char mode.
  • Manual: open a ghostel buffer in emacsclient, kill text from another buffer, press S-<insert> and confirm bracketed paste arrives at the shell prompt; repeat in Emacs/copy mode.

Shift-Insert is the conventional alternative paste binding in
browsers, terminal emulators, and file managers; binding it to
ghostel-yank brings ghostel in line.  In the same pass, layer
<remap> <yank> onto the semi-char and readonly maps so any key
Emacs binds to yank globally — s-v on macOS, plus user rebinds —
routes through ghostel-yank without needing a per-key entry, and
drop the now-redundant darwin s-v special cases from both maps.

C-y stays explicitly bound so user rebinds of the global yank key
cannot break ghostel paste.  S-<insert> also needs an explicit
binding in semi-char-mode-map because ghostel--define-terminal-keys
otherwise routes it through ghostel--send-event as part of the
<insert> modifier expansion; the readonly map doesn't call that
helper and is caught by the remap alone.  <XF86Paste> stays
explicit in ghostel-mode-map (Emacs has no global binding for it
to ride on).  Line mode keeps Emacs's regular yank so paste lands
in the input region.

Closes #263.
@dakra dakra force-pushed the paste-binding-remap-yank branch from e8cc375 to b174678 Compare May 12, 2026 06:39
@dakra dakra merged commit b174678 into main May 12, 2026
22 checks passed
@dakra dakra deleted the paste-binding-remap-yank branch May 12, 2026 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for alternative paste binding

1 participant