Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

meow-pop-selection should undo meow-cancel-selection #418

Open
ajgrf opened this issue Mar 19, 2023 · 4 comments
Open

meow-pop-selection should undo meow-cancel-selection #418

ajgrf opened this issue Mar 19, 2023 · 4 comments
Labels
question Further information is requested

Comments

@ajgrf
Copy link

ajgrf commented Mar 19, 2023

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.

@DogLooksGood
Copy link
Collaborator

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.

@ajgrf
Copy link
Author

ajgrf commented Mar 20, 2023

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.

@DogLooksGood
Copy link
Collaborator

It's possible, of course, but I don't think it's a good idea. Two reasons:

  1. It's a little bit hard for people to remember whether a modification was made or not.
  2. 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.

@DogLooksGood DogLooksGood added the question Further information is requested label Apr 2, 2023
@45mg
Copy link
Contributor

45mg commented May 19, 2024

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants