I have followed this answer's solution. My goal is to back up files right after I save them.
When I create a new file it is successfully backed up to the given path, but when I close and re-open Emacs the file that I was working on is not backed up or created. Please note that I have created new key bindings for saving and closing.
my setup:
(defvar --backup-directory (concat user-emacs-directory "backups_alper"))
(if (not (file-exists-p --backup-directory))
(make-directory --backup-directory t))
(setq backup-directory-alist `(("." . ,--backup-directory)))
(setq backup-by-copying t)
(setq backup-by-copying t ; don't clobber symlinks
version-control t ; version numbers for backup files
delete-old-versions t ; delete excess backup files silently
delete-by-moving-to-trash t
kept-old-versions 6 ; oldest versions to keep when a new numbered backup is made (default: 2)
kept-new-versions 9 ; newest versions to keep when a new numbered backup is made (default: 2)
auto-save-default t ; auto-save every buffer that visits a file
auto-save-timeout 20 ; number of seconds idle time before auto-save (default: 30)
auto-save-interval 200 ; number of keystrokes between auto-saves (default: 300)
)
;; my save:
(defun my-save-all () "My doc-string."
(interactive)
(let ((message-log-max nil)
(inhibit-message t))
(save-some-buffers t)))
(defun save-all ()
(interactive)
(my-save-all)
(bk-kill-buffers "magit: project")
(bk-kill-buffers "init.py")
(bk-kill-buffers "*helm"))
(define-key ctl-x-map "\C-s" 'save-all)
;; closing emacs
(defun my-kill-emacs ()
"save some buffers, then exit unconditionally"
(interactive)
(my-save-all)
;; (save-some-buffers nil t)
(save-buffers-kill-terminal))
(global-set-key (kbd "C-x C-c") 'my-kill-emacs)
.emacs
file but it didn't make any affect @mmmmmm – alper Jan 05 '21 at 19:38my-save-all()
function? I try to runle::save-buffer-force-backup
function but I am not sure where did it save the backup if it does – alper Jan 05 '21 at 19:52recentf
and.emacs
files are saved – alper Jan 05 '21 at 22:42(savehist-mode 1)
I keep getting(void-variable pell-buffer) signal(void-variable (pell-buffer)) savehist-mode(1)
that might be the main cause – alper Jan 14 '21 at 12:05