Skip to content
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

Highlight currently saved node #57

Closed
josephmturner opened this issue Dec 14, 2022 · 10 comments
Closed

Highlight currently saved node #57

josephmturner opened this issue Dec 14, 2022 · 10 comments

Comments

@josephmturner
Copy link

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

Thank you!!

@ideasman42
Copy link
Contributor

ideasman42 commented Dec 15, 2022

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
Copy link
Author

josephmturner commented Dec 15, 2022 via email

@ideasman42
Copy link
Contributor

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

@josephmturner
Copy link
Author

josephmturner commented Dec 15, 2022 via email

@ideasman42
Copy link
Contributor

@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
Copy link
Author

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

@casouri
Copy link
Owner

casouri commented Dec 16, 2022

@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
Copy link
Contributor

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

@josephmturner
Copy link
Author

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

@jdtsmith
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants