-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Highlighting nodes of saves - extend? #72
Comments
No, it does not require saving via vundo (or even undoing via vundo) to work, since undo itself encodes "undo modified a saved buffer state" timestamps into the undo stream. Are you working from the git master branch, or an ELPA version? |
JD Smith ***@***.***> writes:
No, it does not require saving via vundo (or even undoing via vundo)
to work, since undo itself encodes "undo modified a saved buffer
state" timestamps into the undo stream. Are you working from the git
master branch, or an ELPA version?
Interesting. I am using the current version 2.1.0 from Gnu Elpa.
How does vundo normally know/notice when a buffer (state) has been
saved?
|
Oh my! The issue is gone. And I think the reason was that I had some older version in my load-path that just shadowed the elpa package. I'm sorry for this distraction. |
OK. There are a few kinks to work out but it mostly works well. Vundo knows about saved states because the undo system itself injects timestamps into the buffer-undo-list list whenever it's modifying a saved buffer state. This is how it's able to reset the buffer modified status when you "return" to a former saved buffer. |
Yes, it works very well indeed! So I only have some small text improvement suggestions for you does it work when I just paste it here?
The only vundo related thing I feeled I could experiment with so far was to support the following: I hit a key and get a buffer copy of the current buffer in the window above the current one. It is not an indirect buffer but it shares a copy of If you are interested in the idea I can post the code, dunno if it could be useful for others. Thanks, Michael. |
@casouri take a look at the typos. For your clone buffer idea, you can leave the vundo buffer open and eventually hit |
JD Smith ***@***.***> writes:
For your clone buffer idea, you can leave the vundo buffer open and
eventually hit q to cancel any changes. Also remember that undo save
everything.
Sure. But when the history gets large and there are lots of changes, I
might need to copy a former state to a different temporary buffer so
that I can choose which parts I want to restore (reintroduce) and which
not.
Then finding the way back with vundo to the original "HEAD" (undo state)
is not trivial in a large undo date tree. That's the problem I want to
avoid. Is there a solution for this: get back to the last
undo-state after vundo had been left? That would be a nice feature.
It's not easy to implement my original idea btw: AFAIU I have to create
copies of `buffer-undo-list', `undo-equiv-table' and `pending-undo-list'
with markers treated, but leaving shared structures intact
(overarching!). Although I thought I have done that correctly the
`undo-equiv-table' related part doesn't work correctly.
|
How? By simply copying those parts over into place? If that's the case, then just create a temp buffer, copy whatever you need to it from older buffer states, hit
Sure it is: |
JD Smith ***@***.***> writes:
[...] then just create a temp buffer, copy whatever you need to it
from older buffer states, hit q, and put them in place.
So - it is save to leave the vundo buffer and just do something else?
Even when I accidentally edit the base buffer?
Sure it is: q! Also see #56 where I threw together simple diff functionality. This
could be expanded on to include mark-and-act diff (i.e. diff between two specified
nodes). And then you could apply the accumulated diffs to another state of the
same buffer, e.g. using ediff-patch-buffer.
This is definitely useful. I am not yet sure how my favorite interface
would look like.
|
It feels like clone-buffer is all you need (it duplicates the undo history), or I'm missing something? |
Yuan Fu ***@***.***> writes:
It feels like clone-buffer is all you need (it duplicates the undo
history), or I'm missing something?
The questions are whether it is reliable, and whether it is save.
The `buffer-undo-list' contains entries with markers pointing to the
original buffer. The cloned buffers gets the value of buffer-undo-list
- with the markers then pointing to the other buffer.
Second: the values of `buffer-undo-list' in the original buffer and in
the clone share the same list structure (references to the same list
objects). Changes in one buffer might mess up the undo history in the
other.
I don't know how problematic these things are in practice.
|
Yes, it is safe. A "rollback" node is saved as a local variable when vundo starts. |
JD Smith ***@***.***> writes:
Yes, it is safe. A "rollback" node is saved as a local variable when
vundo starts. q takes you back to it.
I see. Is it save to save these node indices (seems they are just
integers) to allow to return to a node later (I mean explictly, a
node I choose).
I can code that by myself, but I want to be sure that the association
undo-state <-> vundo-node-index does never change.
(Background is: I want to allow to save buffer undo states in registers
- as a reference, not just the buffer text. That's not trivial with
only standard undo, but the vundo index seems to provide what I want.
|
Not super safe. If you generate too much undo records, and undo list exceeds undo limit, Emacs will delete the earliest undo records, then the index would be shifted and the number wouldn't point to the intended node. |
@michael-heerdegen you can check #81 which enables moving |
Thanks, will try it out. |
Works wonderful - thank you. Bound those new commands to shift-left and shift-right. For some reason my brain expects that repeating |
Those are interesting bindings. The latest saved state is only "saved" if the associated buffer is saved to file and unmodified. Or do you just mean "before falling off the end, go to the end"? |
I mean that I would want that |
OK will look at adding that. We need to solve (or decide to ignore) some timestamp lossage issues when you navigate back, save a node, then branch from there or navigate away. Let me know if you experience this. |
Hello,
to get the nodes corresponding to saves highlighted - do I have to save from the vundo buffer to get this?
Because I am using
vundo-highlight-saved-nodes
-> t I and never saw such highlights. Would you consider to allow to get the highlights when the user is saving normally?I made it work in my config, but I had to duplicate a lot of quite internal vundo code. It would be nice if you could factor out a function that does the job. So that one could use it in or as an advice of
save-buffer
. Would that make sense?TIA - Michael.
The text was updated successfully, but these errors were encountered: