I am using Emacs on Ubuntu 9.04.

I have my emacs configuration file in the ~/.emacs.d directory.

My emacs file is called .emacs.

I have some basic configuration. However, when I start emacs, it never loads my configuration and I have to keep doing it manually using e.g.

M-X Transient-mark-mode

My emacs file is listed below:

;; Emac customization file path
(add-to-list 'load-path "~/emacs.d")

;; Use font lock mode
(global-font-lock-mode t)

;; Highlight cursor line
(global-hl-line-mode t)

;; Highlight selected region
(transient-mark-mode t)

I want to add to this configuration instead of manually adding entries.

6 Answers 6


Your init file contains personal EmacsLisp code that you want to execute when you start Emacs.

  • For GnuEmacs, it is ~/.emacs or _emacs or ~/.emacs.d/init.el.
  • For XEmacs, it is ~/.xemacs or ~/.xemacs/init.el.

Torok Gabor's answer is what you are looking for. I only wish to point out a minor typo in your init file, it should be

(add-to-list 'load-path "~/.emacs.d")

As Török said, probably you need to rename emacs to init.el.

One thing that drove me crazy for a while is that if ~/.emacs exists then emacs doesn't load ~/.emacs.d/init.el. So, if you have a ~/.emacs either delete it and move its contents into the other file, or (load "~/.emacs.d/init.el") inside ~/.emacs.


It should be mentioned, however, that only Emacs 22+ loads ~/.emacs.d/init.el as alternate per-user init file. As a new but downward-compatible feature it priorizes ~/.emacs. This is arranged in lisp/startup.el.

After startup the user-init-file variable contains the full pathname of the init file in charge, e.g. /home/me/.emacs.elc or C:\Users\Me\.emacs.d\init.el etc. To see its value, in the *scratch* buffer type (insert user-init-file) followed by C-x C-e.

The ~/.emacs.d/ directory is actually a standard location for additional per-user files. The path is defined by the Emacs variable user-emacs-directory. Under Windows this path depends on the HOME (not USERPROFILE) variable. When HOME is set to C:\, for example, it will be C:\.emacs.d. When running Emacs portably I put upon this behavior, by using a batch-file that sets HOME to a directory on the pen drive.

There are not only Lisp files in this directory! For example, the auto-save feature by default stores any edited file into ~/.emacs.d/auto-save-list/ (see the auto-save-list-file-prefix variable). This inspired me to store backup-files there too:

(defvar --user-backup-directory (concat user-emacs-directory "backups"))
(if (not (file-exists-p --user-backup-directory))
    (make-directory --user-backup-directory t))
(setq backup-directory-alist `(("." . ,--user-backup-directory)))
(setq make-backup-files t)

Prior to Emacs 22 I also had a ~/elisp directory for my personal Lisp files. Now I use

(pushnew (expand-file-name "~/.emacs.d/elisp") load-path)

as advised here.

So ~/.emacs.d is actually quite useful, although I find the idea of ~/.emacs.d/init.el questionable. The ~/.emacs.d/ directory is a standard location for additional per-user files. Wouldn't it make more sense when Emacs reads ~/.emacs.d/init.el additionally to ~/.emacs.el?


Another thing to try if what everyone else said does not work for you, is to chown the .emacs and .emacs.d file and directory.

For some reason my .emacs and .emacs.d were owned by root and emacs would not load it unless I did sudo emacs.

A simple sudo chown `whoami` .emacs did it.


I had this problem too, when switching into a container.

It turned out, that the environment wasn't set up properly, and the USER and HOME variable still pointed to the root user, even though I was logged in as my working user.

Doing a su - <username> fixed it, because now the environment was initialized as expected.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.