meow-edit / meow

Yet another modal editing on Emacs / 猫态编辑
GNU General Public License v3.0
1.07k stars 128 forks source link

Add `meow-replace-pop`. #509

Closed okamsn closed 7 months ago

okamsn commented 7 months ago

This command, when run after meow-replace or itself, replaces the just inserted text with the next item in the kill ring, without rotating the kill ring.

The marker was needed to support meow-replace-char, which doesn't use a region. Otherwise, one could use (mark t) to get the mark's position.

okamsn commented 7 months ago

Why do meow-replace and the other commands strip a trailing new line from the replacement? I copied that, but I don't understand why it's needed.

DogLooksGood commented 7 months ago

Well, the meow-replace is designed to replace the selected text with the head of kill-ring. So here is a breaking change?

okamsn commented 7 months ago

The command meow-replace-pop isn't meant to replace meow-replace. It is meant to run run after it. For example, I use meow-replace-pop as the fallback for meow-replace in meow-selection-command-fallback.

Sometimes, I want to replace the region with text that is further into the kill ring. By using meow-replace-pop as the fallback of meow-replace, I can keep hitting r to reach the desired text in the kill ring. It is similar to running yank-pop after yank, except that meow-replace-pop does not cycle the kill ring, so that running meow-replace later will work as expected.

If the command meow-replace-pop is run after meow-replace, which part is the breaking change?

EDIT: I've made the code signal a user error in meow-replace-pop if the previous command isn't a replacement command. Hopefully that makes what I mean to say clearer.

DogLooksGood commented 7 months ago

Got it, thanks for the explanation. Are we ready for the merge?

okamsn commented 7 months ago

Yes, I'm happy with it. I thought about using a prefix argument to reverse the cycling direction, but I now think it's easier to just use undo.

DogLooksGood commented 7 months ago

Thanks!