Practicing Safe Emacs
This has been bugging me for years and I finally got around to looking up a solution.
Everyone knows that Emacs is the greatest editor on the planet, superior in all ways to vi. Unfortunately, Emacs has this nasty habit of tossing tilde-terminated backup files around whatever directory in which you happen to be editing. Not only does this clutter up the file system, it can also be something of a security risk; especially if you’re working on web servers. And really, snapshots of your most recent save is not so useful if, like me, you pathologically
ctrl-x ctrl-s your code every few characters or so.
After a bit of hunting I discovered that Emacs’ built-in versioning could solve both of these problems. Cons the following two commands into your local .emacs:
;; Enable versioning with default values.
(setq version-control t)
;; Save all backup file into the designated directory.
(setq backup-directory-alist (quote ((".*" . "~/.emacs.d/backups/"))))
and not only will Emacs remember all saves:
$ ls .emacs.d/backups/
but, as you see, it also tucks your backups safely out of harm’s way.