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 ()
(defvar autobk-orignal-file-name buffer-file-name)
(shell-command-to-string "echo -n $(date +%Y-%m-%d)")
(add-hook 'before-save-hook 'autobk-save)
The loophole happens because I add the function autobk-save to the before-save-hook and inside autobk-save I try to save the file, which calls the hook which calls the function again and again. So I think I need a way to tell the write-file function inside autobk-save to not use the hook, right? I tried sniffing around the file.el code but haven't found a clue the could help me. I know this is probably a bad code and maybe also a bad question, but I'm still a beginner with lisp and I'm open to any suggestions.
Thank you in advance