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

Seems to wreck undo history #15

Open
raxod502 opened this issue May 8, 2020 · 4 comments
Open

Seems to wreck undo history #15

raxod502 opened this issue May 8, 2020 · 4 comments

Comments

@raxod502
Copy link
Member

raxod502 commented May 8, 2020

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

@hlissner
Copy link

hlissner commented May 21, 2020

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

@raxod502
Copy link
Member Author

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 :)

raxod502 added a commit that referenced this issue May 26, 2020
This reverts commit 621351b. It made
it impossible to undo reformatting operations.
@raxod502
Copy link
Member Author

I must have done something wrong with the implementation, since this change made it impossible to undo reformatting operations.

@tecosaur
Copy link

tecosaur commented Feb 22, 2023

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.

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

Successfully merging a pull request may close this issue.

3 participants