apheleia
apheleia copied to clipboard
Seems to wreck undo history
When a lot of formatting is going on I seem to lose the ability to undo back very far. This is extremely bad for UX. Probably a consequence of undo-limit and the reformatting generating large volumes of undo data (not sure why).
Taking a page out of evil's evil-with-single-undo macro, how about wrapping apheleia--apply-rcs-patch in something like this?
(unwind-protect
(progn
(when (car-safe buffer-undo-list)
(undo-boundary))
(let (buffer-undo-list)
...))
(when (car-safe buffer-undo-list)
(undo-boundary)))
Thanks for the great tip! I pushed a commit that incorporates this and some related code, we'll see if it seems to have fixed the problem I guess :)
I must have done something wrong with the implementation, since this change made it impossible to undo reformatting operations.
I recently created a little major mode where I wanted to ensure some modifications were registered as a single undo, perhaps it could help here?
(let ((marker (prepare-change-group)))
(unwind-protect
(save-excursion
...) ;; Do all sorts of stuff)
(undo-amalgamate-change-group marker)))
Edit: I see that #17 seems to have looked at this approach, but perhaps it's worth revisiting now that Emacs 26 is the minimum? Even though it doesn't alleviate the "large undo entry" problem, it seems like making sure the formatting is recorded as a single undo step this way could be worthwhile.