0

Coming from vim into (evil-mode) spacemacs, I sometimes get frustrated that undo segment is not ended when a mouse-caused cursor movement occurs. An example : While I am inserting text, touchpad gets often touched, causing the cursor to jump elsewhere. If I have entered five sentences just where I wanted them, without any jump, but sixth sentence gets by mistake entered all over the place because of multiple (three) touchpad touches in different places, when I notice this, I need to be able to execute (three times) "undo" so that the fives sentences stay intact, and the undo operation erase only the sixth sentence from all over the place.

Right now when insert gets this way screwed up, the undo tree contains only one segment. When I press undo, all six sentences disappear. I have to choose all-or-nothing, neither of which is very useful!!

Appending after "blabla" by entering insert mode and typing "This is first sentence. " /now mouse click occurs by mistake/ "This is second sentence." I get: blabla This is This is second sentence. first sentence. Pressing U for undo I need to get : blabla This is first sentence. , but I am instead getting: blabla

Interestingly enough, when text is being replaced and not inserted, everything works as expected - undo segment ends when mouse moves the cursor, so replacing by mistake I can in sequence undo the previous changes made after mouse-caused jump.

How can I fix this? Is it a bug, or some funny feature?

PS: Please do not advise me to get "disable touch pad while typing" working.

1 Answer 1

0

On 2020-10-18 00:34, Stefan Monnier wrote:

How to end text-insert undo segment after cursor jump (caused by mouse)?

Note that the behavior you describe comes from code in Evil. The way undo steps are divided in non-Evil Emacs is different (mostly, finer grained).

More specifically, I believe that if you perform the undo before you finish your insertion (i.e. before hitting ESC), you should get (more or less) the behavior you want, i.e. the cursor jump due to your mouse event will indeed have ended an undo sequence. Evil then collapses those undo steps into a single one when you leave insertion mode.

In any case, maybe setting evil-want-fine-undo will also do the trick.

The issue was caused by evil layer. The solution suggested by Stefan, to set evil-want-fine-undo worked.

I went to Emacs customization interface for this option, set it to non-nil, and saved. Then I was able to undo up until the problematic point, and the undo action no longer grouped everything between start and end of insert command, but recognized piece-wise undo segments.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.