I’ve tried many ways to build a clean testing environment for Emacs editor on my Ubuntu machine. One previous attempt showed a possible way to do so:

$ emacs -Q -l some_startup_script.el

But this solution doesn’t show the real state of affairs when we load all the configuration files in Emacs. The .emacs file is loaded in the middle of the Emacs initialization, not at the end. See for details 39.1.1 Summary: Sequence of Actions at Startup. One possible problem is that package.el loads its configuration before you’ve done custom changes.

For now I consider a better way starting Emacs from another user:

$ emacs -u emacstestuser

All customizations can be done in the .emacs.d directory from emacstestuser. The only thing you need is changing of user specific variables:

(setq user-emacs-directory "/home/emacstestuser/.emacs.d")