casouri / vundo

Visualize the undo tree.
413 stars 20 forks source link

Highlight currently saved node #57

Closed josephmturner closed 1 year ago

josephmturner commented 1 year ago

What would it take to highlight the currently saved node in the vundo-mode buffer?

Thank you!!

ideasman42 commented 1 year ago

This shouldn't be difficult to implement (although I'd make it optional as I think it would require a hook that runs on save). I might have a go when I get some time - if someone else doesn't get their first.

josephmturner commented 1 year ago

Wonderful!! Thank you!!!

Campbell Barton @.***> writes:

This shouldn't be difficult to implement. I might have a go when I get some time - if someone else doesn't get their first.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.

ideasman42 commented 1 year ago

@casouri this is how I'd implement this feature, if you have concerns - let me know.

Add an custom option (... show-saved-state or similar), to enable the functionality, when enabled:

josephmturner commented 1 year ago

Another possible feature that could go along with this is the ability to save the buffer at the current node without exiting the vundo buffer. That way, you can save the buffer and continue to explore the undo history.

ideasman42 commented 1 year ago

@josephmturner agree, although I think it's mostly unrelated to this proposal, a few times I've wanted to save while the vundo buffer was active and accidentally saved the vundo buffer it's self.

josephmturner commented 1 year ago

@ideasman42 You're right, that should be a separate issue: #58

casouri commented 1 year ago

@casouri this is how I'd implement this feature, if you have concerns - let me know.

Add an custom option (... show-saved-state or similar), to enable the functionality, when enabled:

  • Add a face to use for the saved undo state.
  • Add a hook to file save that stores the current undo state in a buffer local variable.
  • The undo step would be wrapped in a hash containing a single weak-referenced key, so as not to hold undo data the undo system would otherwise free.
  • Drawing vundo used the saved face to draw the saved undo step (if it's found & has not been freed).

Sounds good. I'll add that you want to save the non-undo record, because vundo could prune undo and redo records. You can find the non-undo record with undo-equiv-table. Also, vundo ignores position records in the undo tree, so when you save the state (I assume you are saving the head of the undo-list), you want to go back to the first non-position records. (See the last paragraph of the comment in the Developer section of vundo.el.)

jdtsmith commented 1 year ago

We implemented past (and current) saved node highlighting using the timestamp data in the undo stream itself; see #62 (but also #66).

josephmturner commented 1 year ago

@jdtsmith @casouri Thank you for adding this feature!!

jdtsmith commented 1 year ago

You're welcome. It scratched a personal itch; only afterwards did I see others had the same!