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

Use narrow-to-region #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cute-jumper
Copy link

This should fix the problem that when the number inside the region
changes, the end of the region might also changes.

For example, when the region contains "9 10", first we will increase 9 to 10, then the region end is changed. Actually the Emacs would issue an error: "Invalid search bound (wrong side of point)" in this case. Using narrow-to-region can avoid such problem.

By the way, I think it is better to remove the deactivate-mark in the code for the region. If we do that, the region is still active after we do evil-numbers/inc-at-pt or evil-numbers/dec-at-pt, so we can repeatedly increase/decrease the numbers in the region, and we can also do some other things for the region(copy, kill, etc.). Right now the user has to reselect the region after they use evil-numbers/inc-at-pt or evil-numbers/dec-at-pt. But this is only my personal favor, and I didn't include this change in this pull request. You decide. :-)

This should fix the problem that when the number inside the region
changes, the end of the region might also changes
@juliapath
Copy link

Thank you, I used this in my fork. I also tried retaining the region, but it was quite a pain to do this and it breaks using . to repeat. Consider this file:

0 0 1
1 0 0

We want to increment the four 0s.

When we exit visual state after incrementing we can select the two on the other hand, execute inc-at-pt, then move point on the first zero on the lower line and hit .. This does not work if we stay in visual state.

Also I wanted it to work with block selection and it sucks when you consider things like this

9 9  ~> 10 10
0 0     1 1

If we selected the 9-0-rectangle and increment, what should the new selection be? I wanted it to contain both the 10s and the 1s even if the last line is to short to put mark or point in the correct spot. I did get it to work, but it required some hacks. If you are interested (I know your PR is from 3½ years ago), you can check out my attempt here.

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.

2 participants