I'm a Vim user trying to migrate to Emacs. When using Vim I wrote a simple code (in vimscript) where it saves me a copy of my working file (with the file name plus date and time) everytime I open or save it.
I tried doing it with Emacs but ended up in a loophole. Here's what I wrote so far:
Code: Select all
(defvar autobk-default-dir "~/.emacsbk/")
(defun autobk-save ()
"func description"
(interactive)
(defvar autobk-orignal-file-name buffer-file-name)
(write-file (concat
autobk-default-dir
(buffer-name)
"_"
(shell-command-to-string "echo -n $(date +%Y-%m-%d)")
".bak"))
(write-file autobk-orignal-file-name)
(message buffer-file-name))
(add-hook 'before-save-hook 'autobk-save)
Thank you in advance