meow
meow copied to clipboard
`meow-pop-selection` should undo `meow-cancel-selection`
I was looking for an analog to vim's gv
command that re-selects the most recent selection, and I couldn't find one. I rely on this feature in vim and I think it would be even more useful in meow given how much more meow relies on selections.
Probably the most logical place to add this functionality in meow is as a fallback behavior when meow-pop-selection
is called without a selection.
The selection histories are stored with their positions, once a modification is made, the histories become inaccurate. This is why we drop histories when selection is deactivated.
OK, but what about when no modification has been made? One thing I find happening a lot as I try to adjust to meow is that I'll start selecting something, then accidentally start a new selection (when I wanted to extend the old one), but there is already no way to undo my mistake. I have to start my selection over again from scratch.
It's possible, of course, but I don't think it's a good idea. Two reasons:
- It's a little bit hard for people to remember whether a modification was made or not.
- It's hard for Meow to track the modification, unless we use the hook, and we are trying to avoid hooks as much as possible.
I used to have a concept in my mind to make all "single-key" mistake recoverable, by designing all commands in a compatible way. But in the end, I found it introduces a lot complexity.
And in your case, a simple idea is, don't extend the selection. When making a selection, you should describe where you want to go(e.g. after a specific char, end of a symbol, a paired parentheses, etc), instead of describing the path(e.g. line+word+char*3). Whenever you need a arbitrary extending, you use built-in commands, M-f
, M-b
, C-e
, etc.
Would you still be open to accepting this feature if someone could find and PR a simple way to do it? I also really feel the need for it. It's often not possible to specify a complex selection with Meow's thing commands (example - select the next 3 paragraphs), and it's very easy to lose a carefully made selction in Meow since so many commands cancel it.
As an example of a possible approach, though I haven't tried yet, I think it could be done by using markers to save the selection positions in meow--selection
and meow--selection-history
; these will move when the buffer is modified, so the position of the selection would remain relatively accurate regardless of changes to that region. This is how Evil does it (see evil-visual-restore
).