Emacs quick tip: No file tree pollution

This is just a quick tip for Emacs beginners. I didn’t find these informations in one place, so it might be useful for somebody:

If not configured otherwise Emacs will create three different special files when editing a file:

All files will are named similar to the files edited and placed in the same directory. I really dislike this default behaviour, because I don’t want any “magic” files appearing in my projects.

So here is the emacs config to deactivate each feature or to save the files in a different place:

 (setq backup-directory-alist
          `((".*" . ,temporary-file-directory)))
 (setq auto-save-file-name-transforms
          `((".*" ,temporary-file-directory t)))         
 (setq create-lockfiles nil)