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

Create `backup' layer to enable auto backup behavior in spacemacs #11903

Closed

Conversation

@igor-kupczynski
Copy link
Contributor

@igor-kupczynski igor-kupczynski commented Jan 27, 2019

Create backup layer to enable auto backup behavior in spacemacs

Related to #8947

Note: my first PR against spacemacs, happy to learn why this change sucks and how I can it

This layer adds support for automatic backups.

Emacs default behavior is to backup a file first time it is saved. This behavior results in a lot of #file_name.ext# files being automatically created. Many people find this annoying and spacemacs turns the auto backup off.

This layer re-enables and extends the automatic backups.

Features:

per-session backups

Similar to emacs default behavior, make a backup first time it is saved from emacs session.

per-save backups

Make a backup every time file is saved.

better defaults

Do not clutter working directories with the backups:

  • Store per-session backup in ~/.emacs.d/.cache/backups/per-session (customize variable backup-per-session-directory to override).
  • Store per-save backup in ~/.emacs.d/.cache/backups/per-save (customize variable backup-per-save-directory to override).

Sane defaults for the backup files:

  • Backup files under version control.
  • Keep the last 10 per-save backups and last 3 per-session backups.
  • Backup by copying.

Install

To use this configuration layer, add it to your ~/.spacemacs. You will need to add backup to the existing dotspacemacs-configuration-layers list in this file.

Acknowledgments

Inner workings of this layer is based on description by @GregorySchwartz in #8947. Which is in turn inspired by a StackOverflow discussion on the subject.

@igor-kupczynski igor-kupczynski mentioned this pull request Jan 27, 2019
@igor-kupczynski igor-kupczynski force-pushed the igor-kupczynski:backup-layer branch from eccaff0 to e981551 Jan 27, 2019
@igor-kupczynski
Copy link
Contributor Author

@igor-kupczynski igor-kupczynski commented Feb 6, 2019

Hey, anything I can do to get this accepted? I think it makes sense to have the backup as its own layer. It doesn't add any packages, but layers are described more as a set of features than package groups. I think this offers a new feature (backup per each write, not only per the first write of a file during a session). Judging by the linked issue (and stack overflow discussion), I think this is useful for more than just me.

@igor-kupczynski igor-kupczynski force-pushed the igor-kupczynski:backup-layer branch from e981551 to 6a089a0 Feb 9, 2019
@igor-kupczynski igor-kupczynski force-pushed the igor-kupczynski:backup-layer branch from 6a089a0 to 6a16cbf Feb 19, 2019
@sdwolfz sdwolfz added this to the Future Release 0.301.0 milestone Mar 4, 2019
@igor-kupczynski igor-kupczynski force-pushed the igor-kupczynski:backup-layer branch from 6a16cbf to 3810953 Mar 31, 2019
@robbyoconnor
Copy link
Contributor

@robbyoconnor robbyoconnor commented Apr 24, 2019

w00t w00t

@duianto
Copy link
Collaborator

@duianto duianto commented Apr 25, 2019

Issue

Saving a new buffer doesn't create any backup files (per-save or per-session).

  • Open a new buffer SPC b N n
  • Adding some text
  • Save SPC f s

If it's modified again and saved, then both backup files are created.

Question

Should .emacs.d\.cache\recentf be excluded from being backed up?
It's saved automatically when Spacemacs:

  • Is idle for 10 minutes
  • Is restarted/closed

Update:
.emacs.d\.cache\.custom-settings is also being backed up. I don't know if it should or not.

Maybe .cache files don't need to backed up?

System Info 💻

  • OS: windows-nt
  • Emacs: 26.2
  • Spacemacs: 0.300.0
  • Spacemacs branch: develop (rev. a097fb79f)
  • Graphic display: t
  • Distribution: spacemacs
  • Editing style: vim
  • Completion: helm
  • Layers:
(autohotkey backup emacs-lisp git helm javascript multiple-cursors org spell-checking treemacs typescript version-control)
  • System configuration features: XPM JPEG TIFF GIF PNG RSVG SOUND NOTIFY ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS THREADS LCMS2
@bb2020
Copy link
Contributor

@bb2020 bb2020 commented Apr 28, 2019

I think it should also cover auto-save feature and include dotspacemacs-auto-save-file-location option from template.

@hyiltiz
Copy link

@hyiltiz hyiltiz commented Mar 7, 2020

Has this been merged yet? If not, what's blocking it? A sensible and out-of-the-box support is a must for any editor used as the daily drive. It is a shape Spacemacs doesn't do this already...

@github-actions
Copy link

@github-actions github-actions bot commented Mar 7, 2021

This PR 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 PR is still need merging!

@github-actions github-actions bot added the stale label Mar 7, 2021
@igor-kupczynski
Copy link
Contributor Author

@igor-kupczynski igor-kupczynski commented Mar 25, 2021

Given it received little traction for the last 2y and I don't use spacemacs [at least for now] I won't be able to drive this towards a conclusion. I'm closing this one.

@ColeWunderlich
Copy link

@ColeWunderlich ColeWunderlich commented May 10, 2021

I would definitely like this included but don't know enough lisp to help (just trying to add my vote). Totally understand if @igor-kupczynski is no longer interested due to no longer using spacemacs.

@robbyoconnor
Copy link
Contributor

@robbyoconnor robbyoconnor commented May 10, 2021

@ColeWunderlich I learned emacs lisp helping to get Spacemacs to where I needed it to work. It's possible to do it -- luckily a lot of example syntax exists in Spacemacs so you're never doing anything that has not been written prior. Use other layers as examples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

7 participants