reddit / emacs

undo-hl: highlight to-be-deleted text before undo operation happens

casouri · 2022-03-23 21:47
casouri · 2022-03-23 21:52
Sometimes in a long undo chain where Emacs jumps to a far away position, I can’t tell whether the undo operation just moved to this position or it has also deleted some text. If I try to redo to see the before-state of that area, Emacs jumps back to the previous location, so I have no way of seeing that area before undo is done! That is so annoying! This package is meant to alleviate that problem: it flashes the to-be-deleted text before deleting so I know what is happening. I tried highlight-changes-mode, but it only places a mark indicating there is a deletion, and I still cannot tell what was deleted. [https://github.com/casouri/undo-hl](https://github.com/casouri/undo-hl)
Dj_Optimus_Rhyme · 2022-03-23 22:18
See also `undo-tree` Wiki: https://www.emacswiki.org/emacs/UndoTree#h5o-1 ELPA: https://elpa.gnu.org/packages/undo-tree.html Repo: https://gitlab.com/tsc25/undo-tree
elimik31 · 2022-03-23 23:11
Thanks, very useful, I think I will use it. This reminds me of [evil-goggles](https://github.com/edkolev/evil-goggles), which highlights an evil-text-object before e.g. deleting it, but for undo. I'm aware of `undo-tree`, but moved to the more minimalistic [undo-fu](https://gitlab.com/ideasman42/emacs-undo-fu), which just uses the built-in emacs undo system instead of replacing it. And this package is a nice complement and awesome that it's non-blocking. Feature request: It would be nice to have the duration of the highlight when undoing customizable via a `defcustom`.
agumonkey · 2022-03-23 23:16
The transient overlay thing may be worth being used in many places (if not all core) I think it's mentally very useful / ergonomic.
putainrespectueuse · 2022-03-24 00:23
god bless this package i get stuck in so many undo-then-undo-the-undo loops
Alby407 · 2022-03-24 00:41
What is the font you are using? :)
casouri · 2022-03-24 00:41
Yes, but actually yes.
casouri · 2022-03-24 00:44
IBM Plex mono
casouri · 2022-03-24 00:44
Right?!
by_wicker · 2022-03-24 01:14
I kept getting lockups from undo-tree. Every now and then I'd have to kill my Emacs and purge its (Edit: undo-tree's) files before I could start it. Since it was about as common as me actually using undo-tree I dropped it. Am I alone in having had problems? These days I tend to be frequent with strategic staging and committing and don't especially feel the need, though when it was useful, it was certainly useful.
by_wicker · 2022-03-24 01:16
This is a good point - I saw this and thought it was cute but not compelling from the gif of contiguous changes, but in reality changes are usually scattered around and it would be very useful. ... off to install, thanks!
Dj_Optimus_Rhyme · 2022-03-24 01:47
Do you have `undo-tree-auto-save-history` enabled? I noticed lockups in `undo-tree` with it enabled whenever the history file gets big enough. Deleting the history file (yeah not the greatest solution lol) always restores performance.
ndamee · 2022-03-24 06:30
See also: https://reddit.com/r/emacs/comments/mgkbsk/complex_undo_local_history_gif_demo_inside/
catern · 2022-03-24 12:45
I always had the same issue. Since Emacs 28 has a new undo system with an explicit "redo" command (undo-redo), I've just stopped using undo-tree.
by_wicker · 2022-03-24 13:14
I did have auto-save set, yes. Deleting the history was how I got out of it, but finding out that was the problem was a significant debugging challenge. My Emacs would just fail to launch, leaving a blocked process. I'm can't remember how I finally diagnosed it and deleted the history and got going again, but I remember I had real work to do and was dead in the water for quite a while.
mrolivertaylor · 2022-03-24 21:58
Between this and [vundo](https://github.com/casouri/vundo) you're my undo hero!
ideasman_42 · 2022-03-24 22:27
> i get stuck in so many undo-then-undo-the-undo loops Try [undo-fu](https://gitlab.com/ideasman42/emacs-undo-fu) it was written to address exactly this problem.
jumper047 · 2022-03-25 22:45
In addition to already mentioned evil-goggles package there is also [goggles](https://github.com/minad/goggles) which is it's non-evil version. It works as on OP's video, but also supports other commands like "delete line" etc
casouri · 2022-03-25 23:07
I want to highlight the deleted text before they are deleted. Small difference, but that's kind of the whole point of undo-hl.
Shivalicious · 2022-03-30 10:52
evil-goggles is great. Thanks for the link!