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

Persistent undo #774

Closed
bandali0 opened this issue Mar 7, 2015 · 66 comments
Closed

Persistent undo #774

bandali0 opened this issue Mar 7, 2015 · 66 comments
Labels
- Forum - Feature request stale marked as a stale issue/pr (usually by a bot)

Comments

@bandali0
Copy link

bandali0 commented Mar 7, 2015

In vim, I can use something like this

set directory=~/.vim/swaps
if exists("&undodir")
    set undodir=~/.vim/undo
endif
set undofile

in my vimrc and have my undo history preserved. So, for instance if I make some changes and save and close vim. If later on I change my mind, I can open vim again, open the file and just undo (u) whatever I had done.

Using spacemacs, if I exit emacs, my undo history will be gone; meaning the next time I open emacs and open the file, pressing u does nothing.

Is there a way to have the undo history preserved, across launches?

@tuhdo
Copy link
Contributor

tuhdo commented Mar 7, 2015

Yes, you can do it by setting undo-tree-auto-save-history variable to true. You can also save/load manually with undo-tree-save-history and undo-tree-load-history.

@syl20bnr
Copy link
Owner

syl20bnr commented Mar 7, 2015

The temp directory is ~/.emacs.d/.cache, the persistent undo was enabled once but has been disabled because some people (and I) reported corrupted undo history. Not sure it is due to persistency, you can try it for yourself.

@bandali0
Copy link
Author

bandali0 commented Mar 7, 2015

@tuhdo That's what I'm looking for, thank you 🍻

@syl20bnr Thanks, that's good to know. I just saw #298.

I've added this

(setq undo-tree-auto-save-history t
         undo-tree-history-directory-alist
         `(("." . ,(concat spacemacs-cache-directory "undo"))))
   (unless (file-exists-p (concat spacemacs-cache-directory "undo"))
(make-directory (concat spacemacs-cache-directory "undo")))

(which is the reverse of 885d092) to my dotspacemacs/config and so far I haven't had issues.

Let's leave this issue open for a while to see if I get corrupted history or not. If everything works well for a week or two, I'll close it.

@syl20bnr
Copy link
Owner

syl20bnr commented Mar 7, 2015

Great ! Thank you for testing this.

@bandali0
Copy link
Author

bandali0 commented Mar 8, 2015

@syl20bnr No worries, thank you for spacemacs :)

@bandali0
Copy link
Author

@syl20bnr It's been 10 days and I haven't had any issues so far.

Although I use emacs regularly, I haven't spent hours editing one single file to see if the history goes corrupt or not. So, that's the last thing I'll try to test this: Soon I'll have to write a lab report. I use emacs for editing TeX, and writing the report would at least take a good couple of hours, so that's my last shot of trying to get a corrupt undo tree.

@syl20bnr
Copy link
Owner

Any news on this ?

@bandali0
Copy link
Author

@syl20bnr I haven't had any undo history corruptions. I think it's safe to add the feature back, or at least make it an option (disabled by default) that one can set in .spacemacs

@ReneFroger
Copy link

Maybe my issue might be related.

If you make a change somewhere, save it, and make a change, then save again, then move your cursor. Press then g;. Are you going back to the correspodenting changed places three in time?

@syl20bnr
Copy link
Owner

That's a nice update on this issue. Thank you ! 👍

@ReneFroger
Copy link

Any news on this, @aminb?

@bandali0
Copy link
Author

bandali0 commented Jun 5, 2015

@ReneFroger When I did g; status bar said "No further change info". 😕

@ReneFroger
Copy link

So it causes a bug. Then it cannot be included in Spacemacs, until we get a update from the authors of Evil, I guess.

@bandali0
Copy link
Author

bandali0 commented Jun 5, 2015

Fair enough :)

@sooheon
Copy link

sooheon commented Jul 9, 2015

FWIW, @ReneFroger's bug may not be caused by this alone, as I'm seeing the bug without this customization.

@Kethku
Copy link
Contributor

Kethku commented Aug 13, 2015

I added @aminb's change and I have been getting a corrupt undo tree message periodically, so as far as I can tell it is still a problem unfortunately. Optionally we could add it back as an optional flag in the init file? I have a hunch that it only happens in some major modes, but I don't really have any evidence for that hunch.

@syl20bnr
Copy link
Owner

Did you work on a source controlled repo ?
I wonder if messing with the buffer content could corrupt the undo tree state.

@Kethku
Copy link
Contributor

Kethku commented Aug 13, 2015

That is very possible. I don't think I ever write text or code in a non git or perforce backed directory, so that could be the issue.

@syl20bnr
Copy link
Owner

Interesting, I'm not sure if the error happened only when I was at work but it happens that I'm using perforce too.

@ReneFroger
Copy link

I don't use perforce or another source controlled repo. Is there any way to get persistent undo and last-changes working?

@qizhihere
Copy link

What about undohist? I just try it, very nice! But i don't know if i will encounter corruptions like in undotree...

@ReneFroger
Copy link

Are you sure that the undo's are persistent after closing and starting Emacs? I tested it, and it didn't worked for me. I use Windows by the way.

@Kethku
Copy link
Contributor

Kethku commented Aug 17, 2015

They aren't currently. You need to manually enable it to get the functionality.

Sent from my Windows Phone


From: ReneFrogermailto:notifications@github.com
Sent: ‎8/‎16/‎2015 12:03 PM
To: syl20bnr/spacemacsmailto:spacemacs@noreply.github.com
Cc: Keith Simmonsmailto:keith@the-simmons.net
Subject: Re: [spacemacs] Persistent undo (#774)

Are you sure that the undo's are persistent after closing and starting Emacs? I tested it, and it didn't worked for me. I use Windows by the way.


Reply to this email directly or view it on GitHubhttps://github.com//issues/774#issuecomment-131603458.

@qizhihere
Copy link

Yes, it is. I use it with desktop-save-mode.

@apirogov
Copy link

I would really love to see reliable persistent undo in spacemacs. In vim a few times it saved me when I messed up a file and could find a version from hours ago after having closed and opened it multiple times in between. Until this bug is hunted down though, I am afraid of enabling the auto-save-history flag after reading this thread here.

@braham-snyder
Copy link
Contributor

Unfortunately, github doesn't have issue voting, but in the meantime I believe giving the original post here a "thumbs up" reaction is the way to go (issues can be sorted by the number of reactions received).

@webavant
Copy link

webavant commented Jan 24, 2017

Undo-tree's auto-saving was working fine for me until I began building emacs from the master development repo. I downgraded to a recent third-party build from master and my seemingly broken .file~undo-tree~ files began working again, despite that they had been problematic only moments before downgrading emacs. Here is a comparison of my configuration :

< In GNU Emacs 26.0.50.2 (x86_64-unknown-linux-gnu, GTK+ Version 3.22.6)
<  of 2017-01-09 built on mbp
< Repository revision: ef8c9f8fc922b615aca91b47820d1f1900fddc96
> In GNU Emacs 26.0.50.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.22.3)
>  of 2016-11-14 built on lilydjwg
> Repository revision: 2f5e0b1bf7b0ac4f450847db34d599a072020600
<  --without-gconf --with-gsettings --with-xwidgets 'CFLAGS=-march=x86-64
<  -mtune=generic -O2 -pipe -fstack-protector-strong'
<  CPPFLAGS=-D_FORTIFY_SOURCE=2
>  --without-gconf --with-gsettings 'CFLAGS=-march=x86-64 -mtune=generic
>  -O2 -pipe -fstack-protector-strong' CPPFLAGS=-D_FORTIFY_SOURCE=2
< GTK3 X11 MODULES XWIDGETS LIBSYSTEMD
> GTK3 X11 MODULES
<   locale-coding-system: utf-8-unix
>   locale-coding-system: utf-8-unix`

(I am not sure what produced the back-tick on the final line)

@webavant
Copy link

webavant commented Jan 24, 2017

You can simplify tests in your environment by setting a few command-line options:

-Q to bypass init.el
-L to load undo-tree.el
--eval to set the undo-tree settings variables

Example:

emacs -Q -L ~/.emacs.d/elpa/undo-tree-* --execute "(progn(require 'undo-tree)(setq undo-tree-auto-save-history t)(global-undo-tree-mode))" /your/problem/file

@therealpxc
Copy link

therealpxc commented Jul 26, 2017

I noticed that a user named @razzius made a little layer for persistent undo in his personal config, based on undohist. I decided to give it a try in my own config, and it seems to at least work. Is anyone else still interested in considering this as a candidate replacement? (Naturally there is more work to do.)

I'll continue using it for a while and report back. If we could hear from @razzius about the tool's functionality and stability (since it has been in his config for about a year now), that would be awesome too. It looks like we haven't heard anything from @CestDiego since the submission of his undohist PR, either.

@razzius
Copy link

razzius commented Jul 28, 2017

@therealpxc It works fine but honestly I restart emacs so infrequently it isn't all that useful to me. Back when I used Vim I would open a new editor every few minutes but in Emacs I keep a single editor server running for days at a time.

There was 1 time when undo glitched but I'm not even sure that was due to undohist.

The other potential downside is dozens of messages about the undo history being discarded due to the file digest not matching on startup, and I presume it's adding to my (already slow) Emacs startup time.

undohist is functional and seems to be the de facto way to persist undo history in Emacs so I think it's a neat feature that could be added but disabled by default.

@noctuid
Copy link

noctuid commented Jul 28, 2017

Lawlist has been working on an undo-tree fork.

@aaronjensen
Copy link
Contributor

Lawlist has been working on an undo-tree fork.

Have you or anyone else successfully integrated this w/ spacemacs? I still don't actually know the proper way to replace a package with a fork.

@braham-snyder
Copy link
Contributor

braham-snyder commented Jul 28, 2017

I still don't actually know the proper way to replace a package with a fork.

I suspect it is or will be https://github.com/emacscollective/borg, but I have yet to try it (I know very little about git submodules)

edit: and/or possibly https://github.com/raxod502/straight.el (like borg, also fairly inchoate)? huge README, but perhaps this section is also relevant: https://github.com/raxod502/straight.el#comparison-to-borg

@sooheon
Copy link

sooheon commented Jul 30, 2017

I tried Borg for a while, but updating across the board was not possible afaict.

@raxod502
Copy link

@sooheon Try straight.el, which is like Borg except that it is a full-featured package manager rather than just a submodule power tool (not saying there is anything wrong with the latter, of course). In particular, M-x straight-pull-all updates all packages.

NB to @braham-snyder: indeed, straight.el is still pre-1.0, but it is likely stable enough to use (as in, it probably doesn't require regular debugging anymore—but feel free to open an issue if you find it does 😜).

@aaronjensen I would assume the correct way to integrate this into Spacemacs is to use Quelpa as that's what Spacemacs uses for its package management. But you could also try straight.el if you want to be adventurous… see radian-software/straight.el#128.

@sooheon
Copy link

sooheon commented Aug 29, 2017

@raxod502 Haven't given straight.el a run yet, but I admire your code documenting philosophy ;)

@diego898
Copy link

just want to see if there is any update on this? persistent undo is a huge issue for me! thanks!

@ReneFroger
Copy link

Which version are you running, @diego898 ?

@diego898
Copy link

Im running:

  • Spacemacs v.0.200.13
  • Emacs 26.1
  • Mac OSX 10.13.6

and I have the following in my ~/.spacemacs:

; Persistent UNDO Tree
;;(setq undo-tree-history-directory-alist '(("." . "~/.emacs.d/undo")))
(setq undo-tree-auto-save-history t
undo-tree-history-directory-alist
`(("." . ,(concat spacemacs-cache-directory "undo"))))
(unless (file-exists-p (concat spacemacs-cache-directory "undo"))
  (make-directory (concat spacemacs-cache-directory "undo")))

@dbrw
Copy link

dbrw commented Oct 9, 2018

Same here, would love to see any update.

@Compro-Prasad
Copy link
Contributor

A new package https://github.com/jackkamm/undo-propose-el has been released and claims to be safer to use than undo-tree.

@github-actions
Copy link

github-actions bot commented Mar 3, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!

@github-actions github-actions bot added the stale marked as a stale issue/pr (usually by a bot) label Mar 3, 2020
@Compro-Prasad
Copy link
Contributor

See http://www.dr-qubit.org/Lost_undo-tree_history.html for further details.

@duianto duianto removed the stale marked as a stale issue/pr (usually by a bot) label Mar 15, 2020
@eugercek
Copy link

@notbandali Thank you so much. Solved my problem.
@braham-snyder +1
I thought it was because I'm using chemacs and files could collapse. For example when you do SPC q R spacemacs/restart-emacs it opens default one in chemacs. Probably simple 'emacs' call but I don't have any idea on elisp. Will learn e(lisp) immediately for tinkering around.

@real-or-random
Copy link
Contributor

There's a PR to evil that (hopefully) fixes the issue but it's stalled unfortunately: emacs-evil/evil#1430

@fleimgruber
Copy link
Contributor

emacs-evil/evil#1430 got merged in the meantime, so this could be tested again.

Copy link

github-actions bot commented May 5, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!

@github-actions github-actions bot added the stale marked as a stale issue/pr (usually by a bot) label May 5, 2024
@github-actions github-actions bot closed this as completed Aug 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- Forum - Feature request stale marked as a stale issue/pr (usually by a bot)
Projects
None yet
Development

No branches or pull requests