Although I start my init.el by setting `user-emacs-directory' to something that suits me, emacs keeps on creating an unwanted "~/.emacs.d/".
How to reproduce:
Create an init file, say "~/.config/emacs/please-do-it.el":
(setq user-emacs-directory "~/.cache/emacs/")
;; (setq auto-save-list-file-prefix ;; I shall not have to do this
;; (concat user-emacs-directory "saves"))
Do the following in a shell session:
$ cd
$ rm -r .emacs.d # actually there was one
$ ls .emacs.d
ls: cannot access '.emacs.d': No such file or directory
$ emacs -l ~/.config/emacs/please-do-it.el &
$ ls -d .emacs.d
.emacs.d
$ ls .emacs.d
$
There's nothing in .emacs.d, but the directory is there. It should not, as this is not my choice as an emacs user, and the only way I've got to state this is setting `user-emacs-directory' in my init file.
Let's edit some file with emacs and wait about 2 minutes:
$ ls .emacs.d
auto-save-list
$
In emacs, describe variable `user-emacs-directory': this is actually what I want, namely "~/.cache/emacs/".
Quit emacs
Is the auto-save guilty ? If I uncomment the part related to auto-save in please-to-it.el:
$ rm -r .emacs.d
$ emacs -l ~/.config/emacs/please-do-it.el &
$ ls -d .emacs.d
.emacs.d
$
Edit some file and wait about 2 minutes; then:
$ ls .emacs.d
$
Nothing in .emacs.d. Let's see what I asked for auto-save:
$ ls .cache/emacs
saves14634-xanadu~
$
Alright... but it's not legitimate: as I've set `user-emacs-directory', I should not have to furthermore tell auto-save where to put its material. If I need to, this means I need to also for every possible package that uses user-emacs-directory. And emacs still trashes my home directory.
I did not find bug reports on the subject, except for this one, which is precisely on topic: