News for hackers. Stuff that matters.
Re:Resolving the Great Undo-Redo Quandary by rcthompson on Friday November 11, 2022 @08:24AM (#33560542)
This is exactly how undo works in Emacs out of the box. Personally, I prefer to install the undo-tree package and manually browse through the tree of undo paths. I'm not sure why this author finds a tree unacceptable for this purpose.
Re:Resolving the Great Undo-Redo Quandary by rtpg on Friday November 11, 2022 @08:42AM (#33560696)
Because it requires more than two commands
Re:Resolving the Great Undo-Redo Quandary by onedognight on Friday November 11, 2022 @09:20AM (#33561086)
Additionally, emacs will filter undo/redo’s to changes within a region. If you select a region (no new command to learn) and use undo/redo, it will only perform those that affect text completely within the region. This is a superpower that delights me each time use it.
Re:Resolving the Great Undo-Redo Quandary by nickcw on Friday November 11, 2022 @10:29AM (#33562002)
I did not know this, despite having used emacs for > 20 years - thank you!
Re:Resolving the Great Undo-Redo Quandary by randlet on Friday November 11, 2022 @10:37AM (#33562108)
Yes! Having regional undo is super useful sometimes. I switched from emacs to vim a long time ago, but still miss this feature (although not enough to go searching to find an equivalent vim plug in I guess). Lazy web?
Re:Resolving the Great Undo-Redo Quandary by _huayra_ on Friday November 11, 2022 @10:42AM (#33562179)
Well if you want to return to Emacs, I can attest as a former long-time vim user that the emulation layers for vim modes in Emacs are fantastic! They're really the only good part of vim, as the configuration language was always a bit less desirable than elisp, imo.
Re:Resolving the Great Undo-Redo Quandary by randlet on Friday November 11, 2022 @10:53AM (#33562338)
I've tried in past but always found the vim modes to be a bit lacking. My last attempt was probably 6 or 7 years ago though so maybe worth another shot!
Re:Resolving the Great Undo-Redo Quandary by comfypotato on Friday November 11, 2022 @11:00AM (#33562442)
Evil mode is the modern standard I believe. Not a user myself, but I hear good things.
Re:Resolving the Great Undo-Redo Quandary by fiddlerwoaroof on Friday November 11, 2022 @11:52AM (#33563210)
I ported my vim configuration to Evil Mode seven years ago and haven’t looked back. Evil Mode is the best done vi emulation layer I’ve seen and I think it even improves on vim in at least one area (the behavior of `I` in visual line mode).
Re:Resolving the Great Undo-Redo Quandary by _huayra_ on Saturday November 12, 2022 @02:04AM (#33570798)
There is a very opinionated and batteries-included "Vim-y" Emacs called Doom [0]. A decent way to approach this if you don't want to start writing elisp outta the gate to have fancy editor features is to learn enough of the Doom config to tweak it to your liking, then add some elisp customization in as needed. I personally use this approach, usually cribbing config and elisp tweaks from the top contributors' configs.

The Evil layer that Doom and most everyone seems to use for Vim modes works really well, and has a lot of ways to tweak things (e.g. changing `j` to `gj` for going through line breaks in normal mode; I forgot what that setting is called...).

There is something to be said by bootstrapping your config entirely from scratch instead of using a "config framework" like Doom, but that can be too daunting and end up preventing one from trying things out.

[0] https://github.com/doomemacs/doomemacs

Re:Resolving the Great Undo-Redo Quandary by ilyt on Friday November 11, 2022 @02:37PM (#33565670)
I switched from Emacs to IDEA because IDE features are frankly unrivalled but I still think Emacs does the text editing part plainly better
Re:Resolving the Great Undo-Redo Quandary by jerry1979 on Friday November 11, 2022 @12:36PM (#33563873)
Do you know a way to keep the region selected after undoing so as to continually undo within the region?
Re:Resolving the Great Undo-Redo Quandary by db48x on Friday November 11, 2022 @02:15PM (#33565335)
That’s the default behavior; perhaps you have customized something that changed it.
Re:Resolving the Great Undo-Redo Quandary by a_e_k on Friday November 11, 2022 @04:20PM (#33567025)
That region based undo is fantastic and has saved my bacon so many times! I really wish more apps had it, though I shudder to think of the implementation complexity.
Re:Resolving the Great Undo-Redo Quandary by gpvos on Friday November 11, 2022 @09:21AM (#33561104)
And it is exactly why I find Emacs undo so hard to work with. But maybe I will get it now I've read this article.
Re:Resolving the Great Undo-Redo Quandary by tmtvl on Friday November 11, 2022 @09:37AM (#33561299)
You can, if you like, install the 'vundo' package, which gives you a tree-based overview of your undo history, making it easy to switch between branches and go backward and forward. It's basically like the undo-tree view for the default undo mechanism.
Re:Resolving the Great Undo-Redo Quandary by b3morales on Friday November 11, 2022 @01:02PM (#33564287)
Two suggestions that might make it easier for you. There's a package called `undo-fu` that puts a thin layer on top of the undo system to keep the behavior strictly linear.

And built in, there are the `undo-only` and `undo-redo` commands. Unlike the base `undo` they will only walk in one direction.

Re:Resolving the Great Undo-Redo Quandary by BeetleB on Friday November 11, 2022 @01:11PM (#33564438)
Note that Emacs undo is not tree based, but works as described in the article. The tree based undo is a separate package one has to install.
Re:Resolving the Great Undo-Redo Quandary by gpvos on Friday November 11, 2022 @07:54PM (#33568815)
As I wrote.
Re:Resolving the Great Undo-Redo Quandary by jonathannerat on Friday November 11, 2022 @02:18PM (#33565375)
See `:h undo-persistance` for that feature. In particular you want to do `set undofile` in your vim config
Re:Resolving the Great Undo-Redo Quandary by gpvos on Friday November 11, 2022 @08:02PM (#33568864)
I'm not sure how you deduced that I'm actually a vi user, but it's interesting to see that vim has similar support but using separate linear undo and redo commands g- and g+ . undo-persistance and undofile seem to be orthogonal to that though, I'm even less sure why you're bringing that up.
Re:Resolving the Great Undo-Redo Quandary by sulam on Friday November 11, 2022 @09:27AM (#33561173)
He literally says why at the top of the post. People find it too complicated.
Re:Resolving the Great Undo-Redo Quandary by taeric on Friday November 11, 2022 @10:53AM (#33562350)
I confess I didn't get that the post was about emacs. Reading the intro, it sounds more like it assumes nobody ever implemented something. And then goes on to describe what sounds a lot like how emacs works.
Re:Resolving the Great Undo-Redo Quandary by db48x on Friday November 11, 2022 @02:17PM (#33565364)
That’s the impression I got as well, since it never mentions Emacs at all and then describes exactly how Emacs works.
Re:Resolving the Great Undo-Redo Quandary by 0xCMP on Friday November 11, 2022 @12:27PM (#33563739)
No, he says most people do not actually implement the interface to make it make sense. So they have to make ctrl-z and ctrl-shift-z do the logical linear thing which requires all sorts of craziness which is what is complicated to do correctly (e.g. without breaking user expectations).
Re:Resolving the Great Undo-Redo Quandary by fuckstick on Friday November 11, 2022 @01:30PM (#33564721)
No they don’t. The method they are praising is already the base implementation for emacs.
Re:Resolving the Great Undo-Redo Quandary by Chris2048 on Friday November 11, 2022 @09:34AM (#33561257)
Sounds like this solution would best be implemented with an undo-tree, but also a linear history mapping with pointers to that tree - the linear history would just log movement within the tree over time e.g. undo-redo would just be a backwards-forwards movement.
Re:Resolving the Great Undo-Redo Quandary by rcthompson on Friday November 11, 2022 @09:36AM (#33561292)
That's exactly what you get with undo-tree. The regular undo/redo commands continue working as normal, but you can also manually browse the tree if things get too nonlinear for you.
Re:Resolving the Great Undo-Redo Quandary by Chris2048 on Friday November 11, 2022 @10:18AM (#33561852)
The one I saw had you browsing the tree, rather than a linear history representation of a tree.
Re:Resolving the Great Undo-Redo Quandary by wging on Friday November 11, 2022 @01:25PM (#33564641)
Yeah, I spent a long while (years) using pretty much exactly the solution he describes, as implemented in emacs. It's not as good as a tree, because undo/redo cycles make it very annoying to traverse through the history. I greatly prefer undo-tree.
Re:Resolving the Great Undo-Redo Quandary by marcinreal on Friday November 11, 2022 @03:14PM (#33566196)
Make sure to check the value of `undo-limit`, as the low default value greatly (and needlessly, on modern machines) nerfs undo. It also applies to extensions like undo-tree and vundo I believe.

> undo-limit is a variable defined in ‘C source code’.

> Its value is 10000000

> Original value was 160000

Speaking of extensions, I find undo-tree pretty buggy. I might be one of a dozen people who actually love the default undo/redo mechanism.