1

After using undo-tree-visualize and going back to some previous state, I wanna return back to final state (i.e., no undo) with my cursor staying at the position at that previous state. Is it possible? I tried to use save-excursion as follow, but it doesn't work:

(defun undo-tree-visualizer-abort-keeping-cursor-position ()
  (interactive)
  (save-excursion (undo-tree-visualizer-abort)))
  • When a user contemplates going back to a previous state and then decides to abandon that choice, there is no guarantee that the point at the previous state still exists. If the point at the previous state does exist, there is no guarantee that it will coincide with the location the user desires when that contemplated undo is aborted. One idea would be to mark your position at the contemplated undo and then abort; and, then go back to the mark and see if it is where you actually want to be. – lawlist Dec 30 '18 at 16:17
  • That's true, thanks. – AhLeung Dec 31 '18 at 6:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.