unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* How to end text-insert undo segment after cursor jump (caused by mouse)?
@ 2020-10-17 17:35 David
  2020-10-17 22:34 ` Stefan Monnier
  0 siblings, 1 reply; 3+ messages in thread
From: David @ 2020-10-17 17:35 UTC (permalink / raw)
  To: help-gnu-emacs

Hello

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

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?


Yours sincerely

    David

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




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How to end text-insert undo segment after cursor jump (caused by mouse)?
  2020-10-17 17:35 How to end text-insert undo segment after cursor jump (caused by mouse)? David
@ 2020-10-17 22:34 ` Stefan Monnier
  2020-10-19 21:00   ` How to end text-insert undo segment after cursor jump (caused by mouse)? [SOLVED] David
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Monnier @ 2020-10-17 22:34 UTC (permalink / raw)
  To: help-gnu-emacs

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


        Stefan




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How to end text-insert undo segment after cursor jump (caused by mouse)? [SOLVED]
  2020-10-17 22:34 ` Stefan Monnier
@ 2020-10-19 21:00   ` David
  0 siblings, 0 replies; 3+ messages in thread
From: David @ 2020-10-19 21:00 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: help-gnu-emacs

Hey Stefan, thanks for your help!

You were absolutely right, the issue was caused by evil layer. Your 
solution to set evil-want-fine-undo worked perfectly!

I went to emacs customization interface for this variable, I set it to 
Yes (non-nil) and clicked "Apply and Save" and voila, from that moment 
on 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.

Thanks again and have a great day,

David

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



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-10-19 21:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-17 17:35 How to end text-insert undo segment after cursor jump (caused by mouse)? David
2020-10-17 22:34 ` Stefan Monnier
2020-10-19 21:00   ` How to end text-insert undo segment after cursor jump (caused by mouse)? [SOLVED] David

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).