Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6213045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:37:32+00:00 2026-05-24T06:37:32+00:00

From time to time I delete files that I shouldn’t and worst is files

  • 0

From time to time I delete files that I shouldn’t and worst is files that I’ve been writing myself. Therefore I have many times been saved by the backup feature of Emacs.

But my problem is that Emacs only makes a backup the very first time you save a buffer. Is there a way to make Emacs do it every time I press C-x C-s?

This is what my .emacs look like currently (only the part that deals with backups):

;; ===== Backups =====                                                                    

;; Enable backup files.                                                                   
(setq make-backup-files t)

;; Save all backup file in this directory.                                                
(setq backup-directory-alist (quote ((".*" . "~/.emacs_backups/"))))

;; Always backup by copying (safest, but slowest)                                         
(setq backup-by-copying t)

;; Append .~1~ (and increasing numbers) to end of file when saving backup                 
(setq version-control t)

;; Defining how many old versions of a file to keep (starting from the                    
;; most recent and counting backward                                                      
(setq kept-new-versions 100)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T06:37:32+00:00Added an answer on May 24, 2026 at 6:37 am

    After reading this: EmacsWiki: Force Backups

    I added these lines to my .emacs:

    (defun force-backup-of-buffer ()
      (setq buffer-backed-up nil))
    
    (add-hook 'before-save-hook  'force-backup-of-buffer)
    

    It utilizes the standard back up/version control but resets the flag that indicates wether or not the buffer has been backed up this session before a save.

    First two rows define a function that resets the flag that indicates wether the buffer was backed up during this session.

    Last row adds an event hook that executes the function before a save.

    This does exactly what I wanted.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I try to delete files from a directory I specify. The first time it
Is it possible to delete multiple elements from a list at the same time?
From time to time I read that Fortran is or can be faster then
From time to time, a file that I'm interested in is modified by some
When I delete a file from my snapshot view, the next time I look
Many common filesystems do not offer atomic operations, yet writing files in an atomic
I have an application that downloads most of the resources from the internet during
I have noticed that when updating my web content files (in this case, a
I'm writing a hobby project wherein I write to .wav files. I decided that
I have a workflow that moves files around between ftp sites. It can be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.