Use narrow-to-region#8
Conversation
This should fix the problem that when the number inside the region changes, the end of the region might also changes
|
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: We want to increment the four 0s. When we exit visual state after incrementing we can select the two on the other hand, execute Also I wanted it to work with block selection and it sucks when you consider things like this 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. |
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-markin the code for the region. If we do that, the region is still active after we doevil-numbers/inc-at-ptorevil-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 useevil-numbers/inc-at-ptorevil-numbers/dec-at-pt. But this is only my personal favor, and I didn't include this change in this pull request. You decide. :-)