Skip to content

Add Emacs-style mark commands (setMark:, selectToMark:, swapWithMark:, deleteToMark:) - #113

Merged
krzyzanowskim merged 1 commit into
krzyzanowskim:mainfrom
rhsev:mark-commands
Jul 18, 2026
Merged

Add Emacs-style mark commands (setMark:, selectToMark:, swapWithMark:, deleteToMark:)#113
krzyzanowskim merged 1 commit into
krzyzanowskim:mainfrom
rhsev:mark-commands

Conversation

@rhsev

@rhsev rhsev commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Problem: The AppKit STTextView implements the kill ring (yank:) but not the mark family from NSStandardKeyBindingRespondingsetMark:, selectToMark:, swapWithMark: and deleteToMark: are no-ops. Multi-step DefaultKeyBinding.dict macros (line moves, paragraph cut/copy, …) are commonly built on exactly these selectors and break mid-chain.

Change: Implements the four selectors in an STTextView+Mark extension, storing the mark as an NSRange next to _yankingManager. deleteToMark: routes through deleteBackward: so the killed text lands in the yank buffer and a following yank: reinserts it. Stale marks (text edited since setMark:) are clamped before use.

Tests included. Verified against a real-world binding dictionary: a ^@\UF700 move-line-up macro chain (selectParagraph:, setMark:, deleteToMark:, …, yank:, selectToMark:) now behaves the same as in NSTextView.

…, deleteToMark:)

The kill ring (yank:) is already implemented, but the mark family from
NSStandardKeyBindingResponding was missing, so DefaultKeyBinding.dict
macros built on setMark:/deleteToMark:/selectToMark: (line moves,
paragraph cut/copy) broke mid-chain. deleteToMark: routes through
deleteBackward: so the killed text lands in the yank buffer.
@CLAassistant

CLAassistant commented Jul 16, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@krzyzanowskim krzyzanowskim left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you!

@rhsev

rhsev commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

FWIW: the five new MarkTests pass — the macOS failures are in the SizeToFitTests suite, which this PR doesn't touch.

@krzyzanowskim

Copy link
Copy Markdown
Owner

I wonder why tests started to fail

@rhsev

rhsev commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

Well, the 2.3.9 and 2.3.10 release pushes failed Tests back in April too (runs 24578356355 / 25106201089), as did an April PR. The last green run on main I can see is from Jan 6. All current failures are SizeToFitTests, i.e. sizeToFit compared against NSTextView metrics, and the macos-15 runner image was refreshed on Jul 15 (version 20260715.0234.1). So this looks like text-metric drift in the runner environment.

Running the Tests workflow on main via workflow_dispatch should reproduce it without this PR.

@krzyzanowskim
krzyzanowskim merged commit 607c1fd into krzyzanowskim:main Jul 18, 2026
2 of 3 checks passed
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.

3 participants