This question is inspired by https://emacs.stackexchange.com/a/7831/ and the below settings borrowed from that answer :
(setq backup-directory-alist '(("." . "~/emacs-backups")) version-control 'numbered make-backup-files t delete-old-versions 'never)
I am wondering if it would be possible that emacs keeps an unlimited backups of a list of files defined by the user and for other files to behave like its usual backup system.
The motivation is that it would be desirable that Emacs keeps several backups of a list of some important files (defined by the user), like
/path/to/my_important_file.txt, (1) by creating a numbered version control of them, like the above code (2) never deletes the old versions and (3) for other files, Emacs keeps its standard backup system.
Based on the answer provided by Drew (suggesting to use local variables and the version-control variable) we can add this at the end of the files that we would like to keep an unlimited number of backups of them (for making the changes permanent, after reopening the file we can answer the question about applying the values of the these variables by
;; Local Variables: ;; version-control: t ;; make-backup-files: t ;; delete-old-versions: never ;; End:
For keeping the last
N backups of a file we should add this at the end of that file
(for example for N=50):
;; Local Variables: ;; version-control: t ;; make-backup-files: t ;; delete-old-versions: t ;; kept-new-versions: 50 ;; kept-old-versions: 0 ;; End:
eval: (setq ...)in your local variables comments. Just use, e.g.,
version-control: t. (And in fact with your
setqapproach you're probably going to end up not creating buffer-local bindings for those variables; so unless they were already buffer-local, you'd be setting the global values.)
'never. Symbols are treated as quoted by default in the local variable syntax, so your current line is actually equivalent to
(setq-local delete-old-versions (quote (quote never)))