# emacs not load (.emacs) configuration file

I am using emacs on ubuntu 9.04.

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

My emacs file is called .emacs

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

M-X Transient-mark-mode


My emacs file is listed below:

;; Emac customization file path

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

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

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


-

## migrated from stackoverflow.comSep 3 '11 at 7:51

This question came from our site for professional and enthusiast programmers.

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)


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?
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.