Hide emacs’ backups inside an hidden folder
browsing a working directory full of files and their backups, cli or gui wise, was turning into an annoying vision.
So, finally i decided to make those backups go elsewhere!
With the help of the friendly irc ppl (#emacs in irc.freenode.org) and building on Ryan Barrett (from /snarfed.org) i came into this:
;; create an invisible backup directory and make the backups also invisable
(defun make-backup-file-name (filename)
(defvar backups-dir "./.backups/")
(make-directory backups-dir t)
(expand-file-name
(concat backups-dir "." (file-name-nondirectory filename) "~")
(file-name-directory filename)))
Put those lines in .emacs (on your home folder ‘~/’) and on the next time you start your emacs the backups will be placed inside a hidden folder (.backups) on the directory were your file is visited (opened) and these backups will also be hidden (.namefile~). So, if you are visiting /some/dir/somefile.el it will create /some/dir/.backups/.somefile.el~
simple isn’t it?
also i’ve learned to evaluate a function inside emacs: M-x eval-defun RET
(place the cursor on the line of the function to be evaluated)
this M-x toggle-debug-on-error RET will make emacs show up a backtrace if an error comes up

Thank you! I’ve looking for this for a while but was too lazy to google until now. I did change the backup directory to .emacs.backups to my $HOME directory though
D
November 22, 2008