News for hackers. Stuff that matters.
Re:Why is it so hard to see code from 5 minutes ago? by im3w1l on Friday February 19, 2021 @03:35AM (#26190898)
> Emacs similarly doesn't lose changes in this scenario, but instead of making a tree, it has a ring and undo is an action that can be undone.

Emacs default undo system is really, really bad. Like worse than the "standard" one. But after installing the emacs undotree it becomes sane.

Re:Why is it so hard to see code from 5 minutes ago? by b3n on Friday February 19, 2021 @05:39AM (#26191601)
What is bad about it? It always goes back to the previous state, and if you want to skip previous undo states (so you don't undo an undo) you can use `M-x undo-only`.
Re:Why is it so hard to see code from 5 minutes ago? by im3w1l on Friday February 19, 2021 @07:00AM (#26192188)
It's been over a decade since my bad experience so take my words with a grain of salt. Iirc, the issues I had was that I made a huge history of undos-followed-by-redos-followed by-undos-etc etc and the more I navigated my history the more tangled and out of control it became. I think I also had a problem with often accidentally switching from undo to redo mode. Emacs documentation recommends using C-f (forward-character) to switch to redo mode, but in my opinion attaching side effect to movement is awful.
Re:Why is it so hard to see code from 5 minutes ago? by jolmg on Friday February 19, 2021 @11:28AM (#26194784)
I agree. It's cool that it's lossless, but doing a lot of undos and redos makes the history quickly unwieldy to navigate. I much prefer vim's tree implementation.

I wouldn't say that it's worse than the standard, though. Unwieldy as it may be, I like that I can just keep on pressing C-/ and eventually get to the state I want without risk that I may have lost it because I accidentally made a change after a series of undos.

> Emacs documentation recommends using C-f (forward-character) to switch to redo mode, but in my opinion attaching side effect to movement is awful.

I use C-g (keyboard-quit) for that, which is the general let's-not-do-this-anymore keybinding. I think the documentation mentions C-f as an example keybinding that does the needful without much thought on being the "best" keybinding for it.

Re:Why is it so hard to see code from 5 minutes ago? by b3n on Friday February 19, 2021 @05:56PM (#26199135)
> doing a lot of undos and redos makes the history quickly unwieldy to navigate

Are you aware of the `undo-only` (and `undo-redo`) functions? They make it a breeze to navigate even the most complex undo history.

Re:Why is it so hard to see code from 5 minutes ago? by jolmg on Friday February 19, 2021 @07:37PM (#26200067)
Actually, I wasn't. Thanks for that.

(undo-redo) doesn't seem to be defined in stock Emacs, but undo-tree defines (undo-tree-redo), which does the needful.

My comment was more about lamenting the defaults in comparison with vim's, but it's true that it doesn't take much configuration to make it much better.

Re:Why is it so hard to see code from 5 minutes ago? by im3w1l on Saturday February 20, 2021 @03:56AM (#26202762)
undo-only doesn't have a keybind which makes it inconvient to use many times in a row. You could define one yourself I suppose, but at that point why not just get undo-tree?
Re:Why is it so hard to see code from 5 minutes ago? by im3w1l on Saturday February 20, 2021 @03:58AM (#26202774)
The issue I have is that I want to be able to use C-f and C-g and many others without it changing anything about my history.