0

I just want to erase history here - the very last entry. This shouldn't be dangerous, right?

I figured I need to somehow transform (undo-tree-current buffer-undo-tree) and pass that to undo-tree-snip-node but I don't see exactly how to do that.

user3496846
  • 378
  • 1
  • 10
  • Do you want to undo your last entry and return to your previous state and *then* erase that last entry; or, do you want to keep your current state and tell undo-tree to just forget about how you got there? Inasmuch as undo-tree just creates a new branch when you undo and then go somewhere else, why (if you don't mind explaining) would you want to erase the last entry (e.g., a use case example)? – lawlist Jun 08 '20 at 17:49
  • @lawlist I just want to forget how I got to that state. I am making an evil motion for paredit-kill. The way I do it is do the kill, then paste the killed text where it was, pop the kill ring, save the (point) for use as a motion. For simplicity, I set a handle to (prepare-change-group) before these and do (undo-amalgamate-change-group handle) afterwards so that I have just one unnecessary undo event. I tried to use undo-tree-undo, but that doesn't play well with evil - it cancels the operator which was pressed before the motion (like d). – user3496846 Jun 08 '20 at 18:24
  • 1
    Other than Dr. Cubitt (the author of `undo-tree.el`), a regular forum participant named Tobias is probably the most familiar with the data structure of the `buffer-undo-tree` of the `undo-tree.el` library. One idea would be to save a copy of the list using `copy-tree*` (in the following link) before doing your stuff and then restore the list when you finish: https://emacs.stackexchange.com/a/32230/2287 Off hand, I do not know how to just snip off the last entry -- but, perhaps Tobias or another forum participant does ... or they can suggest an alternative approach that best suits your needs. – lawlist Jun 09 '20 at 04:23
  • @lawlist Oh, man. I think I will just rewrite the paredit-kill instead, looks like less trouble after all. But thanks for the directions and the link! – user3496846 Jun 09 '20 at 09:51

0 Answers0