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

Auto-save creates backup #file# after renaming the file #10348

Closed
wolfv6 opened this issue Feb 15, 2018 · 15 comments
Closed

Auto-save creates backup #file# after renaming the file #10348

wolfv6 opened this issue Feb 15, 2018 · 15 comments

Comments

@wolfv6
Copy link

wolfv6 commented Feb 15, 2018

Auto-save creates a backup #file# after renaming the file.

This is in my .spacemacs file, defun dotspacemacs/init () (setq-default :

dotspacemacs-auto-save-file-location 'original

So all saves should be saved to the original file, and NOT saved to an auto-save #file#

Saves are NOT to the original file. This could confuse new Spacemacs users enough to cause them to lose data. Please consider making this issue a High Priority.

This might be related to #7927 #10347 #10327

Reproduction guide 🪲

  1. open file in spacemacs
  2. SPC f R (spacemacs/rename-current-buffer-file) and rename file to file1
  3. edit file1 but do not save it
  4. wait 30 seconds (or SPC SCP do-auto-save) and auto-save creates #file1#
  5. edit file and save

Observed behaviour: 👀 💔
Auto-save #file1# is created.
All saves (SPC f R or auto-save) are to auto-save #file1#.

Expected behaviour: ❤️ 😄
No auto-save #file1# is created.
All saves are to the original file1.

System Info 💻

  • OS: gnu/linux
  • Emacs: 25.3.1
  • Spacemacs: 0.200.10
  • Spacemacs branch: master (rev. 4bb4cb4)
  • Graphic display: t
  • Distribution: spacemacs
  • Editing style: vim
  • Completion: ivy
  • Layers:
(c-c++ emacs-lisp evil-snipe git ivy org shell spell-checking)
  • System configuration features: XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND DBUS GCONF GSETTINGS NOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 MODULES XWIDGETS

Backtrace 🐾

<<BACKTRACE IF RELEVANT>>
@CeleritasCelery
Copy link
Contributor

Setting dotspacemacs-auto-save-file-location 'original just means to create an auto save file in same directory as the original file. If you don’t want an auto-save file created set this value to nil.

@wolfv6
Copy link
Author

wolfv6 commented Feb 17, 2018

@CeleritasCelery
Thanks for looking into this. I am misinterpreting or the documentation is off.
https://github.com/syl20bnr/spacemacs/blob/master/doc/DOCUMENTATION.org#location-of-auto-saved-files says:

Auto-save of modified files can be performed in-place on the original file itself or in the cache directory (in this case the original file will remain unsaved).

My understanding is that dotspacemacs-auto-save-file-location 'cache will auto-save in same directory as the original file, and the original file will remain unsaved.
dotspacemacs-auto-save-file-location 'original will auto-save to the original file itself.

@CeleritasCelery
Copy link
Contributor

dotspacemacs-auto-save-file-location 'original will auto-save to the original file itself.

That would be no different then a regular save.

cache will move all the auto saves to .emacs.d/.cache and original will keep the auto save in the original directory. If you feel that the documentation is unclear submit a PR that clarifies things.

@wolfv6
Copy link
Author

wolfv6 commented Feb 18, 2018

I want a regular save every 30 seconds automatically.
In other words, auto-save modified files to the original file itself.
Is there a way to do that?

@CeleritasCelery
Copy link
Contributor

You could write a function that saves the buffer on a timer. Shouldn’t be too hard. Though the question is, why don’t you want to use the builtin auto save? It’s more flexible because it won’t overwrite your file when you don’t want to.

@wolfv6
Copy link
Author

wolfv6 commented Feb 18, 2018

I want to auto-save to the original file because my Linux desktop crashes often, and it's easier to reboot and just keep going, rather than go through the file-recovery dance.

@CeleritasCelery
Copy link
Contributor

Then you will have to roll your own implementation.

@wolfv6
Copy link
Author

wolfv6 commented Feb 18, 2018

Normally my Spacemacs auto-saves to the original file as described in the documentation.

Reproduction guide :

  1. open file in spacemacs
  2. edit file but do not save it
  3. wait 30 seconds (or SPC SCP do-auto-save)

*Observed behaviour:
The file is auto-saved to the original file itself.
Verified by opening the file in another editor.
The directory time stamp indicates the time of auto-save.

But after SPC f R (spacemacs/rename-current-buffer-file) renaming the file, the auto-save behavior changes to saving to a #file# stored in the same directory (as described at the top of this thread).

I think that change in auto-save behavior is a bug, or a very strange feature.

@CeleritasCelery
Copy link
Contributor

Looks like you were correct about the implementation of original. I misspoke.

@wolfv6
Copy link
Author

wolfv6 commented Feb 18, 2018

@CeleritasCelery thanks for the validation. Losing file edits at seemingly random times was confusing me for weeks before I figured out the pattern.

@ssfrr
Copy link

ssfrr commented Apr 13, 2018

Just to throw out another use case for auto-save on the original file - I sync my org-mode files across different computer using DropBox and the files tend to be actively open on the different machines. I don't always remember to save before I switch computers (e.g. leaving my work computer and going home), so my changes weren't always being propagated between machines and I was getting conflicts.

By auto-saving every 5min things stay better in sync, and by the time I sit at the other computer the changes have propagated to the open buffer (though lock files are still a problem, as in #10347). Maybe there's some other configuration where emacs would do a better job of noticing when an auto-save file is newer than the currently open one, but that wasn't happening.

@dijonkitchen
Copy link
Contributor

dijonkitchen commented Oct 14, 2018

Is there some work-around where we can edit how long it takes to auto-save? That might get us a better feedback loop on if there's an error (e.g., you'd see it in your git status faster).

Or even better, save on focus to another window.

@dijonkitchen
Copy link
Contributor

Found some documentation here: https://github.com/syl20bnr/spacemacs/blob/master/doc/DOCUMENTATION.org#auto-saving

The original PR implementing it might be useful too: #1484

@hyiltiz
Copy link

hyiltiz commented Feb 27, 2020

@wolfv6 Your comment above seem to have resolved the issue; if anything fancy is required, there are packages users can download and configure.

Maybe consider closing this issue?

@wolfv6
Copy link
Author

wolfv6 commented Feb 28, 2020

This is no longer an issue. Solution documented at
https://github.com/syl20bnr/spacemacs/blob/master/doc/DOCUMENTATION.org#location-of-auto-saved-files

@wolfv6 wolfv6 closed this as completed Feb 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants