0

I've set some variables (kept-new-versions, for one) to a higher number (10, it was 2) since I don't mind having a handful of backup files in my dir.

I did it using C-h v and customizing the variable. They get written into the .emacs file, but after restarting the program, they are at their previous values (2,2).

I have noticed the message "kept-new-versions is a variable defined in `files.el'." and I wonder, whether this is overriding my .emacs settings. Otherwise, I have no idea what it could be.

What I have in my .emacs:

 '(version-control t)     ;; Use version numbers for backups.
 '(kept-new-versions 10)  ;; Number of newest versions to keep.
 '(kept-old-versions 0)   ;; Number of oldest versions to keep.
 '(delete-old-versions t) ;; Don't ask to delete excess backup versions.
 '(backup-by-copying t)  ;; Copy all files, don't rename them.

I expect this to create a backup file after each save, but not more than 10 of them.

  • 1
    Can you confirm whether the quoted settings are within a (custom-set-variables ...) form? – phils Apr 22 '18 at 22:45
  • @phils: yes, they are. But problem is solved, using answer below. – Quora Feans Apr 23 '18 at 16:27
  • That suggests to me that something is wrong with your config. One possibility is that you've told Emacs to write customized values to a separate custom-file, but that you're not loading that file in your .emacs. Or perhaps an error is occurring on start-up before your custom-set-variables is processed. In any case, I suspect the root cause of your problem is still in effect. – phils Apr 23 '18 at 21:24
2

To set variables in Emacs use:

(setq version-control t)     ;; Use version numbers for backups.
(setq kept-new-versions 10)  ;; Number of newest versions to keep.
(setq kept-old-versions 0)   ;; Number of oldest versions to keep.
(setq delete-old-versions t) ;; Don't ask to delete excess backup versions.
(setq backup-by-copying t)  ;; Copy all files, don't rename them.

You can also setq multiple variables, as in

(setq version-control t
      kept-new-versions 10)

For more info see the documentation here.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.