help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: undo custom delete


From: rgb
Subject: Re: undo custom delete
Date: 5 Oct 2005 07:23:18 -0700
User-agent: G2/0.2

> but this does raise another question... is there a way to undo deletion
> of a complete word in the same way that undo would undo the typing of a
> complete word? surely it must be do-able, the logic being something
> recursive like "if (last action was delete char) and (char not
> whitespace), then (undo last action) and (repeat this loop), else
> (break)".

The only possibility is to change how undo elements appear on
buffer-undo-list. Since undoing an insert involves deleting the
inserted character the undo list doesn't record what character
was inserted.  Only when you delete something does the original
content need to be saved so it can be re-inserted during undo.
So a special-undo could not tell when to stop undoing unless it
looked at the buffer contents at the point where undo list says
delete something.
Hmm, so it could tell...  Anyway...
Undo normally undoes elements on the list until it reaches a
undo-boundary element.  A nil.
You could create a pre command hook or remap word constituent
characters to an intermediate function.  Either way the
function would decide if it wanted to remove the car of
buffer-undo-list (if it's an undo-boundary element (nil)).
This has the effect of making the next action belong to the
previous group of keystrokes and all will be undone at once.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]