I work on a laptop most of the time and it happens somewhat often that while inserting some text (in evil mode) I will accidentally hit the touchpad with my thumb, changing the cursor position and causing the next few words to be inserted into some unrelated paragraph. The somewhat annoying thing is that undo is usually of no help here, because the last saved undo state is whenever I entered insert mode and I might have written several sentences since then that I don't want to lose. I'd rather not completely disable use of the mouse, so I'm hoping to implement one of the following acceptable fixes:
- Don't allow mouse clicks to change position while in evil insert mode, only in normal mode (this sounds the simplest).
- Update the undo state whenever I change cursor position with the mouse, if there is a callback for that.
Are either of these possible?
undo-boundary
looks like it might be helpful if you call it when setting point with the mouse .... gnu.org/software/emacs/manual/html_node/elisp/Undo.html My recollection is that there is more than one mouse-set-point related functions, so it may depend upon the mode. You can typeC-h k
and see what your mouse click is bound to.emacs-nox
) the mouse clicks will never have any effect (except to shift focus to your window). That's not what you asked for - but this is only a comment, not an answer.