Repository navigation
donkey 1.16.0 — f edits every match at once
A feature release. f edits every match in a selection at once, and a
V selection hands Emacs's own C-w, M-w and C-x r s its whole
lines.
f asks for a regexp, holds every match in what you selected, and
waits: i types before every match, a after it, c empties it and
types in its place, d deletes it, and w or a delimiter wraps it.
What you type appears at every match as you type it, in ordinary
INSERT state, and C-g ends it keeping what you wrote.
It is DONKEY's own take on multiple cursors, and it works by mirroring
rather than by cursors: the place you type in is copied into the others
after each command, so nothing intercepts a command while you write and
INSERT state stays Emacs's own.
Added
f(donkey-split) — a key that rang the bell before. It
changes nothing by itself: it selects every match and waits for a
verb. A wrap leaves the split standing, so pairs nest and a verb can
still follow —f([awraps twice and then types after — and
the other verbs end it.- What
fsearches is what you selected: the current line when
nothing is, av,Vor%selection, the inside of anm vblock
(C-u ftakes each row's whole line), or banked lines, with av
selection made after banking searched exactly as selected. There is
no whole-buffer default; press%first. Opening the split spends
the bank, asyandddo. - Matches that differ —
[0-9]+over1,22and333holds
three different texts, andiandathen type at their edges, so
nothing is replaced. Case is decided the wayr rdecides it: a
regexp with no capital ignores case. DELandC-dat an edge — Backspace just before a match,C-d
just after it, and the indentationRETbrings with it are repeated
at every match. An edit anywhere else ends the split and says so.canddput one kill on the ring: one copy when the matches
agree, every match on a line of its own when they differ.- The report — a split that ends says what it did, "Split: typed
after 3 places", and the line stays in*Messages*. donkey-split-facecolors the matches while a split is open.- The tutor teaches the split in Lessons 14 and 15, by exercise:
the verbs, a selection, banked lines alone and with part of a line
selected, case, and the five regexp spellings Emacs does not share
with other tools.
Changed — you will notice these
C-w,M-w,C-x r son aVselection take its whole lines,
final newline included, asdandydo.C-wused to leave an
empty line behind, andM-wcopied the lines without their last
newline, so the paste ran into the line it landed on.M-s o
searches the same lines. Commands that read point and mark for
themselves still see the selection stop before its last newline —
M-x keep-linesleaves the last line out — and the README says how
to hand them whole lines.
Fixed — you will notice these
Min a daemon with two clients — a key on the second client
ended a mark run armed on the first but left its keys armed there for
good, so on that client its letters went on running mark commands in
every state: typingwowin INSERT state left a singleo. A run
now keeps to the terminal it started on.
Under the hood
- Every match's edit goes through Emacs's change hooks as a typed edit
does, so font-lock, the syntax cache and a language server see every
match change, not only the one you typed in. - A verb over many matches is one change: it happens at every match or
at none, and what it reports reaches the kill ring only once it has. - Only what changed is copied into the other matches, which keeps a key
at a thousand matches to about a millisecond and a half, and the undo
record to about a third of the size.
Upgrading
Nothing to do. f was a free key, so if you had bound it yourself your
binding still wins; DONKEY's startup report now names it — "f is ...
now, was donkey-split" — because the key is DONKEY's from this release.